SOFA API  ca665544
Open source framework for multi-physics simuation
sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy > Class Template Reference

#include <CompressedRowSparseMatrixGeneric.h>

Inheritance diagram for sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >:

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 VecIndexgetRowIndex () const
 
const VecIndexgetRowBegin () const
 
Range getRowRange (Index id) const
 Returns the range of indices from the column indices corresponding to the id-th row. More...
 
const VecIndexgetColsIndex () const
 
const VecBlockgetColsValue () const
 
virtual void resizeBlock (Index nbBRow, Index nbBCol)
 
void resizeBloc (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 Blockblock (Index i, Index j) const
 Get block method. More...
 
const Blockbloc (Index i, Index j) const
 
Blockwblock (Index i, Index j, bool create=false)
 Write block method. More...
 
Blockwbloc (Index i, Index j, bool create=false)
 
Blockwblock (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 BlockgetBlock (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)
 
BlockgetWBlock (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 charName ()
 
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, IndexregisterBtempLine (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...
 
BlockinsertBtemp (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
 

Attribute details

◆ btemp

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
VecIndexedBlock sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::btemp

Additional storage to make block insertion more efficient.

unsorted blocks and their indices

◆ colsIndex

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
VecIndex sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::colsIndex

column indices of all the non-empty blocks, sorted by increasing row index and column index

◆ colsValue

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
VecBlock sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::colsValue

values of the non-empty blocks, in the same order as in colsIndex

◆ nBlockCol

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
Index sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::nBlockCol

Mathematical size of the matrix, in blocks.

◆ nBlockRow

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
Index sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::nBlockRow

Size.

◆ NC

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
constexpr sofa::Index sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::NC = traits::NC
staticconstexpr

Number of columns of a block.

◆ NL

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
constexpr sofa::Index sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::NL = traits::NL
staticconstexpr

Number of rows of a block.

◆ oldColsIndex

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
VecIndex sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::oldColsIndex

◆ oldColsValue

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
VecBlock sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::oldColsValue

◆ oldRowBegin

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
VecIndex sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::oldRowBegin

◆ oldRowIndex

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
VecIndex sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::oldRowIndex

Temporary vectors used during compression.

◆ rowBegin

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
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])

◆ rowIndex

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
VecIndex sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::rowIndex

Compressed sparse data structure.

indices of non-empty block rows

◆ s_invalidIndex

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
constexpr Index sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::s_invalidIndex = std::is_signed_v<Index> ? std::numeric_limits<Index>::lowest() : std::numeric_limits<Index>::max()
staticconstexpr

◆ skipCompressZero

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
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.

◆ touchedBlock

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
VecFlag sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::touchedBlock

boolean vector, i-th value is true if block has been touched since last compression.

Constructor details

◆ CompressedRowSparseMatrixGeneric() [1/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::CompressedRowSparseMatrixGeneric ( )
inline

◆ CompressedRowSparseMatrixGeneric() [2/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::CompressedRowSparseMatrixGeneric ( Index  nbBlockRow,
Index  nbBlockCol 
)
inline

◆ ~CompressedRowSparseMatrixGeneric()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
virtual sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::~CompressedRowSparseMatrixGeneric ( )
virtualdefault

Function details

◆ add() [1/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::add ( unsigned int  bi,
unsigned int  bj,
const Block b 
)
inline

◆ add() [2/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::add ( unsigned int  bi,
unsigned int  bj,
int &  rowId,
int &  colId,
const Block b 
)
inline

◆ addBlock() [1/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addBlock ( Index  i,
Index  j,
const Block v 
)
inline

◆ addBlock() [2/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addBlock ( Index  i,
Index  j,
Index rowId,
Index colId,
const Block v 
)
inline

◆ addDBlock()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addDBlock ( unsigned int  bi,
unsigned int  bj,
const DBlock b 
)
inline

◆ addDiag() [1/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename = typename std::enable_if< Policy::IsAlwaysSquare>>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addDiag ( unsigned int  bi,
const Block b 
)
inline

◆ addDiag() [2/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename = typename std::enable_if< Policy::IsAlwaysSquare>>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addDiag ( unsigned int  bi,
int &  rowId,
int &  colId,
const Block b 
)
inline

◆ addDiagDBlock()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename = typename std::enable_if< Policy::IsAlwaysSquare>>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addDiagDBlock ( unsigned int  bi,
const DBlock b 
)
inline

◆ addDiagDValue() [1/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename = typename std::enable_if< Policy::IsAlwaysSquare>>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addDiagDValue ( unsigned int  bi,
const Real  b 
)
inline

◆ addDiagDValue() [2/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename = typename std::enable_if< Policy::IsAlwaysSquare>>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addDiagDValue ( unsigned int  bi,
int &  rowId,
int &  colId,
const Real  b 
)
inline

◆ addDValue() [1/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addDValue ( unsigned int  bi,
unsigned int  bj,
const Real  b 
)
inline

◆ addDValue() [2/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addDValue ( unsigned int  bi,
unsigned int  bj,
int &  rowId,
int &  colId,
const Real  b 
)
inline

◆ addSym() [1/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename = typename std::enable_if< Policy::IsAlwaysSymmetric>>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addSym ( unsigned int  bi,
unsigned int  bj,
const Block b 
)
inline

◆ addSym() [2/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename = typename std::enable_if< Policy::IsAlwaysSymmetric>>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addSym ( unsigned int  bi,
unsigned int  bj,
int &  rowId,
int &  colId,
int &  rowIdT,
int &  colIdT,
const Block b 
)
inline

◆ addSymDBlock()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename = typename std::enable_if< Policy::IsAlwaysSymmetric>>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addSymDBlock ( unsigned int  bi,
unsigned int  bj,
const DBlock b 
)
inline

◆ addSymDValue() [1/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename = typename std::enable_if< Policy::IsAlwaysSymmetric>>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addSymDValue ( unsigned int  bi,
unsigned int  bj,
const Real  b 
)
inline

◆ addSymDValue() [2/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename = typename std::enable_if< Policy::IsAlwaysSymmetric>>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::addSymDValue ( unsigned int  bi,
unsigned int  bj,
int &  rowId,
int &  colId,
int &  rowIdT,
int &  colIdT,
Real  b 
)
inline

◆ bloc()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
const Block& sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::bloc ( Index  i,
Index  j 
) const
inline

◆ block()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
const Block& sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::block ( Index  i,
Index  j 
) const
inline

Get block method.

Parameters
Lineindex i and column index j
Returns
Block value if exist or empty Block if not

◆ blockMultTranspose()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
static auto sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::blockMultTranspose ( const TBlock &  blockA,
const TBlock &  blockB 
)
inlinestatic

◆ check_matrix() [1/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
bool sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::check_matrix ( )
inline

◆ check_matrix() [2/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
static bool sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::check_matrix ( Index  nzmax,
Index  m,
Index  n,
Index a_p,
Index a_i,
Block a_x 
)
inlinestatic

◆ clear()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::clear ( )
inline

Completely clear the matrix.

Warning
if ClearByZeros Policy is activated all value in colsValue will be set to zero using default constructor

◆ clearColBlock()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::clearColBlock ( Index  j)
inline

Clear col block method. Clear this col in all row of matrix.

Parameters
j: Col index considering size of matrix in block.
Warning
if ClearByZeros Policy is activated all col j of each line will be set to zero using default constructor

◆ clearRowBlock()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::clearRowBlock ( Index  i)
inline

Clear row block method. Clear all col of this line.

Parameters
i: Line index considering size of matrix in block.
Warning
if ClearByZeros Policy is activated all col value of line will be set to zero using default constructor

◆ clearRowColBlock()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename = typename std::enable_if< Policy::IsAlwaysSquare>>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::clearRowColBlock ( Index  i)
inline

Clear both row i and column i in a square matrix.

Parameters
i: Row and Col index considering size of matrix in block.
Warning
if ClearByZeros Policy is activated all col i and line i values of will be set to zero using default constructor

◆ colBSize()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
Index sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::colBSize ( ) const
inline
Returns
the number of col blocks

◆ compress()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::compress ( )
inline

◆ compressBtemp()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::compressBtemp ( )
inlineprotected

Clear matrix and compute new triplet's arrays by combining old ones and btemp(VecIndexedBlock) array.

◆ compressCSR()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::compressCSR ( )
inlineprotected

◆ countEmptyBlocks()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
std::size_t sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::countEmptyBlocks ( ) const
inline

◆ deleteRow()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::deleteRow ( Index  rowId)
inlineprotected

Method to easy delete row given position in rowIndex.

Parameters
RowIdposition on line in rowIndex

◆ fullRows()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::fullRows ( )
inline

Make sure all rows have an entry even if they are empty.

◆ fullyCompressBtemp()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::fullyCompressBtemp ( )
inlineprotected

Clear matrix and just add btemp array.

◆ getBlock()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
const Block& sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::getBlock ( Index  i,
Index  j 
) const
inline

◆ getColsIndex()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
const VecIndex& sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::getColsIndex ( ) const
inline

◆ getColsValue()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
const VecBlock& sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::getColsValue ( ) const
inline

◆ getMaxColIndex()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename = typename std::enable_if< Policy::AutoSize>>
Index sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::getMaxColIndex ( )
inlineprotected

Method to easy have the max colIndex. Could only be used if AutoSize policy is activated.

◆ getRowBegin()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
const VecIndex& sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::getRowBegin ( ) const
inline

◆ getRowIndex()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
const VecIndex& sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::getRowIndex ( ) const
inline

◆ getRowRange()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
Range sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::getRowRange ( Index  id) const
inline

Returns the range of indices from the column indices corresponding to the id-th row.

◆ getSymBlock()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
const BlockTranspose sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::getSymBlock ( Index  i,
Index  j 
) const
inline

◆ getWBlock()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
Block* sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::getWBlock ( Index  i,
Index  j,
bool  create = false 
)
inline

◆ insertBtemp()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
Block* sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::insertBtemp ( const Index  i,
const Index  j 
)
inlineprotected

Method to easy insert new block into btemp.

Parameters
Lineindex i and column index j
Returns
pointer on Block value

◆ mul()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename RB , typename RP , typename MB , typename MP >
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::mul ( CompressedRowSparseMatrixGeneric< RB, RP > &  res,
const CompressedRowSparseMatrixGeneric< MB, MP > &  m 
) const
inline

Compute res = this * m

Warning
The block sizes must be compatible, i.e. this::NC==m::NR and res::NR==this::NR and res::NC==m::NC. The basic algorithm consists in accumulating rows of m to rows of res: foreach row { foreach col { res[row] += this[row,col] * m[col] } }
matrices this and m must be compressed

◆ mulTranspose()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename RB , typename RP , typename MB , typename MP >
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::mulTranspose ( CompressedRowSparseMatrixGeneric< RB, RP > &  res,
const CompressedRowSparseMatrixGeneric< MB, MP > &  m 
) const
inline

Compute res = this.transpose * m

Warning
The block sizes must be compatible, i.e. this::NR==m::NR and res::NR==this::NC and res::NC==m::NC The basic algorithm consists in accumulating rows of m to rows of res: foreach row { foreach col { res[row] += this[row,col] * m[col] } }
matrices this and m must be compressed

◆ Name()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
static const char* sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::Name ( )
inlinestatic

◆ read()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
std::istream& sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::read ( std::istream &  is)
inline

◆ readVector()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename TVec >
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::readVector ( TVec &  vec,
std::istream &  in 
)
inlineprotected

◆ registerBtempLine()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
std::pair<Index, Index> sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::registerBtempLine ( typename VecIndexedBlock::const_iterator &  itbtemp)
inlineprotected

Add a complete new line from btemp into matrix.

Parameters
itbtemp: Reference to actual status of iterator on btemp
Returns
Number of col added

◆ registerNewCol()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
bool sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::registerNewCol ( Index colId,
TBlock &  bvalue 
)
inlineprotected

Add a new col into matrix.

Parameters
colId: Index of column
bvalue: Block value to add
Returns
true if col has been added

◆ resizeBloc()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::resizeBloc ( Index  nbBRow,
Index  nbBCol 
)
inline

◆ resizeBlock()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
virtual void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::resizeBlock ( Index  nbBRow,
Index  nbBCol 
)
inlinevirtual

◆ rowBSize()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
Index sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::rowBSize ( ) const
inline
Returns
the number of row blocks

◆ setBlock() [1/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::setBlock ( Index  i,
Index  j,
const Block v 
)
inline

◆ setBlock() [2/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::setBlock ( Index  i,
Index  j,
Index rowId,
Index colId,
const Block v 
)
inline

◆ shiftIndices()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::shiftIndices ( Index  base)
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.

◆ sortedFind() [1/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
static bool sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::sortedFind ( const VecIndex v,
Index  val,
Index result 
)
inlinestatic

◆ sortedFind() [2/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
static bool sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::sortedFind ( const VecIndex v,
Range  in,
Index  val,
Index result 
)
inlinestatic

◆ swap()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::swap ( Matrix m)
inline

◆ transposeFullRows()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename TBlock2 , typename TPolicy2 >
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::transposeFullRows ( CompressedRowSparseMatrixGeneric< TBlock2, TPolicy2 > &  res) const
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.

◆ wbloc()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
Block* sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::wbloc ( Index  i,
Index  j,
bool  create = false 
)
inline

◆ wblock() [1/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
Block* sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::wblock ( Index  i,
Index  j,
bool  create = false 
)
inline

Write block method.

Parameters
Lineindex i and column index j
create,booleanto decide if wblock could add new value into not existing line/column
Returns
pointer on Block value if exist or nullptr if not

◆ wblock() [2/2]

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
Block* sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::wblock ( Index  i,
Index  j,
Index rowId,
Index colId,
bool  create = false 
)
inline

Write block method when rowId and colId are known, this is an optimized wblock specification.

Parameters
Lineindex i and column index j
rowId: Index of value i into rowIndex internal vector
colId: Index of value j into colIndex internal vector
create,booleanto decide if wblock could add new value into not existing line/column
Returns
pointer on Block value if exist or nullptr if not

◆ write()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
std::ostream& sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::write ( std::ostream &  os) const
inline

◆ writeVector()

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
template<typename TVec >
void sofa::linearalgebra::CompressedRowSparseMatrixGeneric< TBlock, TPolicy >::writeVector ( const TVec &  vec,
std::ostream &  os 
)
inlineprotected

Enum details

◆ anonymous enum

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
anonymous enum
Enumerator
category 

◆ anonymous enum

template<typename TBlock , typename TPolicy = CRSDefaultPolicy>
anonymous enum
Enumerator
operand