#include <CompressedRowSparseMatrixGeneric.h>

Classes | |
| struct | IndexedBlock |
| class | Range |
Public Attributes | |
| Index | nBlockRow |
| Size. More... | |
| Index | nBlockCol |
| Mathematical size of the matrix, in blocks. More... | |
| VecIndex | rowIndex |
| Compressed sparse data structure. More... | |
| VecIndex | rowBegin |
| column indices of non-empty blocks in each row. The column indices of the non-empty block within the i-th non-empty row are all the colsIndex[j], j in [rowBegin[i],rowBegin[i+1]) More... | |
| VecIndex | colsIndex |
| column indices of all the non-empty blocks, sorted by increasing row index and column index More... | |
| VecBlock | colsValue |
| values of the non-empty blocks, in the same order as in colsIndex More... | |
| VecFlag | touchedBlock |
| boolean vector, i-th value is true if block has been touched since last compression. More... | |
| VecIndexedBlock | btemp |
| Additional storage to make block insertion more efficient. More... | |
| bool | skipCompressZero |
| VecIndex | oldRowIndex |
| Temporary vectors used during compression. More... | |
| VecIndex | oldRowBegin |
| VecIndex | oldColsIndex |
| VecBlock | oldColsValue |
Static Public Attributes | |
| static constexpr sofa::Index | NL = traits::NL |
| Number of rows of a block. More... | |
| static constexpr sofa::Index | NC = traits::NC |
| Number of columns of a block. More... | |
| static constexpr Index | s_invalidIndex = std::is_signed_v<Index> ? std::numeric_limits<Index>::lowest() : std::numeric_limits<Index>::max() |
Static Public Attributes inherited from sofa::linearalgebra::CRSDefaultPolicy | |
| static constexpr bool | IsAlwaysSquare = false |
| Set to true if this matrix is always square (must be true for symmetric) More... | |
| static constexpr bool | IsAlwaysSymmetric = false |
| Set to true if this matrix is always symmetric (IsAlwaysSquare should be true) More... | |
| static constexpr bool | AutoSize = false |
| Set to true if the size of the matrix should be automatically increased when new blocks are added. More... | |
| static constexpr bool | AutoCompress = true |
| Set to true if the matrix should be automatically compressed (easier to use, but might cause issues in multithreading) More... | |
| static constexpr bool | CompressZeros = true |
| Set to true if the blocks that are all zeros should be removed from the matrix when compressing (expensive) More... | |
| static constexpr bool | ClearByZeros = true |
| Set to true if clear methods will put all concerned value to zero instead of clearing vectors (CompressZeros should be true) More... | |
| static constexpr bool | OrderedInsertion = false |
| Set to true if insertion in matrix are in most case at last line index or last col index. More... | |
| static constexpr bool | StoreLowerTriangularBlock = true |
| Set to false to disable storage of blocks on the lower triangular part (IsAlwaysSymmetric must be true) More... | |
| static constexpr int | matrixType = 0 |
| Do not change this value, has to be overrided for all derivated class. More... | |
Public Member Functions | |
| CompressedRowSparseMatrixGeneric () | |
| CompressedRowSparseMatrixGeneric (Index nbBlockRow, Index nbBlockCol) | |
| virtual | ~CompressedRowSparseMatrixGeneric ()=default |
| Index | rowBSize () const |
| Index | colBSize () const |
| const VecIndex & | getRowIndex () const |
| const VecIndex & | getRowBegin () const |
| Range | getRowRange (Index id) const |
| Returns the range of indices from the column indices corresponding to the id-th row. More... | |
| const VecIndex & | getColsIndex () const |
| const VecBlock & | getColsValue () const |
| virtual void | resizeBlock (Index nbBRow, Index nbBCol) |
| void | compress () |
| void | swap (Matrix &m) |
| void | fullRows () |
| Make sure all rows have an entry even if they are empty. More... | |
| void | shiftIndices (Index base) |
| const Block & | block (Index i, Index j) const |
| Get block method. More... | |
| Block * | wblock (Index i, Index j, bool create=false) |
| Write block method. More... | |
| Block * | wblock (Index i, Index j, Index &rowId, Index &colId, bool create=false) |
| Write block method when rowId and colId are known, this is an optimized wblock specification. More... | |
| const Block & | getBlock (Index i, Index j) const |
| const BlockTranspose | getSymBlock (Index i, Index j) const |
| void | setBlock (Index i, Index j, const Block &v) |
| void | addBlock (Index i, Index j, const Block &v) |
| void | setBlock (Index i, Index j, Index &rowId, Index &colId, const Block &v) |
| void | addBlock (Index i, Index j, Index &rowId, Index &colId, const Block &v) |
| Block * | getWBlock (Index i, Index j, bool create=false) |
| void | clearRowBlock (Index i) |
| Clear row block method. Clear all col of this line. More... | |
| void | clearColBlock (Index j) |
| Clear col block method. Clear this col in all row of matrix. More... | |
| std::size_t | countEmptyBlocks () const |
| template<typename = typename std::enable_if< Policy::IsAlwaysSquare>> | |
| void | clearRowColBlock (Index i) |
| Clear both row i and column i in a square matrix. More... | |
| void | clear () |
| Completely clear the matrix. More... | |
| bool | check_matrix () |
| std::ostream & | write (std::ostream &os) const |
| std::istream & | read (std::istream &is) |
BlockMatrixWriter operators | |
| void | add (unsigned int bi, unsigned int bj, const Block &b) |
| void | add (unsigned int bi, unsigned int bj, int &rowId, int &colId, const Block &b) |
| void | addDBlock (unsigned int bi, unsigned int bj, const DBlock &b) |
| void | addDValue (unsigned int bi, unsigned int bj, const Real b) |
| void | addDValue (unsigned int bi, unsigned int bj, int &rowId, int &colId, const Real b) |
| template<typename = typename std::enable_if< Policy::IsAlwaysSquare>> | |
| void | addDiag (unsigned int bi, const Block &b) |
| template<typename = typename std::enable_if< Policy::IsAlwaysSquare>> | |
| void | addDiag (unsigned int bi, int &rowId, int &colId, const Block &b) |
| template<typename = typename std::enable_if< Policy::IsAlwaysSquare>> | |
| void | addDiagDBlock (unsigned int bi, const DBlock &b) |
| template<typename = typename std::enable_if< Policy::IsAlwaysSquare>> | |
| void | addDiagDValue (unsigned int bi, const Real b) |
| template<typename = typename std::enable_if< Policy::IsAlwaysSquare>> | |
| void | addDiagDValue (unsigned int bi, int &rowId, int &colId, const Real b) |
| template<typename = typename std::enable_if< Policy::IsAlwaysSymmetric>> | |
| void | addSym (unsigned int bi, unsigned int bj, const Block &b) |
| template<typename = typename std::enable_if< Policy::IsAlwaysSymmetric>> | |
| void | addSym (unsigned int bi, unsigned int bj, int &rowId, int &colId, int &rowIdT, int &colIdT, const Block &b) |
| template<typename = typename std::enable_if< Policy::IsAlwaysSymmetric>> | |
| void | addSymDBlock (unsigned int bi, unsigned int bj, const DBlock &b) |
| template<typename = typename std::enable_if< Policy::IsAlwaysSymmetric>> | |
| void | addSymDValue (unsigned int bi, unsigned int bj, const Real b) |
| template<typename = typename std::enable_if< Policy::IsAlwaysSymmetric>> | |
| void | addSymDValue (unsigned int bi, unsigned int bj, int &rowId, int &colId, int &rowIdT, int &colIdT, Real b) |
Static Public Member Functions | |
| static bool | sortedFind (const VecIndex &v, Range in, Index val, Index &result) |
| static bool | sortedFind (const VecIndex &v, Index val, Index &result) |
| static const char * | Name () |
| static bool | check_matrix (Index nzmax, Index m, Index n, Index *a_p, Index *a_i, Block *a_x) |
Protected Member Functions | |
| bool | registerNewCol (Index &colId, TBlock &bvalue) |
| Add a new col into matrix. More... | |
| std::pair< Index, Index > | registerBtempLine (typename VecIndexedBlock::const_iterator &itbtemp) |
| Add a complete new line from btemp into matrix. More... | |
| void | fullyCompressBtemp () |
| Clear matrix and just add btemp array. More... | |
| Block * | insertBtemp (const Index i, const Index j) |
| Method to easy insert new block into btemp. More... | |
| template<typename = typename std::enable_if< Policy::AutoSize>> | |
| Index | getMaxColIndex () |
| Method to easy have the max colIndex. Could only be used if AutoSize policy is activated. More... | |
| void | deleteRow (Index rowId) |
| Method to easy delete row given position in rowIndex. More... | |
| void | compressBtemp () |
| Clear matrix and compute new triplet's arrays by combining old ones and btemp(VecIndexedBlock) array. More... | |
| void | compressCSR () |
| template<typename TVec > | |
| void | writeVector (const TVec &vec, std::ostream &os) |
| template<typename TVec > | |
| void | readVector (TVec &vec, std::istream &in) |
Matrix operators | |
| static auto | blockMultTranspose (const TBlock &blockA, const TBlock &blockB) |
| template<typename TBlock2 , typename TPolicy2 > | |
| void | transposeFullRows (CompressedRowSparseMatrixGeneric< TBlock2, TPolicy2 > &res) const |
| Transpose the matrix into res, works only for 3 array variant ("full rows") matrices, ie which can be expressed using the rowBegin, colsIndex and colsValue arrays solely. More... | |
| template<typename RB , typename RP , typename MB , typename MP > | |
| void | mul (CompressedRowSparseMatrixGeneric< RB, RP > &res, const CompressedRowSparseMatrixGeneric< MB, MP > &m) const |
| template<typename RB , typename RP , typename MB , typename MP > | |
| void | mulTranspose (CompressedRowSparseMatrixGeneric< RB, RP > &res, const CompressedRowSparseMatrixGeneric< MB, MP > &m) const |
| VecIndexedBlock sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::btemp |
Additional storage to make block insertion more efficient.
unsorted blocks and their indices
| VecIndex sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::colsIndex |
column indices of all the non-empty blocks, sorted by increasing row index and column index
| VecBlock sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::colsValue |
values of the non-empty blocks, in the same order as in colsIndex
| Index sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::nBlockCol |
Mathematical size of the matrix, in blocks.
| Index sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::nBlockRow |
Size.
|
staticconstexpr |
Number of columns of a block.
|
staticconstexpr |
Number of rows of a block.
| VecIndex sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::oldColsIndex |
| VecBlock sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::oldColsValue |
| VecIndex sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::oldRowBegin |
| VecIndex sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::oldRowIndex |
Temporary vectors used during compression.
| VecIndex sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::rowBegin |
column indices of non-empty blocks in each row. The column indices of the non-empty block within the i-th non-empty row are all the colsIndex[j], j in [rowBegin[i],rowBegin[i+1])
| VecIndex sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::rowIndex |
Compressed sparse data structure.
indices of non-empty block rows
|
staticconstexpr |
| bool sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::skipCompressZero |
When true, only compressBtemp if needed This is to avoid compressCRS costly method when no change into matrix size occurs.
| VecFlag sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::touchedBlock |
boolean vector, i-th value is true if block has been touched since last compression.
|
inline |
|
inline |
|
virtualdefault |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get block method.
| Line | index i and column index j |
|
inlinestatic |
|
inline |
|
inlinestatic |
|
inline |
Completely clear the matrix.
|
inline |
Clear col block method. Clear this col in all row of matrix.
| j | : Col index considering size of matrix in block. |
|
inline |
Clear row block method. Clear all col of this line.
| i | : Line index considering size of matrix in block. |
|
inline |
Clear both row i and column i in a square matrix.
| i | : Row and Col index considering size of matrix in block. |
|
inline |
|
inline |
|
inlineprotected |
Clear matrix and compute new triplet's arrays by combining old ones and btemp(VecIndexedBlock) array.
|
inlineprotected |
|
inline |
|
inlineprotected |
Method to easy delete row given position in rowIndex.
| RowId | position on line in rowIndex |
|
inline |
Make sure all rows have an entry even if they are empty.
|
inlineprotected |
Clear matrix and just add btemp array.
|
inline |
|
inline |
|
inline |
|
inlineprotected |
Method to easy have the max colIndex. Could only be used if AutoSize policy is activated.
|
inline |
|
inline |
|
inline |
Returns the range of indices from the column indices corresponding to the id-th row.
|
inline |
|
inline |
|
inlineprotected |
Method to easy insert new block into btemp.
| Line | index i and column index j |
|
inline |
Compute res = this * m
|
inline |
Compute res = this.transpose * m
|
inlinestatic |
|
inline |
|
inlineprotected |
|
inlineprotected |
Add a complete new line from btemp into matrix.
| itbtemp | : Reference to actual status of iterator on btemp |
|
inlineprotected |
Add a new col into matrix.
| colId | : Index of column |
| bvalue | : Block value to add |
|
inlinevirtual |
|
inline |
|
inline |
|
inline |
|
inline |
Add the given base to all indices. Use 1 to convert do Fortran 1-based notation. Note that the matrix will no longer be valid from the point of view of C/C++ codes. You need to call again with -1 as base to undo it.
|
inlinestatic |
|
inlinestatic |
|
inline |
|
inline |
Transpose the matrix into res, works only for 3 array variant ("full rows") matrices, ie which can be expressed using the rowBegin, colsIndex and colsValue arrays solely.
|
inline |
Write block method.
| Line | index i and column index j |
| create,boolean | to decide if wblock could add new value into not existing line/column |
|
inline |
Write block method when rowId and colId are known, this is an optimized wblock specification.
| Line | index i and column index j |
| rowId | : Index of value i into rowIndex internal vector |
| colId | : Index of value j into colIndex internal vector |
| create,boolean | to decide if wblock could add new value into not existing line/column |
|
inline |
|
inlineprotected |