![]() |
MechSys
1.0
Computing library for simulations in continuum and discrete mechanics
|
#include <sparse_matrix.h>
Public Member Functions | |
Matrix () | |
~Matrix () | |
Matrix (Triplet< Value_T, Index_T > const &T) | |
void | Set (Triplet< Value_T, Index_T > const &T) |
(Re)set this matrix for a given triplet (with duplicates) | |
void | Set (Index_T nRows, Index_T nCols, Index_T nZ, String const &strAx, String const &strAi, String const &strAp) |
nRows: Number of rows, nCols: Number of columns, nZ: Number of non-zero values, Ax: Non-zero values, Ai: Row indexes, Ap: Pointers to row indexes | |
Index_T | Rows () const |
Number of rows. | |
Index_T | Cols () const |
Number of columns. | |
Index_T | nZ () const |
Number of non-zero values. | |
Value_T | Ax (Index_T iNz) const |
Returns non-zero values. | |
Index_T | Ai (Index_T iNz) const |
Returns the row indexes. | |
Index_T | Ap (Index_T iCol) const |
Returns the pointers to row indexes. | |
Value_T * | GetAxPtr () |
Access values (write) | |
Index_T * | GetAiPtr () |
Access row indexes (write) | |
Index_T * | GetApPtr () |
Access pointers to row indexes (write) | |
Value_T const * | GetAxPtr () const |
Access values (read) | |
Index_T const * | GetAiPtr () const |
Access row indexes (read) | |
Index_T const * | GetApPtr () const |
Access pointers to row indexes (read) | |
void | GetDense (Mat_t &D) const |
Convert this sparse structure to a Dense matrix. | |
void | SetNS (Util::NumStream &NS) |
Set the NumStream, a structure to aid format output of numbers. | |
Util::NumStream const & | NS () const |
Return the NumStream, a structure to aid format output of numbers. | |
void | WriteSMAT (char const *FileKey, double Tol=1.0e-14) const |
Write .smat file for vismatrix. |
Sparse matrix in compressed-column (CC) format (sorted).
Example:
columns: 0 1 2 3 4 | | | | | V V V V V _ _ rows: | 2 3 0 0 0 | <-- i=0 | 3 0 4 0 6 | <-- i=1 A = | 0 -1 -3 2 0 | <-- i=2 | 0 0 1 0 0 | <-- i=3 |_ 0 4 2 0 1 _| <-- i=4 non-zero: Ax: Ax: Ax: Ax: Ax: 2 3 4 2 6 3 -1 -3 1 4 1 2 => Ax = 2 3 3 -1 4 4 -3 1 2 2 6 1 Ai: Ai: Ai: Ai: Ai: | | | | | 0 0 1 2 1 | | | | | 1 2 2 4 | | | | | 4 3 | | | | | 4 => Ai = 0 1 0 2 4 1 2 3 4 2 1 4 Ap: Ap: Ap: Ap: Ap: | | | | | 0 2 5 9 10 12 => Ap = 0 2 5 9 10 12 n = 5 (nrows==ncols) nz = 12 (number of non-zero values) Ax.size == nz == 12 : Non-zero values Ai.size == nz == 12 : Row indexes of the non-zero values Ap.size == ncols+1 == 6 : Pointers (indexes) to the row indexes of non-zero values inside Ai
Example:
Sparse::Matrix< Value_T, Index_T >::Matrix | ( | ) | [inline] |
Constructor (must call Set() method later).
Sparse::Matrix< Value_T, Index_T >::~Matrix | ( | ) | [inline] |
Destructor.
Sparse::Matrix< Value_T, Index_T >::Matrix | ( | Triplet< Value_T, Index_T > const & | T | ) | [inline] |
Alternative constructor. Convert triplet (with duplicates) to compressed-column format
Index_T Sparse::Matrix< Value_T, Index_T >::Ai | ( | Index_T | iNz | ) | const [inline] |
Returns the row indexes.
Index_T Sparse::Matrix< Value_T, Index_T >::Ap | ( | Index_T | iCol | ) | const [inline] |
Returns the pointers to row indexes.
Value_T Sparse::Matrix< Value_T, Index_T >::Ax | ( | Index_T | iNz | ) | const [inline] |
Returns non-zero values.
Index_T Sparse::Matrix< Value_T, Index_T >::Cols | ( | ) | const [inline] |
Number of columns.
Index_T * Sparse::Matrix< Value_T, Index_T >::GetAiPtr | ( | ) | [inline] |
Access row indexes (write)
Index_T const * Sparse::Matrix< Value_T, Index_T >::GetAiPtr | ( | ) | const [inline] |
Access row indexes (read)
Index_T * Sparse::Matrix< Value_T, Index_T >::GetApPtr | ( | ) | [inline] |
Access pointers to row indexes (write)
Index_T const * Sparse::Matrix< Value_T, Index_T >::GetApPtr | ( | ) | const [inline] |
Access pointers to row indexes (read)
Value_T * Sparse::Matrix< Value_T, Index_T >::GetAxPtr | ( | ) | [inline] |
Access values (write)
Value_T const * Sparse::Matrix< Value_T, Index_T >::GetAxPtr | ( | ) | const [inline] |
Access values (read)
void Sparse::Matrix< Value_T, Index_T >::GetDense | ( | Mat_t & | D | ) | const [inline] |
Convert this sparse structure to a Dense matrix.
Util::NumStream const& Sparse::Matrix< Value_T, Index_T >::NS | ( | ) | const [inline] |
Return the NumStream, a structure to aid format output of numbers.
Index_T Sparse::Matrix< Value_T, Index_T >::nZ | ( | ) | const [inline] |
Number of non-zero values.
Index_T Sparse::Matrix< Value_T, Index_T >::Rows | ( | ) | const [inline] |
Number of rows.
void Sparse::Matrix< Value_T, Index_T >::Set | ( | Triplet< Value_T, Index_T > const & | T | ) | [inline] |
(Re)set this matrix for a given triplet (with duplicates)
void Sparse::Matrix< Value_T, Index_T >::Set | ( | Index_T | nRows, |
Index_T | nCols, | ||
Index_T | nZ, | ||
String const & | strAx, | ||
String const & | strAi, | ||
String const & | strAp | ||
) | [inline] |
nRows: Number of rows, nCols: Number of columns, nZ: Number of non-zero values, Ax: Non-zero values, Ai: Row indexes, Ap: Pointers to row indexes
void Sparse::Matrix< Value_T, Index_T >::SetNS | ( | Util::NumStream & | NS | ) | [inline] |
Set the NumStream, a structure to aid format output of numbers.
void Sparse::Matrix< Value_T, Index_T >::WriteSMAT | ( | char const * | FileKey, |
double | Tol = 1.0e-14 |
||
) | const [inline] |
Write .smat file for vismatrix.