|
AGX Dynamics
2.35.0.1
|
agx::SparseMatrix holds a matrix representation which contains the data. More...
#include <SparseMatrix.h>
Public Types | |
| enum | BlockFlags { DENSE = 0 , DIAGONAL = 1 , LOWER_TRIANGULAR = 2 , UPPER_TRIANGULAR = 3 } |
| Flags that can be used to tag blocks so that the matrix representation can optimize the calculations. More... | |
Public Member Functions | |
| SparseMatrix (MatrixType type=MatrixType(), SparseMatrixRep *rep=0) | |
| Constructor. More... | |
| ~SparseMatrix () | |
| Destructor. More... | |
| void | factor () |
| Factors the matrix. More... | |
| agx::Real * | getBlock (int i, int j, bool &writeTransposed, unsigned int &leadingDimension) |
| Fetches the location for a block of the matrix. More... | |
| agx::UInt | getBlockPermutedStartRowIndex (agx::UInt blockIndex) const |
| agx::Bool | getColumn (agx::UInt colNumber, agx::RealValarray &retCol) const |
| Extract a column from the matrix. More... | |
| agx::Bool | getColumn (agx::UInt colNumber, agx::RealValarray &retCol, agx::Bool &signFlip) const |
| Extract a column from the matrix. More... | |
| agx::Real | getFactorTime () const |
| unsigned int | getNumColumns () const |
| unsigned int | getNumRows () const |
| SparseMatrixRep * | getRep () |
| const SparseMatrixRep * | getRep () const |
| agx::Bool | getRow (agx::UInt rowNumber, const agx::RealValarray &signs, agx::RealValarray &retRow) const |
| Extract a row from the matrix. More... | |
| agx::Real | getSolveTime () const |
| MatrixType & | getType () |
| agx::UInt | invPermuteRowIndex (agx::UInt permutedRowIndex) const |
| bool | loadH5 (void *group, const agx::String &name) |
| Loads the matrix. More... | |
| void | multiply (const agx::Real *x, agx::Real *r) |
| Calculates r = A x. More... | |
| void | multiplyAdd (const agx::Real &alpha, const agx::Real *x, const agx::Real &beta, agx::Real *r) |
| Calculates r = alpha A x + beta r. More... | |
| void | multiplyAdd (const agx::Real *x, agx::Real *r) |
| Calculates r = Ax + r. More... | |
| agx::UInt | permuteRowIndex (agx::UInt rowIndex) const |
| void | print () const |
| void | reset () |
| Clears the matrix. More... | |
| bool | saveH5 (void *group, const agx::String &name) const |
| Stores the matrix in HDF5 format. More... | |
| void | setLogicalStructure (size_t n, const unsigned int *pointers, const unsigned int *indices, const unsigned int *dimensions, const int *flags=nullptr, unsigned int numThreads=1) |
| Sets the logical structure of the matrix. More... | |
| void | setNumBodies (int num) |
| Sets the number of bodies, can be used by the representation to help making the permutation. More... | |
| void | setRep (SparseMatrixRep *rep) |
| Replace the Sparse Matrix Representation. More... | |
| void | solve (agx::Real *) |
| Solve, the right hand side is overwritten with the result. More... | |
| size_t | unitSolve (agx::Real *, int=-1) |
| Solve, the right hand side is overwritten with the result. More... | |
agx::SparseMatrix holds a matrix representation which contains the data.
Each solver wrapper (if it can handle the matrix format defined by MatrixType), uses this data and passes it in the correct format to the solver.
Definition at line 85 of file SparseMatrix.h.
Flags that can be used to tag blocks so that the matrix representation can optimize the calculations.
| Enumerator | |
|---|---|
| DENSE | |
| DIAGONAL | |
| LOWER_TRIANGULAR | |
| UPPER_TRIANGULAR | |
Definition at line 93 of file SparseMatrix.h.
| agx::SparseMatrix::SparseMatrix | ( | MatrixType | type = MatrixType(), |
| SparseMatrixRep * | rep = 0 |
||
| ) |
Constructor.
| type | Matrix type |
| rep | Pointer to SparseMatrixRepresentation. The SparseMatrix takes ownership of the pointer. |
| agx::SparseMatrix::~SparseMatrix | ( | ) |
Destructor.
| void agx::SparseMatrix::factor | ( | ) |
Factors the matrix.
Definition at line 376 of file SparseMatrix.h.
References agx::SparseMatrixRep::factor().
| agx::Real * agx::SparseMatrix::getBlock | ( | int | i, |
| int | j, | ||
| bool & | writeTransposed, | ||
| unsigned int & | leadingDimension | ||
| ) |
Fetches the location for a block of the matrix.
The block can be 1x1 in size for non block matrix.
| i | Block row index. |
| j | Block column index. |
| leadingDimension | Leading dimension when writing the block data. Row major/column major depends on MatrixRep used. |
Definition at line 366 of file SparseMatrix.h.
References agx::SparseMatrixRep::getBlock().
| blockIndex | - non-permuted block index |
Definition at line 406 of file SparseMatrix.h.
References agx::SparseMatrixRep::getBlockPermutedStartRowIndex().
| agx::Bool agx::SparseMatrix::getColumn | ( | agx::UInt | colNumber, |
| agx::RealValarray & | retCol | ||
| ) | const |
Extract a column from the matrix.
| colNumber | - column number to extract | |
| [out] | retCol | - result |
| agx::Bool agx::SparseMatrix::getColumn | ( | agx::UInt | colNumber, |
| agx::RealValarray & | retCol, | ||
| agx::Bool & | signFlip | ||
| ) | const |
Extract a column from the matrix.
| colNumber | - column number to extract | |
| [out] | retCol | - result |
| [out] | signFlip | - depending on colNumber the sign has to be flipped when this column is transformed to a row |
| agx::Real agx::SparseMatrix::getFactorTime | ( | ) | const |
| unsigned int agx::SparseMatrix::getNumColumns | ( | ) | const |
Definition at line 426 of file SparseMatrix.h.
References agx::SparseMatrixRep::getNumColumns().
| unsigned int agx::SparseMatrix::getNumRows | ( | ) | const |
Definition at line 421 of file SparseMatrix.h.
References agx::SparseMatrixRep::getNumRows().
| SparseMatrixRep* agx::SparseMatrix::getRep | ( | ) |
| const SparseMatrixRep* agx::SparseMatrix::getRep | ( | ) | const |
| agx::Bool agx::SparseMatrix::getRow | ( | agx::UInt | rowNumber, |
| const agx::RealValarray & | signs, | ||
| agx::RealValarray & | retRow | ||
| ) | const |
Extract a row from the matrix.
| rowNumber | - row number to extract | |
| signs | - sign array -1 for constraints, 1 for bodies | |
| [out] | retRow | - result |
| agx::Real agx::SparseMatrix::getSolveTime | ( | ) | const |
| MatrixType & agx::SparseMatrix::getType | ( | ) |
Definition at line 353 of file SparseMatrix.h.
| permutedRowIndex | - permuted row index |
Definition at line 416 of file SparseMatrix.h.
References agx::SparseMatrixRep::invPermuteRowIndex().
|
inline |
Loads the matrix.
| group | Pointer to H5::Group in which matrix should be stored |
| name | Name to use when loading matrix |
Definition at line 441 of file SparseMatrix.h.
References agx::SparseMatrixRep::loadH5().
Calculates r = A x.
Definition at line 391 of file SparseMatrix.h.
References agx::SparseMatrixRep::multiply().
| void agx::SparseMatrix::multiplyAdd | ( | const agx::Real & | alpha, |
| const agx::Real * | x, | ||
| const agx::Real & | beta, | ||
| agx::Real * | r | ||
| ) |
Calculates r = alpha A x + beta r.
Definition at line 401 of file SparseMatrix.h.
References agx::SparseMatrixRep::multiplyAdd().
Calculates r = Ax + r.
Definition at line 396 of file SparseMatrix.h.
References agx::SparseMatrixRep::multiplyAdd().
| rowIndex | - non-permuted rowIndex |
Definition at line 411 of file SparseMatrix.h.
References agx::SparseMatrixRep::permuteRowIndex().
|
inline |
Definition at line 431 of file SparseMatrix.h.
References agx::SparseMatrixRep::print().
| void agx::SparseMatrix::reset | ( | ) |
Clears the matrix.
Definition at line 371 of file SparseMatrix.h.
References agx::SparseMatrixRep::reset().
|
inline |
Stores the matrix in HDF5 format.
| group | Pointer to H5::Group in which matrix should be stored |
| name | Name to use when storing matrix |
Definition at line 436 of file SparseMatrix.h.
References agx::SparseMatrixRep::saveH5().
| void agx::SparseMatrix::setLogicalStructure | ( | size_t | n, |
| const unsigned int * | pointers, | ||
| const unsigned int * | indices, | ||
| const unsigned int * | dimensions, | ||
| const int * | flags = nullptr, |
||
| unsigned int | numThreads = 1 |
||
| ) |
Sets the logical structure of the matrix.
The method takes a matrix in packed row format.
| n | Number of (block) rows |
| pointers | Row pointers |
| indices | Column indices |
| dimensions | Number of rows for each block row. If not blocked, each dimension[i] will be 1. |
| flags | Pointer to flag for each block, if 0, all blocks are assumed to be dense. |
| numThreads | Hint about maximum number of threads the factorizer can use. |
Definition at line 359 of file SparseMatrix.h.
References agx::SparseMatrixRep::setLogicalStructure().
| void agx::SparseMatrix::setNumBodies | ( | int | num | ) |
Sets the number of bodies, can be used by the representation to help making the permutation.
Definition at line 446 of file SparseMatrix.h.
References agx::SparseMatrixRep::setNumBodies().
| void agx::SparseMatrix::setRep | ( | SparseMatrixRep * | rep | ) |
Replace the Sparse Matrix Representation.
The SparseMatrix takes ownership of the SparseMatrixRep
This method is only needed in some very special use cases.
| void agx::SparseMatrix::solve | ( | agx::Real * | rhs | ) |
Solve, the right hand side is overwritten with the result.
Definition at line 381 of file SparseMatrix.h.
References agx::SparseMatrixRep::solve().
| size_t agx::SparseMatrix::unitSolve | ( | agx::Real * | rhs, |
| int | startRow = -1 |
||
| ) |
Solve, the right hand side is overwritten with the result.
The right hand side is contains one 1, the rest is 0.
Definition at line 386 of file SparseMatrix.h.
References agx::SparseMatrixRep::unitSolve().