11 #ifndef EIGEN_SPARSEVIEW_H
12 #define EIGEN_SPARSEVIEW_H
20 template<
typename MatrixType>
21 struct traits<SparseView<
MatrixType> > : traits<MatrixType>
24 typedef Sparse StorageKind;
26 Flags = int(traits<MatrixType>::Flags) & (
RowMajorBit)
46 template<
typename MatrixType>
85 template<
typename ArgType>
86 struct unary_evaluator<
SparseView<ArgType>, IteratorBased>
87 :
public evaluator_base<SparseView<ArgType> >
89 typedef typename evaluator<ArgType>::InnerIterator
EvalIterator;
96 typedef typename XprType::Scalar Scalar;
99 EIGEN_STRONG_INLINE InnerIterator(
const unary_evaluator& sve,
Index outer)
102 incrementToNonZero();
105 EIGEN_STRONG_INLINE InnerIterator&
operator++()
108 incrementToNonZero();
112 using EvalIterator::value;
115 const XprType &m_view;
118 void incrementToNonZero()
128 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
129 Flags = XprType::Flags
132 explicit unary_evaluator(
const XprType& xpr) : m_argImpl(xpr.nestedExpression()), m_view(xpr) {}
135 evaluator<ArgType> m_argImpl;
136 const XprType &m_view;
139 template<
typename ArgType>
140 struct unary_evaluator<SparseView<ArgType>, IndexBased>
141 :
public evaluator_base<SparseView<ArgType> >
144 typedef SparseView<ArgType> XprType;
147 typedef typename XprType::Scalar Scalar;
148 typedef typename XprType::StorageIndex StorageIndex;
155 EIGEN_STRONG_INLINE InnerIterator(
const unary_evaluator& sve,
Index outer)
156 : m_sve(sve), m_inner(0), m_outer(outer), m_end(sve.m_view.innerSize())
158 incrementToNonZero();
161 EIGEN_STRONG_INLINE InnerIterator&
operator++()
164 incrementToNonZero();
168 EIGEN_STRONG_INLINE Scalar value()
const
170 return (IsRowMajor) ? m_sve.m_argImpl.coeff(m_outer, m_inner)
171 : m_sve.m_argImpl.coeff(m_inner, m_outer);
174 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_inner; }
175 inline Index row()
const {
return IsRowMajor ? m_outer : index(); }
176 inline Index col()
const {
return IsRowMajor ? index() : m_outer; }
178 EIGEN_STRONG_INLINE
operator bool()
const {
return m_inner < m_end && m_inner>=0; }
181 const unary_evaluator &m_sve;
187 void incrementToNonZero()
197 CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
198 Flags = XprType::Flags
201 explicit unary_evaluator(
const XprType& xpr) : m_argImpl(xpr.nestedExpression()), m_view(xpr) {}
204 evaluator<ArgType> m_argImpl;
205 const XprType &m_view;
227 template<
typename Derived>
246 template<
typename Derived>
249 const RealScalar& epsilon)
const
RowXpr row(Index i)
This is the const version of row(). */.
ColXpr col(Index i)
This is the const version of col().
#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
Matrix< float, 1, Dynamic > MatrixType
internal::traits< Derived >::StorageIndex StorageIndex
The type used to store indices.
internal::traits< Derived >::Scalar Scalar
The matrix class, also used for vectors and row-vectors.
Base class of any sparse matrices or sparse expressions.
internal::traits< SparseView< MatrixType > >::Scalar Scalar
const SparseView< Derived > pruned(const Scalar &reference=Scalar(0), const RealScalar &epsilon=NumTraits< Scalar >::dummy_precision()) const
Expression of a dense or sparse matrix with zero or too small values removed.
internal::remove_all_t< MatrixType > NestedExpression
MatrixType::Nested MatrixTypeNested
SparseMatrixBase< SparseView > Base
const internal::remove_all_t< MatrixTypeNested > & nestedExpression() const
internal::remove_all_t< MatrixTypeNested > MatrixTypeNested_
MatrixTypeNested m_matrix
RealScalar epsilon() const
const SparseView< Derived > sparseView(const Scalar &m_reference=Scalar(0), const typename NumTraits< Scalar >::Real &m_epsilon=NumTraits< Scalar >::dummy_precision()) const
const unsigned int RowMajorBit
bfloat16 operator++(bfloat16 &a)
typename remove_all< T >::type remove_all_t
bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Eigen::Index Index
The interface type of indices.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.