template<typename Derived>
Eigen::SparseCompressedBase class

Common base class for sparse [compressed]-{row|column}-storage format.

This class defines the common interface for all derived classes implementing the compressed sparse storage format, such as:

Base classes

template<typename Derived>
class SparseMatrixBase
Base class of any sparse matrices or sparse expressions.

Derived classes

template<typename Derived>
class SparseMapBase<Derived, ReadOnlyAccessors>
Common base class for Map and Ref instance of sparse matrix and vector.
template<typename _Scalar, int _Options, typename _StorageIndex>
class SparseMatrix
A versatible sparse matrix representation.
template<typename _Scalar, int _Options, typename _StorageIndex>
class SparseMatrix
A versatible sparse matrix representation.
template<typename _Scalar, int _Options, typename _StorageIndex>
class SparseMatrix
A versatible sparse matrix representation.
template<typename _Scalar, int _Options, typename _StorageIndex>
class SparseMatrix
A versatible sparse matrix representation.

Constructors, destructors, conversion operators

SparseCompressedBase() protected

Public functions

auto coeffs() const -> const Map<const Array<Scalar, Dynamic, 1>>
auto coeffs() -> Map<Array<Scalar, Dynamic, 1>>
auto innerIndexPtr() const -> const StorageIndex*
auto innerIndexPtr() -> StorageIndex*
auto innerNonZeroPtr() const -> const StorageIndex*
auto innerNonZeroPtr() -> StorageIndex*
auto isCompressed() const -> bool
auto nonZeros() const -> Index
auto outerIndexPtr() const -> const StorageIndex*
auto outerIndexPtr() -> StorageIndex*
auto valuePtr() const -> const Scalar*
auto valuePtr() -> Scalar*

Function documentation

template<typename Derived>
Eigen::SparseCompressedBase<Derived>::SparseCompressedBase() protected

Default constructor. Do nothing.

template<typename Derived>
const Map<const Array<Scalar, Dynamic, 1>> Eigen::SparseCompressedBase<Derived>::coeffs() const

Returns a read-only view of the stored coefficients as a 1D array expression.

template<typename Derived>
Map<Array<Scalar, Dynamic, 1>> Eigen::SparseCompressedBase<Derived>::coeffs()

Returns a read-write view of the stored coefficients as a 1D array expression

Here is an example:

SparseMatrix<double> A(3,3);
A.insert(1,2) = 0;
A.insert(0,1) = 1;
A.insert(2,0) = 2;
A.makeCompressed();
cout << "The matrix A is:" << endl << MatrixXd(A) << endl;
cout << "it has " << A.nonZeros() << " stored non zero coefficients that are: " << A.coeffs().transpose() << endl;
A.coeffs() += 10;
cout << "After adding 10 to every stored non zero coefficient, the matrix A is:" << endl << MatrixXd(A) << endl;

and the output is:

The matrix A is:
0 1 0
0 0 0
2 0 0
it has 3 stored non zero coefficients that are: 2 1 0
After adding 10 to every stored non zero coefficient, the matrix A is:
 0 11  0
 0  0 10
12  0  0

template<typename Derived>
const StorageIndex* Eigen::SparseCompressedBase<Derived>::innerIndexPtr() const

Returns a const pointer to the array of inner indices. This function is aimed at interoperability with other libraries.

template<typename Derived>
StorageIndex* Eigen::SparseCompressedBase<Derived>::innerIndexPtr()

Returns a non-const pointer to the array of inner indices. This function is aimed at interoperability with other libraries.

template<typename Derived>
const StorageIndex* Eigen::SparseCompressedBase<Derived>::innerNonZeroPtr() const

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.

template<typename Derived>
StorageIndex* Eigen::SparseCompressedBase<Derived>::innerNonZeroPtr()

Returns a non-const pointer to the array of the number of non zeros of the inner vectors. This function is aimed at interoperability with other libraries.

template<typename Derived>
bool Eigen::SparseCompressedBase<Derived>::isCompressed() const

Returns whether *this is in compressed form.

template<typename Derived>
Index Eigen::SparseCompressedBase<Derived>::nonZeros() const

Returns the number of non zero coefficients

template<typename Derived>
const StorageIndex* Eigen::SparseCompressedBase<Derived>::outerIndexPtr() const

Returns a const pointer to the array of the starting positions of the inner vectors. This function is aimed at interoperability with other libraries.

template<typename Derived>
StorageIndex* Eigen::SparseCompressedBase<Derived>::outerIndexPtr()

Returns a non-const pointer to the array of the starting positions of the inner vectors. This function is aimed at interoperability with other libraries.

template<typename Derived>
const Scalar* Eigen::SparseCompressedBase<Derived>::valuePtr() const

Returns a const pointer to the array of values. This function is aimed at interoperability with other libraries.

template<typename Derived>
Scalar* Eigen::SparseCompressedBase<Derived>::valuePtr()

Returns a non-const pointer to the array of values. This function is aimed at interoperability with other libraries.