10 #ifndef EIGEN_SPARSE_COMPRESSED_BASE_H 11 #define EIGEN_SPARSE_COMPRESSED_BASE_H 19 template<
typename Derived>
35 template<
typename Derived>
42 using Base::operator=;
43 using Base::IsRowMajor;
46 class ReverseInnerIterator;
58 if(Derived::IsVectorAtCompileTime && outerIndexPtr()==0)
59 return derived().nonZeros();
60 else if(isCompressed())
61 return outerIndexPtr()[derived().outerSize()]-outerIndexPtr()[0];
62 else if(derived().outerSize()==0)
65 return innerNonZeros().sum();
135 template<
typename Derived>
140 : m_values(0), m_indices(0), m_outer(0), m_id(0), m_end(0)
144 : m_values(other.m_values), m_indices(other.m_indices), m_outer(other.m_outer), m_id(other.m_id), m_end(other.m_end)
158 : m_values(mat.valuePtr()), m_indices(mat.innerIndexPtr()), m_outer(outer)
176 : m_values(mat.valuePtr()), m_indices(mat.innerIndexPtr()), m_outer(0), m_id(0), m_end(mat.nonZeros())
182 : m_values(data.valuePtr()), m_indices(data.indexPtr()), m_outer(0), m_id(0), m_end(data.
size())
194 inline Index row()
const {
return IsRowMajor ? m_outer.value() : index(); }
195 inline Index col()
const {
return IsRowMajor ? index() : m_outer.value(); }
197 inline operator bool()
const {
return (m_id < m_end); }
213 template<
typename Derived>
218 : m_values(mat.valuePtr()), m_indices(mat.innerIndexPtr()), m_outer(outer)
236 : m_values(mat.valuePtr()), m_indices(mat.innerIndexPtr()), m_outer(0), m_start(0), m_id(mat.nonZeros())
242 : m_values(data.valuePtr()), m_indices(data.indexPtr()), m_outer(0), m_start(0), m_id(data.
size())
254 inline Index row()
const {
return IsRowMajor ? m_outer.value() : index(); }
255 inline Index col()
const {
return IsRowMajor ? index() : m_outer.value(); }
257 inline operator bool()
const {
return (m_id > m_start); }
270 template<
typename Derived>
279 Flags = Derived::Flags
286 explicit evaluator(
const Derived &mat) : m_matrix(&mat), m_zero(0)
292 return m_matrix->nonZeros();
295 operator Derived&() {
return m_matrix->const_cast_derived(); }
296 operator const Derived&()
const {
return *m_matrix; }
301 Index p = find(row,col);
306 return m_matrix->const_cast_derived().valuePtr()[p];
311 Index p = find(row,col);
313 return m_matrix->const_cast_derived().valuePtr()[p];
322 const Index outer = Derived::IsRowMajor ? row :
col;
323 const Index inner = Derived::IsRowMajor ? col :
row;
325 Index start = m_matrix->outerIndexPtr()[outer];
326 Index end = m_matrix->isCompressed() ? m_matrix->outerIndexPtr()[outer+1] : m_matrix->outerIndexPtr()[outer] + m_matrix->innerNonZeroPtr()[outer];
327 eigen_assert(end>=start &&
"you are using a non finalized sparse matrix or written coefficient does not exist");
328 const Index p = std::lower_bound(m_matrix->innerIndexPtr()+start, m_matrix->innerIndexPtr()+end,inner) - m_matrix->innerIndexPtr();
330 return ((p<end) && (m_matrix->innerIndexPtr()[p]==inner)) ? p :
Dynamic;
341 #endif // EIGEN_SPARSE_COMPRESSED_BASE_H ReverseInnerIterator(const internal::CompressedStorage< Scalar, StorageIndex > &data)
SparseMatrixBase< Derived > Base
const Eigen::Map< const IndexVector > innerNonZeros() const
A matrix or vector expression mapping an existing array of data.
TFSIMD_FORCE_INLINE void setValue(const tfScalar &x, const tfScalar &y, const tfScalar &z)
evaluator(const Derived &mat)
InnerIterator(const InnerIterator &other)
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T value()
StorageIndex * innerIndexPtr()
static constexpr size_t size(Tuple< Args... > &)
Provides access to the number of elements in a tuple as a compile-time constant expression.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
InnerIterator & operator++()
Eigen::Index Index
The interface type of indices.
const Scalar & coeff(Index row, Index col) const
const Map< const Array< Scalar, Dynamic, 1 > > coeffs() const
Map< Array< Scalar, Dynamic, 1 > > coeffs()
internal::traits< Block< const SparseMatrix< _Scalar, _Options, _StorageIndex >, BlockRows, BlockCols, true > >::StorageIndex StorageIndex
const StorageIndex * m_indices
#define EIGEN_INTERNAL_CHECK_COST_VALUE(C)
#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
EIGEN_DEVICE_FUNC ColXpr col(Index i)
This is the const version of col().
Base class of any sparse matrices or sparse expressions.
const StorageIndex * outerIndexPtr() const
Derived::InnerIterator InnerIterator
const StorageIndex * innerNonZeroPtr() const
StorageIndex * innerNonZeroPtr()
internal::traits< Block< const SparseMatrix< _Scalar, _Options, _StorageIndex >, BlockRows, BlockCols, true > >::Scalar Scalar
internal::variable_if_dynamic< Index, Derived::IsVectorAtCompileTime?0:Dynamic > OuterType
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
InnerIterator(const internal::CompressedStorage< Scalar, StorageIndex > &data)
EIGEN_DEVICE_FUNC RowXpr row(Index i)
This is the const version of row(). */.
InnerIterator(const SparseCompressedBase &mat, Index outer)
const StorageIndex * innerIndexPtr() const
Index nonZerosEstimate() const
const Scalar & value() const
internal::variable_if_dynamic< Index, Derived::IsVectorAtCompileTime?0:Dynamic > OuterType
ReverseInnerIterator(const SparseCompressedBase &mat)
DenseCoeffsBase< Derived, ReadOnlyAccessors >::CoeffReturnType CoeffReturnType
bool isCompressed() const
StorageIndex index() const
InnerIterator & operator=(const InnerIterator &other)
StorageIndex * outerIndexPtr()
const Scalar & value() const
const StorageIndex * m_indices
static ConstMapType Map(const Scalar *data)
ReverseInnerIterator(const SparseCompressedBase &mat, Index outer)
ReverseInnerIterator & operator--()
#define eigen_internal_assert(x)
const Scalar * valuePtr() const
Common base class for sparse [compressed]-{row|column}-storage format.
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
InnerIterator(const SparseCompressedBase &mat)
Index find(Index row, Index col) const
StorageIndex index() const
An InnerIterator allows to loop over the element of any matrix expression.
Scalar & coeffRef(Index row, Index col)