11 #ifndef EIGEN_SPARSEVIEW_H
12 #define EIGEN_SPARSEVIEW_H
18 template<
typename MatrixType>
19 struct traits<SparseView<MatrixType> > : traits<MatrixType>
21 typedef typename MatrixType::Index Index;
22 typedef Sparse StorageKind;
24 Flags = int(traits<MatrixType>::Flags) & (
RowMajorBit)
30 template<
typename MatrixType>
31 class SparseView :
public SparseMatrixBase<SparseView<MatrixType> >
33 typedef typename MatrixType::Nested MatrixTypeNested;
34 typedef typename internal::remove_all<MatrixTypeNested>::type _MatrixTypeNested;
36 EIGEN_SPARSE_PUBLIC_INTERFACE(SparseView)
38 SparseView(const MatrixType& mat, const Scalar& m_reference = Scalar(0),
39 typename NumTraits<Scalar>::Real m_epsilon = NumTraits<Scalar>::dummy_precision()) :
40 m_matrix(mat), m_reference(m_reference), m_epsilon(m_epsilon) {}
44 inline Index rows()
const {
return m_matrix.rows(); }
45 inline Index cols()
const {
return m_matrix.cols(); }
47 inline Index innerSize()
const {
return m_matrix.innerSize(); }
48 inline Index outerSize()
const {
return m_matrix.outerSize(); }
51 MatrixTypeNested m_matrix;
53 typename NumTraits<Scalar>::Real m_epsilon;
56 template<
typename MatrixType>
57 class SparseView<MatrixType>::InnerIterator :
public _MatrixTypeNested::InnerIterator
59 typedef typename SparseView::Index Index;
61 typedef typename _MatrixTypeNested::InnerIterator IterBase;
62 InnerIterator(
const SparseView& view, Index outer) :
63 IterBase(view.m_matrix, outer), m_view(view)
68 EIGEN_STRONG_INLINE InnerIterator& operator++()
70 IterBase::operator++();
75 using IterBase::value;
78 const SparseView& m_view;
81 void incrementToNonZero()
83 while((
bool(*
this)) && internal::isMuchSmallerThan(value(), m_view.m_reference, m_view.m_epsilon))
85 IterBase::operator++();
90 template<
typename Derived>
91 const SparseView<Derived> MatrixBase<Derived>::sparseView(
const Scalar& m_reference,
92 const typename NumTraits<Scalar>::Real& m_epsilon)
const
94 return SparseView<Derived>(derived(), m_reference, m_epsilon);
const unsigned int RowMajorBit
Definition: Constants.h:53