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

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

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

Public Types

enum  { IsRowMajor }
 
typedef SparseMapBase< Derived, ReadOnlyAccessorsBase
 
typedef Base::Scalar Scalar
 
typedef Base::StorageIndex StorageIndex
 
- Public Types inherited from Eigen::SparseMapBase< Derived, ReadOnlyAccessors >
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

ScalarcoeffRef (Index row, Index col)
 
StorageIndexinnerIndexPtr ()
 
StorageIndexinnerNonZeroPtr ()
 
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 ()
 
 SparseMapBase (Index rows, Index cols, Index nnz, StorageIndex *outerIndexPtr, StorageIndex *innerIndexPtr, Scalar *valuePtr, StorageIndex *innerNonZerosPtr=0)
 
 SparseMapBase (Index size, Index nnz, StorageIndex *innerIndexPtr, Scalar *valuePtr)
 
ScalarvaluePtr ()
 
 ~SparseMapBase ()
 
- Public Member Functions inherited from Eigen::SparseMapBase< Derived, ReadOnlyAccessors >
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 Member Functions

 SparseMapBase ()
 
- Protected Member Functions inherited from Eigen::SparseMapBase< Derived, ReadOnlyAccessors >
 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)
 

Private Types

typedef MapBase< Derived, ReadOnlyAccessorsReadOnlyMapBase
 

Additional Inherited Members

- Protected Types inherited from Eigen::SparseMapBase< Derived, ReadOnlyAccessors >
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
 
- Static Protected Member Functions inherited from Eigen::SparseMatrixBase< Derived >
static StorageIndex convert_index (const Index idx)
 
- Protected Attributes inherited from Eigen::SparseMapBase< Derived, ReadOnlyAccessors >
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
 

Detailed Description

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

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

class SparseMapBase

Definition at line 150 of file SparseMap.h.

Member Typedef Documentation

◆ Base

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

Definition at line 156 of file SparseMap.h.

◆ ReadOnlyMapBase

template<typename Derived >
typedef MapBase<Derived, ReadOnlyAccessors> Eigen::SparseMapBase< Derived, WriteAccessors >::ReadOnlyMapBase
private

Definition at line 153 of file SparseMap.h.

◆ Scalar

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

Definition at line 157 of file SparseMap.h.

◆ StorageIndex

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

Definition at line 158 of file SparseMap.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename Derived >
anonymous enum
Enumerator
IsRowMajor 

Definition at line 159 of file SparseMap.h.

159 { IsRowMajor = Base::IsRowMajor };

Constructor & Destructor Documentation

◆ SparseMapBase() [1/3]

template<typename Derived >
Eigen::SparseMapBase< Derived, WriteAccessors >::SparseMapBase ( Index  rows,
Index  cols,
Index  nnz,
StorageIndex outerIndexPtr,
StorageIndex innerIndexPtr,
Scalar valuePtr,
StorageIndex innerNonZerosPtr = 0 
)
inline

◆ SparseMapBase() [2/3]

template<typename Derived >
Eigen::SparseMapBase< Derived, WriteAccessors >::SparseMapBase ( Index  size,
Index  nnz,
StorageIndex innerIndexPtr,
Scalar valuePtr 
)
inline

Definition at line 203 of file SparseMap.h.

204  : Base(size, nnz, innerIndexPtr, valuePtr)
205  {}

◆ ~SparseMapBase()

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

Empty destructor

Definition at line 208 of file SparseMap.h.

208 {}

◆ SparseMapBase() [3/3]

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

Definition at line 211 of file SparseMap.h.

211 {}

Member Function Documentation

◆ coeffRef()

template<typename Derived >
Scalar& Eigen::SparseMapBase< Derived, WriteAccessors >::coeffRef ( Index  row,
Index  col 
)
inline

Returns
a non-const reference to the value of the matrix at position i, j

If the element does not exist then it is inserted via the insert(Index,Index) function which itself turns the matrix into a non compressed form if that was not the case.

This is a O(log(nnz_j)) operation (binary search) plus the cost of insert(Index,Index) function if the element does not already exist.

Definition at line 182 of file SparseMap.h.

183  {
184  const Index outer = IsRowMajor ? row : col;
185  const Index inner = IsRowMajor ? col : row;
186 
187  Index start = Base::m_outerIndex[outer];
188  Index end = Base::isCompressed() ? Base::m_outerIndex[outer+1] : start + Base::m_innerNonZeros[outer];
189  eigen_assert(end>=start && "you probably called coeffRef on a non finalized matrix");
190  eigen_assert(end>start && "coeffRef cannot be called on a zero coefficient");
191  StorageIndex* r = std::lower_bound(&Base::m_innerIndices[start],&Base::m_innerIndices[end],inner);
192  const Index id = r - &Base::m_innerIndices[0];
193  eigen_assert((*r==inner) && (id<end) && "coeffRef cannot be called on a zero coefficient");
194  return const_cast<Scalar*>(Base::m_values)[id];
195  }
RowXpr row(Index i)
This is the const version of row(). *‍/.
ColXpr col(Index i)
This is the const version of col().
#define eigen_assert(x)
Definition: Macros.h:902
static const lastp1_t end
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:41

◆ innerIndexPtr()

template<typename Derived >
StorageIndex* Eigen::SparseMapBase< Derived, WriteAccessors >::innerIndexPtr ( )
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 174 of file SparseMap.h.

174 { return Base::m_innerIndices; }

◆ innerNonZeroPtr()

template<typename Derived >
StorageIndex* Eigen::SparseMapBase< Derived, WriteAccessors >::innerNonZeroPtr ( )
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 178 of file SparseMap.h.

178 { return Base::m_innerNonZeros; }

◆ 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 >
StorageIndex* Eigen::SparseMapBase< Derived, WriteAccessors >::outerIndexPtr ( )
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 176 of file SparseMap.h.

176 { return Base::m_outerIndex; }

◆ valuePtr()

template<typename Derived >
Scalar* Eigen::SparseMapBase< Derived, WriteAccessors >::valuePtr ( )
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 172 of file SparseMap.h.

172 { return Base::m_values; }

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