11#ifndef EIGEN_SPARSEVIEW_H
12#define EIGEN_SPARSEVIEW_H
18template<
typename MatrixType>
21 typedef typename MatrixType::StorageIndex StorageIndex;
30template<
typename MatrixType>
33 typedef typename MatrixType::Nested MatrixTypeNested;
40 explicit SparseView(
const MatrixType&
mat,
const Scalar& reference = Scalar(0),
42 : m_matrix(
mat), m_reference(reference), m_epsilon(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(); }
54 Scalar reference()
const {
return m_reference; }
55 RealScalar epsilon()
const {
return m_epsilon; }
58 MatrixTypeNested m_matrix;
69template<
typename ArgType>
79 typedef typename XprType::Scalar Scalar;
83 : EvalIterator(
sve.m_argImpl,outer), m_view(
sve.m_view)
90 EvalIterator::operator++();
95 using EvalIterator::value;
101 void incrementToNonZero()
103 while((
bool(*
this)) && internal::isMuchSmallerThan(value(), m_view.reference(), m_view.epsilon()))
105 EvalIterator::operator++();
112 Flags = XprType::Flags
119 const XprType &m_view;
122template<
typename ArgType>
130 typedef typename XprType::Scalar Scalar;
131 typedef typename XprType::StorageIndex StorageIndex;
139 : m_sve(
sve), m_inner(0), m_outer(outer), m_end(
sve.m_view.innerSize())
141 incrementToNonZero();
147 incrementToNonZero();
151 EIGEN_STRONG_INLINE Scalar value()
const
153 return (IsRowMajor) ? m_sve.m_argImpl.coeff(m_outer, m_inner)
154 : m_sve.m_argImpl.coeff(m_inner, m_outer);
157 EIGEN_STRONG_INLINE StorageIndex index()
const {
return m_inner; }
158 inline Index row()
const {
return IsRowMajor ? m_outer : index(); }
159 inline Index col()
const {
return IsRowMajor ? index() : m_outer; }
170 void incrementToNonZero()
172 while((
bool(*
this)) && internal::isMuchSmallerThan(value(), m_sve.m_view.reference(), m_sve.m_view.epsilon()))
181 Flags = XprType::Flags
188 const XprType &m_view;
193template<
typename Derived>
194const SparseView<Derived> MatrixBase<Derived>::sparseView(
const Scalar& reference,
195 const typename NumTraits<Scalar>::Real& epsilon)
const
197 return SparseView<Derived>(derived(), reference, epsilon);
212template<
typename Derived>
213const SparseView<Derived>
An InnerIterator allows to loop over the element of any matrix expression.
Definition CoreIterators.h:34
Pseudo expression representing a solving operation.
Definition Solve.h:63
Base class of any sparse matrices or sparse expressions.
Definition SparseMatrixBase.h:34
NumTraits< Scalar >::Real RealScalar
This is the "real scalar" type; if the Scalar type is already real numbers (e.g.
Definition SparseMatrixBase.h:125
Definition SparseView.h:32
const internal::remove_all< MatrixTypeNested >::type & nestedExpression() const
Definition SparseView.h:52
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:61
Holds information about the various numeric (i.e.
Definition NumTraits.h:108
The type used to identify a general sparse storage.
Definition Constants.h:493
Definition Constants.h:525
Definition Constants.h:528
Definition CoreEvaluators.h:101
Definition CoreEvaluators.h:82
Definition ForwardDeclarations.h:17
Definition CoreEvaluators.h:56