SparseMatrix Class Reference
Last update: 16.07.2025encapsulates sparse matrix classes and algorithms More...
Public Types | |
| typedef Eigen::SparseMatrix< TScalar > | Base |
| the ancestor class type | |
| typedef Base::Index | TEigenIndex |
| index type for Eigen matrices | |
| typedef number | TScalar |
| the data type of the coefficients (real number) | |
| typedef number | TUnsignedIndex |
| an unsigned index type | |
Public Member Functions | |
| SparseMatrix | __neg__ () const |
| char * | __str__ () |
| transforms this objects into a string, required by SWIG More... | |
| Assign (SparseMatrix other, bool keep_data=true) | |
| assigns a new matrix to this object More... | |
| SparseMatrix | Col (int col) const |
| extracts a column of this matrix (as a copy, not a reference!) More... | |
| TUnsignedIndex | Cols () |
| TUnsignedIndex | InnerSize () |
| TUnsignedIndex | NonZeros () |
| Matrix | operator* (Matrix x) const |
| overrides the sparsematrix-densematrix product. More... | |
| Matrix | operator* (MatrixBlock x) const |
| overrides the sparsematrix-densematrix product. More... | |
| SparseMatrix | operator* (SparseMatrix x) const |
| overrides the sparsematrix-densematrix product. More... | |
| SparseMatrix | operator* (SymSparseMatrix x) const |
| overrides the sparsematrix-densematrix product. More... | |
| SparseMatrix | operator* (number x) const |
| overrides the sparsematrix-scalar product. More... | |
| SparseMatrix | operator+ (SparseMatrix x) const |
| overrides the sparsematrix-sparsematrix sum. More... | |
| SparseMatrix | operator- (SparseMatrix x) const |
| overrides the sparsematrix-sparsematrix subtraction. More... | |
| SparseMatrix | operator/ (number x) const |
| overrides the sparsematrix-scalar division. More... | |
| TUnsignedIndex | OuterSize () |
| Print (string format="%g ", TUnsignedIndex rows=20, TUnsignedIndex cols=20) const | |
| Prune (TScalar reference) | |
| sets all elements with absolute value <= reference to zero and removes from storage More... | |
| Prune (TScalar reference, TScalar epsilon) | |
| sets all elements with absolute value <= reference*epsilon to zero and removes from storage More... | |
| TUnsignedIndex | Rows () |
| SetZero () | |
| sets the object to zero (clears it) | |
| SparseMatrix (SparseMatrix ar, bool keep_data=true) | |
| destructor More... | |
| SparseMatrix (SparseMatrix ar) | |
| copy constructor More... | |
| SparseMatrix (SymSparseMatrix ar, bool keep_data=true) | |
| copy constructor More... | |
| SparseMatrix (SymSparseMatrix ar) | |
| copy constructor More... | |
| Swap (SparseMatrix other) | |
| swaps the contents of this object More... | |
| SparseMatrix | Transpose () |
Detailed Description
encapsulates sparse matrix classes and algorithms
The default sparse matrix class.
A class that represents storage for sparse linalg objects.
The storage scheme is column_major (FORTRAN). It basically provides basic features of the Eigen::SparseMatrix class, i.e. basic operators and assembly methods.
The storage scheme is described in the Eigen doc in detail. It should be noted that one can view any column_major sparse matrix as a set of 'ncols' sparse vectors. The sparse vectors are labeled by the index i ("outer iterator"), the access of the elements within these vectors is labeled by the Eigen::InnerIterator object it ("inner iterator"/ "inner loop").
Constructor & Destructor Documentation
◆ SparseMatrix() [1/4]
| SparseMatrix | ( | SparseMatrix | ar, |
| bool | keep_data = true |
||
| ) |
destructor
copy constructor
- Parameters
-
ar the source matrix keep_data if true, the data is copied. if false, the source matrix is empty on output
◆ SparseMatrix() [2/4]
| SparseMatrix | ( | SparseMatrix | ar | ) |
copy constructor
- Parameters
-
ar the source matrix
◆ SparseMatrix() [3/4]
| SparseMatrix | ( | SymSparseMatrix | ar, |
| bool | keep_data = true |
||
| ) |
copy constructor
- Parameters
-
ar the source matrix keep_data if true, the data is copied. if false, the source matrix is empty on output
◆ SparseMatrix() [4/4]
| SparseMatrix | ( | SymSparseMatrix | ar | ) |
copy constructor
- Parameters
-
ar the source matrix
Member Function Documentation
◆ __neg__()
| SparseMatrix __neg__ | ( | ) | const |
- Returns
- unary minus of this matrix (return B = -A)
◆ __str__()
| char* __str__ | ( | ) |
transforms this objects into a string, required by SWIG
- Returns
- a 0-terminated string.
◆ Assign()
| Assign | ( | SparseMatrix | other, |
| bool | keep_data = true |
||
| ) |
assigns a new matrix to this object
- Parameters
-
other the other sparse matrix keep_data if false, then the other matrix will be cleared
◆ Col()
| SparseMatrix Col | ( | int | col | ) | const |
extracts a column of this matrix (as a copy, not a reference!)
- Parameters
-
col the column index
- Returns
- the column as sparse matrix
◆ Cols()
| TUnsignedIndex Cols | ( | ) |
- Returns
- the number of columns
◆ InnerSize()
| TUnsignedIndex InnerSize | ( | ) |
- Returns
- the number of inner elements
◆ NonZeros()
| TUnsignedIndex NonZeros | ( | ) |
- Returns
- the number of nonzeros
◆ operator*() [1/5]
overrides the sparsematrix-densematrix product.
- Parameters
-
x the other matrix
- Returns
- (*this)*x
◆ operator*() [2/5]
| Matrix operator* | ( | MatrixBlock | x | ) | const |
overrides the sparsematrix-densematrix product.
- Parameters
-
x the other matrix
- Returns
- (*this)*x
◆ operator*() [3/5]
| SparseMatrix operator* | ( | SparseMatrix | x | ) | const |
overrides the sparsematrix-densematrix product.
- Parameters
-
x the other matrix
- Returns
- (*this)*x
◆ operator*() [4/5]
| SparseMatrix operator* | ( | SymSparseMatrix | x | ) | const |
overrides the sparsematrix-densematrix product.
- Parameters
-
x the other matrix
- Returns
- (*this)*x
◆ operator*() [5/5]
| SparseMatrix operator* | ( | number | x | ) | const |
overrides the sparsematrix-scalar product.
- Parameters
-
x the other matrix
- Returns
- (*this)*x
◆ operator+()
| SparseMatrix operator+ | ( | SparseMatrix | x | ) | const |
overrides the sparsematrix-sparsematrix sum.
- Parameters
-
x the other matrix
- Returns
- (*this)+x
◆ operator-()
| SparseMatrix operator- | ( | SparseMatrix | x | ) | const |
overrides the sparsematrix-sparsematrix subtraction.
- Parameters
-
x the other matrix
- Returns
- (*this)-x
◆ operator/()
| SparseMatrix operator/ | ( | number | x | ) | const |
overrides the sparsematrix-scalar division.
- Parameters
-
x the other matrix
- Returns
- (*this)/x
◆ OuterSize()
| TUnsignedIndex OuterSize | ( | ) |
- Returns
- the number of sparse column vectors
◆ Print()
| ( | string | format = "%g ", |
|
| TUnsignedIndex | rows = 20, |
||
| TUnsignedIndex | cols = 20 |
||
| ) | const |
prints the sparse matrix up to the given rows and columns (internally a temporary dense matrix will be created)
- Parameters
-
format the format of a single element, see printf for details rows only print the first rows rows cols only print the first cols columns
◆ Prune() [1/2]
| Prune | ( | TScalar | reference | ) |
sets all elements with absolute value <= reference to zero and removes from storage
- Parameters
-
reference the reference value
◆ Prune() [2/2]
sets all elements with absolute value <= reference*epsilon to zero and removes from storage
- Parameters
-
reference the reference value epsilon the tolerance epsilon
◆ Rows()
| TUnsignedIndex Rows | ( | ) |
- Returns
- the number of rows
◆ Swap()
| Swap | ( | SparseMatrix | other | ) |
swaps the contents of this object
- Parameters
-
other the other sparse matrix
◆ Transpose()
| SparseMatrix Transpose | ( | ) |
- Returns
- the transpose