Sparse matrix in CSR or CSC format. More...
#include <cl_SpMatrix.hpp>
Public Member Functions | |
| SpMatrix ()=default | |
| SpMatrix (const SpMatrix &)=delete | |
| SpMatrix (SpMatrix &&)=delete | |
| SpMatrix (Graph &aGraph, const enum SpMatrixType aType=SpMatrixType::CSC, const index_t aNumRows=0, const index_t aNumCols=0, const bool aSortGraph=true) | |
| SpMatrix (SpMatrixType aType, const index_t aNumRows, const index_t aNumCols, const index_t aNumNonZeros, const int_t *aIndices, const int_t *aPointers) | |
| SpMatrix (const string &aHDF5Path, const string aLabel="Matrix") | |
| SpMatrix (const hid_t aParent, const string aLabel="Matrix") | |
| SpMatrix (const Matrix< real > &aMatrix, const SpMatrixType aType=SpMatrixType::CSC) | |
| SpMatrix (SpMatrix *aParent) | |
| ~SpMatrix () | |
| const SpMatrixType & | type () const |
| return the data type | |
| void | fill (const real aValue) |
| write a specific value into all entries of the value container | |
| index_t | n_rows () const |
| number of rows of this matrix | |
| index_t | n_cols () const |
| number of columns of this matrix | |
| index_t | n_pointers () const |
| size_t | memory () const |
| bool | have_coo_indices () const |
| void | set_type (const SpMatrixType aType) |
| sets the type, must be called after set_sizes | |
| index_t | number_of_nonzeros () const |
| number of nonzero values in this matrix | |
| int_t * | pointers () |
| expose the pointers | |
| const int_t * | pointers () const |
| expose the pointers (const version) | |
| int_t * | indices () |
| expose the index array | |
| const int_t * | indices () const |
| expose the index array ( const version ) | |
| int_t * | rows () |
| expose the row indices | |
| const int_t * | rows () const |
| expose the row indices ( const version ) | |
| int_t * | cols () |
| expose the col indices | |
| const int_t * | cols () const |
| expose the col indices ( const version ) | |
| real * | data () |
| expose the data container | |
| const real * | data () const |
| expose the data container ( const version ) | |
| real & | data (const index_t aIndex) |
| expose single entry in the data container | |
| const real & | data (const index_t aIndex) const |
| expose single entry in the data containe ( const version ) | |
| int_t | index (const index_t aRowIndex, const index_t aColIndex) const |
| int_t | position (const index_t aRowIndex, const index_t aColIndex) const |
| Position of ( aRowIndex, aColIndex ) in the value array, or mNumNonZeros when the entry is not in the sparsity pattern. | |
| void | positions_in_slice (const index_t aSlice, const int_t *aCols, const uint aNumCols, int_t *aPos) const |
| Batched lookup: positions of aNumCols entries of one slice ( a row for CSR, a column for CSC ) in a single merge join over the slice, instead of aNumCols independent searches. | |
| void | sort_entries () |
| Ensure that the indices within each row (CSR) or column (CSC) are sorted in ascending order. | |
| void | set_indexing_base (const enum SpMatrixIndexingBase &aBasis) |
| change the indexing base | |
| void | create_coo_indices () |
| create addidional indices that are needed by MUMPS | |
| void | free_coo_indices () |
| delete additional indices that are needed by MUMPS | |
| void | print (const string aLabel="SparseMatrix") |
| print_t the matrix to the screen ( for debugging ) | |
| void | print2 (const string aLabel="SparseMatrix") |
| print_t the container indices on the screen ( for debugging ) | |
| int_t | indexing_base () const |
| returns the basis type of the matrix 0: c++ indexing 1: fortran indexing | |
| void | multiply (const Vector< real > &aX, Vector< real > &aY, const real aAlpha, const real aBeta, const bool aTransposedFlag=false) |
| performs a matrix-vector multiplication | |
| void | multiply (const Vector< real > &aX, Vector< real > &aY) |
| simple matrix-vector multiplication | |
| void | transpose () |
| void | save (const string &aPath, const string aLabel="Matrix", const enum FileMode aMode=FileMode::NEW) |
| save matrix to a hdf5 file | |
| void | save (hid_t &aGroup, herr_t &aStatus) |
| save matrix to a specific group in a HDF5 file | |
| void | load (const string &aPath, const string aLabel="Matrix") |
| load matrix from a hdf5 file | |
| void | load (hid_t &aGroup, herr_t &aStatus) |
| load matrix from a specific group in a hdf5 file | |
| real & | operator() (const index_t &aRowIndex, const index_t &aColIndex) |
| access a specific value with write access | |
| const real & | operator() (const index_t &aRowIndex, const index_t &aColIndex) const |
| access a specific value with read access | |
| SpMatrix & | operator= (const SpMatrix &aMatrix) |
| copy operator | |
| SpMatrix & | operator= (SpMatrix &&aMatrix) |
| move operator | |
Sparse matrix in CSR or CSC format.
|
default |
|
delete |
|
delete |
| belfem::SpMatrix::SpMatrix | ( | Graph & | aGraph, |
| const enum SpMatrixType | aType = SpMatrixType::CSC, | ||
| const index_t | aNumRows = 0, | ||
| const index_t | aNumCols = 0, | ||
| const bool | aSortGraph = true ) |
| belfem::SpMatrix::SpMatrix | ( | SpMatrixType | aType, |
| const index_t | aNumRows, | ||
| const index_t | aNumCols, | ||
| const index_t | aNumNonZeros, | ||
| const int_t * | aIndices, | ||
| const int_t * | aPointers ) |
| belfem::SpMatrix::SpMatrix | ( | const Matrix< real > & | aMatrix, |
| const SpMatrixType | aType = SpMatrixType::CSC ) |
|
explicit |
| belfem::SpMatrix::~SpMatrix | ( | ) |
|
inline |
expose the col indices
|
inline |
expose the col indices ( const version )
| void belfem::SpMatrix::create_coo_indices | ( | ) |
create addidional indices that are needed by MUMPS
|
inline |
expose the data container
|
inline |
expose the data container ( const version )
expose single entry in the data container
expose single entry in the data containe ( const version )
| void belfem::SpMatrix::fill | ( | const real | aValue | ) |
write a specific value into all entries of the value container
| void belfem::SpMatrix::free_coo_indices | ( | ) |
delete additional indices that are needed by MUMPS
|
inline |
|
inline |
returns the basis type of the matrix 0: c++ indexing 1: fortran indexing
|
inline |
expose the index array
|
inline |
expose the index array ( const version )
load matrix from a specific group in a hdf5 file
| size_t belfem::SpMatrix::memory | ( | ) | const |
simple matrix-vector multiplication
| void belfem::SpMatrix::multiply | ( | const Vector< real > & | aX, |
| Vector< real > & | aY, | ||
| const real | aAlpha, | ||
| const real | aBeta, | ||
| const bool | aTransposedFlag = false ) |
performs a matrix-vector multiplication
c = alpha * A * b + beta * c
| aX | |
| aY | |
| aAlpha | scaling factor of the product |
| aBeta | scaling factor of the accumulator aY |
| aTransposedFlag | multiply with the transpose of the matrix |
|
inline |
number of columns of this matrix
|
inline |
|
inline |
number of rows of this matrix
|
inline |
number of nonzero values in this matrix
access a specific value with write access
|
inline |
access a specific value with read access
|
inline |
expose the pointers
|
inline |
expose the pointers (const version)
Position of ( aRowIndex, aColIndex ) in the value array, or mNumNonZeros when the entry is not in the sparsity pattern.
Works in either indexing base and for both CSR and CSC; the base is read from mPointers[ 0 ] and both branches are perfectly predicted in any loop that does not alternate between matrices.
| void belfem::SpMatrix::positions_in_slice | ( | const index_t | aSlice, |
| const int_t * | aCols, | ||
| const uint | aNumCols, | ||
| int_t * | aPos ) const |
Batched lookup: positions of aNumCols entries of one slice ( a row for CSR, a column for CSC ) in a single merge join over the slice, instead of aNumCols independent searches.
| aSlice | row index (CSR) or column index (CSC) |
| aCols | the other index of each entry, STRICTLY ascending |
| aNumCols | number of entries |
| aPos | output, one position per entry; an entry absent from the pattern gets mNumNonZeros |
aCols must be strictly ascending - within one element the dof indices are unique, so equal neighbors cannot occur and the merge join does not handle them. Asserted in debug builds.
| void belfem::SpMatrix::print | ( | const string | aLabel = "SparseMatrix" | ) |
print_t the matrix to the screen ( for debugging )
| void belfem::SpMatrix::print2 | ( | const string | aLabel = "SparseMatrix" | ) |
print_t the container indices on the screen ( for debugging )
|
inline |
expose the row indices
|
inline |
expose the row indices ( const version )
| void belfem::SpMatrix::save | ( | const string & | aPath, |
| const string | aLabel = "Matrix", | ||
| const enum FileMode | aMode = FileMode::NEW ) |
save matrix to a specific group in a HDF5 file
| void belfem::SpMatrix::set_indexing_base | ( | const enum SpMatrixIndexingBase & | aBasis | ) |
change the indexing base
| void belfem::SpMatrix::set_type | ( | const SpMatrixType | aType | ) |
sets the type, must be called after set_sizes
| void belfem::SpMatrix::sort_entries | ( | ) |
Ensure that the indices within each row (CSR) or column (CSC) are sorted in ascending order.
Unsorted entries are reordered in place together with their values. This is required for binary search in the index() methods.
Called automatically when loading from HDF5 or constructing from external arrays.
| void belfem::SpMatrix::transpose | ( | ) |
|
inline |
return the data type