Eigen::SparseMapBase< Derived, ReadOnlyAccessors > Class Template Reference

Common base class for Map and Ref instance of sparse matrix and vector. More...

+ Inheritance diagram for Eigen::SparseMapBase< Derived, ReadOnlyAccessors >:

Public Types

enum  { IsRowMajor }
 
typedef SparseCompressedBase< Derived > Base
 
typedef Base::Scalar Scalar
 
typedef Base::StorageIndex StorageIndex
 
- Public Types inherited from Eigen::SparseCompressedBase< Derived >
typedef SparseMatrixBase< Derived > Base
 
- Public Types inherited from Eigen::SparseMatrixBase< Derived >
enum  {
  RowsAtCompileTime ,
  ColsAtCompileTime ,
  SizeAtCompileTime ,
  MaxRowsAtCompileTime ,
  MaxColsAtCompileTime ,
  MaxSizeAtCompileTime ,
  IsVectorAtCompileTime ,
  NumDimensions ,
  Flags ,
  IsRowMajor ,
  InnerSizeAtCompileTime
}
 
typedef std::conditional_t< NumTraits< Scalar >::IsComplex, CwiseUnaryOp< internal::scalar_conjugate_op< Scalar >, Eigen::Transpose< const Derived > >, Transpose< const Derived > > AdjointReturnType
 
typedef Transpose< const Derived > ConstTransposeReturnType
 
typedef Matrix< StorageIndex, Dynamic, 1 > IndexVector
 
typedef internal::add_const_on_value_type_if_arithmetic< typename internal::packet_traits< Scalar >::type >::type PacketReturnType
 
typedef internal::packet_traits< Scalar >::type PacketScalar
 
typedef SparseMatrix< Scalar, Flags &RowMajorBit ? RowMajor :ColMajor, StorageIndexPlainObject
 
typedef internal::traits< Derived >::Scalar Scalar
 
typedef Matrix< Scalar, Dynamic, 1 > ScalarVector
 
typedef SparseMatrixBase StorageBaseType
 
typedef internal::traits< Derived >::StorageIndex StorageIndex
 
typedef internal::traits< Derived >::StorageKind StorageKind
 
typedef Transpose< Derived > TransposeReturnType
 
typedef Scalar value_type
 
- Public Types inherited from Eigen::EigenBase< Derived >
typedef Eigen::Index Index
 The interface type of indices. More...
 
typedef internal::traits< Derived >::StorageKind StorageKind
 

Public Member Functions

Scalar coeff (Index row, Index col) const
 
Index cols () const
 
const StorageIndexinnerIndexPtr () const
 
const StorageIndexinnerNonZeroPtr () const
 
Index innerSize () const
 
bool isCompressed () const
 
Index nonZeros () const
 
Derived & operator= (const Derived &other)
 
template<typename OtherDerived >
Derived & operator= (const EigenBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator= (const ReturnByValue< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator= (const SparseMatrixBase< OtherDerived > &other)
 
const StorageIndexouterIndexPtr () const
 
Index outerSize () const
 
Index rows () const
 
 SparseMapBase (Index rows, Index cols, Index nnz, IndexPointer outerIndexPtr, IndexPointer innerIndexPtr, ScalarPointer valuePtr, IndexPointer innerNonZerosPtr=0)
 
 SparseMapBase (Index size, Index nnz, IndexPointer innerIndexPtr, ScalarPointer valuePtr)
 
const ScalarvaluePtr () const
 
 ~SparseMapBase ()
 
- Public Member Functions inherited from Eigen::SparseCompressedBase< Derived >
Map< Array< Scalar, Dynamic, 1 > > coeffs ()
 
const Map< const Array< Scalar, Dynamic, 1 > > coeffs () const
 
StorageIndexinnerIndexPtr ()
 
const StorageIndexinnerIndexPtr () const
 
template<class Comp = std::less<>>
Index innerIndicesAreSorted () const
 
template<class Comp = std::less<>>
Index innerIndicesAreSorted (Index begin, Index end) const
 
StorageIndexinnerNonZeroPtr ()
 
const StorageIndexinnerNonZeroPtr () const
 
bool isCompressed () const
 
Index nonZeros () const
 
Derived & operator= (const Derived &other)
 
template<typename OtherDerived >
Derived & operator= (const EigenBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator= (const ReturnByValue< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator= (const SparseMatrixBase< OtherDerived > &other)
 
StorageIndexouterIndexPtr ()
 
const StorageIndexouterIndexPtr () const
 
template<class Comp = std::less<>>
void sortInnerIndices ()
 
template<class Comp = std::less<>>
void sortInnerIndices (Index begin, Index end)
 
ScalarvaluePtr ()
 
const ScalarvaluePtr () const
 
- Public Member Functions inherited from Eigen::SparseMatrixBase< Derived >
const AdjointReturnType adjoint () const
 
RealScalar blueNorm () const
 
Index cols () const
 
template<typename OtherDerived >
const SparseMatrixBase< Derived >::template CwiseProductDenseReturnType< OtherDerived >::Type cwiseProduct (const MatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
const CwiseProductDenseReturnType< OtherDerived >::Type cwiseProduct (const MatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
internal::traits< Derived >::Scalar dot (const MatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
Scalar dot (const MatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
internal::traits< Derived >::Scalar dot (const SparseMatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
Scalar dot (const SparseMatrixBase< OtherDerived > &other) const
 
const internal::eval< Derived >::type eval () const
 
Index innerSize () const
 
template<typename OtherDerived >
bool isApprox (const MatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
template<typename OtherDerived >
bool isApprox (const SparseMatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
bool isRValue () const
 
bool isVector () const
 
Derived & markAsRValue ()
 
RealScalar norm () const
 
template<typename OtherDerived >
const Product< Derived, OtherDerived > operator* (const DiagonalBase< OtherDerived > &other) const
 
template<typename OtherDerived >
const Product< Derived, OtherDerived > operator* (const MatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
const Product< Derived, OtherDerived, AliasFreeProductoperator* (const SparseMatrixBase< OtherDerived > &other) const
 
Derived & operator*= (const Scalar &other)
 
template<typename OtherDerived >
Derived & operator*= (const SparseMatrixBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator+= (const DiagonalBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator+= (const EigenBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator+= (const SparseMatrixBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator-= (const DiagonalBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator-= (const EigenBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator-= (const SparseMatrixBase< OtherDerived > &other)
 
Derived & operator/= (const Scalar &other)
 
Derived & operator= (const Derived &other)
 
template<typename OtherDerived >
Derived & operator= (const EigenBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator= (const ReturnByValue< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator= (const SparseMatrixBase< OtherDerived > &other)
 
Index outerSize () const
 
const SparseView< Derived > pruned (const Scalar &reference=Scalar(0), const RealScalar &epsilon=NumTraits< Scalar >::dummy_precision()) const
 
Index rows () const
 
template<unsigned int UpLo>
SelfAdjointViewReturnType< UpLo >::Type selfadjointView ()
 
template<unsigned int UpLo>
SparseMatrixBase< Derived >::template SelfAdjointViewReturnType< UpLo >::Type selfadjointView ()
 
template<unsigned int UpLo>
ConstSelfAdjointViewReturnType< UpLo >::Type selfadjointView () const
 
template<unsigned int UpLo>
SparseMatrixBase< Derived >::template ConstSelfAdjointViewReturnType< UpLo >::Type selfadjointView () const
 
Index size () const
 
 SparseMatrixBase ()
 
RealScalar squaredNorm () const
 
Scalar sum () const
 
DenseMatrixType toDense () const
 
TransposeReturnType transpose ()
 
const ConstTransposeReturnType transpose () const
 
template<int Mode>
const TriangularView< const Derived, Mode > triangularView () const
 
SparseSymmetricPermutationProduct< Derived, Upper|LowertwistedBy (const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
 
- Public Member Functions inherited from Eigen::EigenBase< Derived >
template<typename Dest >
void addTo (Dest &dst) const
 
template<typename Dest >
void applyThisOnTheLeft (Dest &dst) const
 
template<typename Dest >
void applyThisOnTheRight (Dest &dst) const
 
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
Derived & const_cast_derived () const
 
const Derived & const_derived () const
 
Derived & derived ()
 
const Derived & derived () const
 
template<typename Dest >
void evalTo (Dest &dst) const
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index size () const EIGEN_NOEXCEPT
 
template<typename Dest >
void subTo (Dest &dst) const
 

Protected Types

typedef std::conditional_t< bool(internal::is_lvalue< Derived >::value), StorageIndex *, const StorageIndex * > IndexPointer
 
typedef std::conditional_t< bool(internal::is_lvalue< Derived >::value), Scalar *, const Scalar * > ScalarPointer
 
- Protected Types inherited from Eigen::SparseCompressedBase< Derived >
typedef Base::IndexVector IndexVector
 

Protected Member Functions

 SparseMapBase ()
 
- Protected Member Functions inherited from Eigen::SparseCompressedBase< Derived >
Eigen::Map< IndexVectorinnerNonZeros ()
 
const Eigen::Map< const IndexVectorinnerNonZeros () const
 
internal::LowerBoundIndex lower_bound (Index row, Index col) const
 
 SparseCompressedBase ()
 
- Protected Member Functions inherited from Eigen::SparseMatrixBase< Derived >
template<typename OtherDerived >
Derived & assign (const OtherDerived &other)
 
template<typename OtherDerived >
void assignGeneric (const OtherDerived &other)
 

Protected Attributes

IndexPointer m_innerIndices
 
IndexPointer m_innerNonZeros
 
Index m_innerSize
 
IndexPointer m_outerIndex
 
Index m_outerSize
 
ScalarPointer m_values
 
Array< StorageIndex, 2, 1 > m_zero_nnz
 
- Protected Attributes inherited from Eigen::SparseMatrixBase< Derived >
bool m_isRValue
 

Additional Inherited Members

- Static Protected Member Functions inherited from Eigen::SparseMatrixBase< Derived >
static StorageIndex convert_index (const Index idx)
 

Detailed Description

template<typename Derived>
class Eigen::SparseMapBase< Derived, ReadOnlyAccessors >

Common base class for Map and Ref instance of sparse matrix and vector.

class SparseMapBase

Definition at line 52 of file SparseMap.h.

Member Typedef Documentation

◆ Base

template<typename Derived >
typedef SparseCompressedBase<Derived> Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::Base

Definition at line 56 of file SparseMap.h.

◆ IndexPointer

template<typename Derived >
typedef std::conditional_t< bool(internal::is_lvalue<Derived>::value), StorageIndex *, const StorageIndex *> Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::IndexPointer
protected

Definition at line 68 of file SparseMap.h.

◆ Scalar

template<typename Derived >
typedef Base::Scalar Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::Scalar

Definition at line 57 of file SparseMap.h.

◆ ScalarPointer

template<typename Derived >
typedef std::conditional_t< bool(internal::is_lvalue<Derived>::value), Scalar *, const Scalar *> Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::ScalarPointer
protected

Definition at line 65 of file SparseMap.h.

◆ StorageIndex

template<typename Derived >
typedef Base::StorageIndex Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::StorageIndex

Definition at line 58 of file SparseMap.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename Derived >
anonymous enum
Enumerator
IsRowMajor 

Definition at line 59 of file SparseMap.h.

Constructor & Destructor Documentation

◆ SparseMapBase() [1/3]

template<typename Derived >
Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::SparseMapBase ( Index  rows,
Index  cols,
Index  nnz,
IndexPointer  outerIndexPtr,
IndexPointer  innerIndexPtr,
ScalarPointer  valuePtr,
IndexPointer  innerNonZerosPtr = 0 
)
inline

Definition at line 126 of file SparseMap.h.

128  : m_outerSize(IsRowMajor?rows:cols), m_innerSize(IsRowMajor?cols:rows), m_zero_nnz(0,internal::convert_index<StorageIndex>(nnz)), m_outerIndex(outerIndexPtr),
130  {}
const StorageIndex * outerIndexPtr() const
Definition: SparseMap.h:101
const StorageIndex * innerIndexPtr() const
Definition: SparseMap.h:99

◆ SparseMapBase() [2/3]

template<typename Derived >
Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::SparseMapBase ( Index  size,
Index  nnz,
IndexPointer  innerIndexPtr,
ScalarPointer  valuePtr 
)
inline

Definition at line 133 of file SparseMap.h.

134  : m_outerSize(1), m_innerSize(size), m_zero_nnz(0,internal::convert_index<StorageIndex>(nnz)), m_outerIndex(m_zero_nnz.data()),
136  {}
const Scalar * data() const

◆ ~SparseMapBase()

template<typename Derived >
Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::~SparseMapBase ( )
inline

Empty destructor

Definition at line 139 of file SparseMap.h.

139 {}

◆ SparseMapBase() [3/3]

template<typename Derived >
Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::SparseMapBase ( )
inlineprotected

Definition at line 142 of file SparseMap.h.

142 {}

Member Function Documentation

◆ coeff()

template<typename Derived >
Scalar Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::coeff ( Index  row,
Index  col 
) const
inline

Returns
the value of the matrix at position i, j This function returns Scalar(0) if the element is an explicit zero

Definition at line 107 of file SparseMap.h.

108  {
109  const Index outer = IsRowMajor ? row : col;
110  const Index inner = IsRowMajor ? col : row;
111 
112  Index start = m_outerIndex[outer];
113  Index end = isCompressed() ? m_outerIndex[outer+1] : start + m_innerNonZeros[outer];
114  if (start==end)
115  return Scalar(0);
116  else if (end>0 && inner==m_innerIndices[end-1])
117  return m_values[end-1];
118  // ^^ optimization: let's first check if it is the last coefficient
119  // (very common in high level algorithms)
120 
121  const StorageIndex* r = std::lower_bound(&m_innerIndices[start],&m_innerIndices[end-1],inner);
122  const Index id = r-&m_innerIndices[0];
123  return ((*r==inner) && (id<end)) ? m_values[id] : Scalar(0);
124  }
RowXpr row(Index i)
This is the const version of row(). *‍/.
ColXpr col(Index i)
This is the const version of col().
static const lastp1_t end
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:41

◆ cols()

template<typename Derived >
Index Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::cols ( void  ) const
inline

Returns
the number of columns.
See also
rows()

Definition at line 83 of file SparseMap.h.

83 { return IsRowMajor ? m_innerSize : m_outerSize; }

◆ innerIndexPtr()

template<typename Derived >
const StorageIndex* Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::innerIndexPtr ( ) const
inline

Returns
a const pointer to the array of inner indices. This function is aimed at interoperability with other libraries.
See also
valuePtr(), outerIndexPtr()

Definition at line 99 of file SparseMap.h.

99 { return m_innerIndices; }

◆ innerNonZeroPtr()

template<typename Derived >
const StorageIndex* Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::innerNonZeroPtr ( ) const
inline

Returns
a const pointer to the array of the number of non zeros of the inner vectors. This function is aimed at interoperability with other libraries.
Warning
it returns the null pointer 0 in compressed mode

Definition at line 103 of file SparseMap.h.

103 { return m_innerNonZeros; }

◆ innerSize()

template<typename Derived >
Index Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::innerSize ( ) const
inline

Returns
the size of the inner dimension according to the storage order, i.e., the number of rows for a columns major matrix, and the number of cols otherwise

Definition at line 85 of file SparseMap.h.

85 { return m_innerSize; }

◆ isCompressed()

template<typename Derived >
bool Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::isCompressed ( ) const
inline

Returns
whether *this is in compressed form.

Definition at line 92 of file SparseMap.h.

92 { return m_innerNonZeros==0; }

◆ nonZeros()

template<typename Derived >
Index Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::nonZeros ( ) const
inline

Returns
the number of non zero coefficients

Definition at line 89 of file SparseMap.h.

89 { return m_zero_nnz[1]; }

◆ operator=() [1/4]

template<typename Derived >
Derived & Eigen::SparseMatrixBase< Derived >::operator=
inline

Definition at line 206 of file SparseAssign.h.

46 {
47  internal::call_assignment_no_alias(derived(), other.derived());
48  return derived();
49 }
EIGEN_CONSTEXPR void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)
Derived & derived()
Definition: EigenBase.h:48

◆ operator=() [2/4]

template<typename Derived >
template<typename OtherDerived >
Derived & Eigen::SparseMatrixBase< Derived >::operator= ( typename OtherDerived  )

Definition at line 57 of file SparseAssign.h.

20 {
21  internal::call_assignment_no_alias(derived(), other.derived());
22  return derived();
23 }

◆ operator=() [3/4]

template<typename Derived >
template<typename OtherDerived >
Derived & Eigen::SparseMatrixBase< Derived >::operator= ( typename OtherDerived  )

Definition at line 201 of file SparseAssign.h.

28 {
29  // TODO use the evaluator mechanism
30  other.evalTo(derived());
31  return derived();
32 }

◆ operator=() [4/4]

template<typename Derived >
template<typename OtherDerived >
Derived & Eigen::SparseMatrixBase< Derived >::operator= ( typename OtherDerived  )
inline

Definition at line 204 of file SparseAssign.h.

37 {
38  // by default sparse evaluation do not alias, so we can safely bypass the generic call_assignment routine
39  internal::Assignment<Derived,OtherDerived,internal::assign_op<Scalar,typename OtherDerived::Scalar> >
40  ::run(derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
41  return derived();
42 }

◆ outerIndexPtr()

template<typename Derived >
const StorageIndex* Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::outerIndexPtr ( ) const
inline

Returns
a const pointer to the array of the starting positions of the inner vectors. This function is aimed at interoperability with other libraries.
See also
valuePtr(), innerIndexPtr()

Definition at line 101 of file SparseMap.h.

101 { return m_outerIndex; }

◆ outerSize()

template<typename Derived >
Index Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::outerSize ( ) const
inline

Returns
the size of the storage major dimension, i.e., the number of columns for a columns major matrix, and the number of rows otherwise

Definition at line 87 of file SparseMap.h.

87 { return m_outerSize; }

◆ rows()

template<typename Derived >
Index Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::rows ( void  ) const
inline

Returns
the number of rows.
See also
cols()

Definition at line 81 of file SparseMap.h.

81 { return IsRowMajor ? m_outerSize : m_innerSize; }

◆ valuePtr()

template<typename Derived >
const Scalar* Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::valuePtr ( ) const
inline

Returns
a const pointer to the array of values. This function is aimed at interoperability with other libraries.
See also
innerIndexPtr(), outerIndexPtr()

Definition at line 97 of file SparseMap.h.

97 { return m_values; }

Member Data Documentation

◆ m_innerIndices

template<typename Derived >
IndexPointer Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::m_innerIndices
protected

Definition at line 74 of file SparseMap.h.

◆ m_innerNonZeros

template<typename Derived >
IndexPointer Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::m_innerNonZeros
protected

Definition at line 76 of file SparseMap.h.

◆ m_innerSize

template<typename Derived >
Index Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::m_innerSize
protected

Definition at line 71 of file SparseMap.h.

◆ m_outerIndex

template<typename Derived >
IndexPointer Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::m_outerIndex
protected

Definition at line 73 of file SparseMap.h.

◆ m_outerSize

template<typename Derived >
Index Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::m_outerSize
protected

Definition at line 70 of file SparseMap.h.

◆ m_values

template<typename Derived >
ScalarPointer Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::m_values
protected

Definition at line 75 of file SparseMap.h.

◆ m_zero_nnz

template<typename Derived >
Array<StorageIndex,2,1> Eigen::SparseMapBase< Derived, ReadOnlyAccessors >::m_zero_nnz
protected

Definition at line 72 of file SparseMap.h.


The documentation for this class was generated from the following file: