Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix. This class provides basic element-wise arithmetic operations and access functionality. It also includes a build-up feature that allows elements to be registered using the Coordinate (COO) format prior to finalization. Note: Adding elements after the initial build-up is not supported, as it is inefficient and unnecessary for static mesh use cases.
More...
|
| | CsrSparseMatrix () |
| | Constructor for an empty CsrSparseMatrix object. Leaves all storage arrays empty but sets the flag to allow dynamic creation.
|
| |
| | CsrSparseMatrix (const std::valarray< T > &values, const std::valarray< int > &column_indices, const std::valarray< int > &row_pointers, int rows, int cols) |
| | Constructor for an CsrSparseMatrix object from given CSR arrays and row and column numbers. Disables dynamic creation.
|
| |
| void | registerElement (T value, int rows, int cols) |
| | Registers the element and it's initial value within a COO style vector for dynamic creation.
|
| |
| void | buildAtRuntime () |
| | Builds the CSR matrix from the registered elements. It sorts all elements of the COO format vector by rows (ascending) and within one row by columns (ascending) and marks the beginning of the rows while it progresses through the column sorting. Afterwards it simply writes the values and column indices into the corresponding layer. The sorting of the column indices it done to fully comply with the CSR format and allow for O(
log(m) ) random access time (m = #elements within a row). The flag m_dynamic_creation is always true, when using the default constructor and not passing already prebuild CSR arrays to the constructor.
|
| |
| void | buildAtRuntime (int rows, int cols) override |
| | Function overload for enforcing matrix boundaries. Builds the CSR matrix from the registered elements. It sorts all elements of the COO format vector by rows (ascending) and within one row by columns (ascending) and marks the beginning of the rows while it progresses through the column sorting. Afterwards it simply writes the values and column indices into the corresponding layer. The sorting of the column indices it done to fully comply with the CSR format and allow for O(
log(m) ) random access time (m = #elements within a row).
|
| |
| T & | operator() (int rows, int cols) override |
| | Parentheses operator to allow access to the non-zero matrix values as Matrix(row,column). The static CSR matrix only supports writing to predefined non-zero positions. Right now throws an error (int) when trying to access a zero element. Uses divide and conquer to allow access in O( log(m) ) time (m = #elements within a row).
|
| |
| T | operator() (int rows, int cols) const override |
| | Parentheses operator to allow access to the non-zero matrix values as Matrix(row,column) in const contexts. Uses divide and conquer to allow access in O( log(m) ) time (m = #elements within a row).
|
| |
| std::valarray< T > | scalarAdd (T value) const override |
| | Addition of a scalar to the matrix values element-wise.
|
| |
| std::valarray< T > | scalarSubtract (T value) const override |
| | Subtraction of a scalar from the matrix values element-wise.
|
| |
| std::valarray< T > | scalarMultiply (T value) const override |
| | Multiplication of a scalar to the matrix values element-wise.
|
| |
| std::valarray< T > | scalarDivide (T value) const override |
| | Division of a scalar from the matrix values element-wise.
|
| |
| void | printMatrixInDenseFormat () |
| | Prints the entire matrix with zero values.
|
| |
| const std::vector< std::pair< int, int > > & | getNonZeroElements () override |
| |
| void | updateNonZeroElements () override |
| |
| | ~CsrSparseMatrix () override=default |
| |
| | GenericMatrix () |
| | Constructor for an empty GenericMatrix object. This should only be used for dynamically created matrices.
|
| |
| | GenericMatrix (int rows, int cols) |
| | Constructor for an empty GenericMatrix object whose value array holds rows*cols values.
|
| |
| | GenericMatrix (int rows, int cols, const std::valarray< T > &values, bool allow_mismatched_size) |
| | Constructor for a GenericMatrix object whose value array holds rows*cols values given by the user. Can throw an std::ivalid_argument if provided with a value array of different size than rows*cols.
|
| |
| | GenericMatrix (const GenericMatrix &)=default |
| |
| GenericMatrix & | operator= (const GenericMatrix &)=default |
| |
| | GenericMatrix (GenericMatrix &&)=default |
| |
| GenericMatrix & | operator= (GenericMatrix &&)=default |
| |
| std::pair< int, int > | size () const |
| | Function that returns the size of the matrix as a pair in (rows, columns) format.
|
| |
| void | zeroMatrix () |
| | Function that zeros out the matrix.
|
| |
| virtual | ~GenericMatrix ()=default |
| |
template<
typename T>
class CsrSparseMatrix< T >
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix. This class provides basic element-wise arithmetic operations and access functionality. It also includes a build-up feature that allows elements to be registered using the Coordinate (COO) format prior to finalization. Note: Adding elements after the initial build-up is not supported, as it is inefficient and unnecessary for static mesh use cases.