|
| MultidiagonalMatrix ()=default |
| Constructor with no parameters.
|
|
| MultidiagonalMatrix (const MultidiagonalMatrix &matrix) |
| Copy constructor.
|
|
template<typename ListIndex , typename ListReal > |
| MultidiagonalMatrix (Index columns, std::initializer_list< ListIndex > diagonalOffsets, const std::initializer_list< std::initializer_list< ListReal > > &data) |
| Constructor with matrix dimensions, diagonals offsets and matrix elements.
|
|
| MultidiagonalMatrix (Index rows, Index columns) |
| Constructor with matrix dimensions.
|
|
template<typename Vector > |
| MultidiagonalMatrix (Index rows, Index columns, const Vector &diagonalOffsets) |
| Constructor with matrix dimensions and matrix elements offsets.
|
|
template<typename ListIndex > |
| MultidiagonalMatrix (Index rows, Index columns, std::initializer_list< ListIndex > diagonalOffsets) |
| Constructor with matrix dimensions and diagonals offsets.
|
|
| MultidiagonalMatrix (MultidiagonalMatrix &&) noexcept=default |
| Move constructor.
|
|
ConstViewType | getConstView () const |
| Returns a non-modifiable view of the multidiagonal matrix.
|
|
template<typename Real2 , typename Index2 > |
void | getTransposition (const MultidiagonalMatrix< Real2, Device, Index2 > &matrix, const Real &matrixMultiplicator=1.0) |
|
ViewType | getView () |
| Returns a modifiable view of the multidiagonal matrix.
|
|
void | load (const String &fileName) |
| Method for loading the matrix from the file with given filename.
|
|
void | load (File &file) override |
| Method for loading the matrix from a file.
|
|
MultidiagonalMatrix & | operator= (const MultidiagonalMatrix &matrix) |
| Assignment of exactly the same matrix type.
|
|
template<typename Real_ , typename Device_ , typename Index_ , ElementsOrganization Organization_, typename RealAllocator_ , typename IndexAllocator_ > |
MultidiagonalMatrix & | operator= (const MultidiagonalMatrix< Real_, Device_, Index_, Organization_, RealAllocator_, IndexAllocator_ > &matrix) |
| Assignment of another multidiagonal matrix.
|
|
template<typename Real_ , typename Device_ , typename Index_ , ElementsOrganization Organization_, typename RealAllocator_ , typename IndexAllocator_ > |
MultidiagonalMatrix< Real, Device, Index, Organization, RealAllocator, IndexAllocator > & | operator= (const MultidiagonalMatrix< Real_, Device_, Index_, Organization_, RealAllocator_, IndexAllocator_ > &matrix) |
|
void | reset () |
| Resets the matrix to zero dimensions.
|
|
void | save (const String &fileName) const |
| Method for saving the matrix to the file with given filename.
|
|
void | save (File &file) const override |
| Method for saving the matrix to a file.
|
|
template<typename Vector > |
void | setDiagonalOffsets (const Vector &diagonalOffsets) |
| Set the diagonals offsets by means of vector-like container.
|
|
template<typename ListIndex > |
void | setDiagonalOffsets (std::initializer_list< ListIndex > diagonalOffsets) |
| Set the diagonals offsets by means of initializer list.
|
|
template<typename Vector > |
void | setDimensions (Index rows, Index columns, const Vector &diagonalOffsets) |
| Set matrix dimensions and diagonals offsets.
|
|
template<typename ListReal > |
void | setElements (const std::initializer_list< std::initializer_list< ListReal > > &data) |
| Set matrix elements from an initializer list.
|
|
template<typename Real_ , typename Device_ , typename Index_ , ElementsOrganization Organization_, typename RealAllocator_ , typename IndexAllocator_ > |
void | setLike (const MultidiagonalMatrix< Real_, Device_, Index_, Organization_, RealAllocator_, IndexAllocator_ > &matrix) |
| Setup the matrix dimensions and diagonals offsets based on another multidiagonal matrix.
|
|
template<typename RowCapacitiesVector > |
void | setRowCapacities (const RowCapacitiesVector &rowCapacities) |
| This method is for compatibility with SparseMatrix.
|
|
virtual | ~Object ()=default |
| Destructor.
|
|
virtual std::string | getSerializationTypeVirtual () const |
|
void | load (const String &fileName) |
| Method for restoring the object from a file.
|
|
void | save (const String &fileName) const |
| Method for saving the object to a file as a binary data.
|
|
__cuda_callable__ | MultidiagonalMatrixBase ()=default |
| Constructor with no parameters.
|
|
__cuda_callable__ | MultidiagonalMatrixBase (const MultidiagonalMatrixBase &)=default |
| Copy constructor.
|
|
__cuda_callable__ | MultidiagonalMatrixBase (MultidiagonalMatrixBase &&) noexcept=default |
| Move constructor.
|
|
__cuda_callable__ | MultidiagonalMatrixBase (typename Base::ValuesViewType values, DiagonalOffsetsView diagonalOffsets, HostDiagonalOffsetsView hostDiagonalOffsets, IndexerType indexer) |
| Constructor with all necessary data and views.
|
|
__cuda_callable__ void | addElement (IndexType row, IndexType column, const RealType &value, const RealType &thisElementMultiplicator=1.0) |
| Add element at given row and column to given value.
|
|
void | addMatrix (const MultidiagonalMatrixBase< Real_, Device_, Index_, Organization_ > &matrix, const RealType &matrixMultiplicator=1.0, const RealType &thisMatrixMultiplicator=1.0) |
|
void | forAllElements (Function &function) |
| This method calls forElements for all matrix rows.
|
|
void | forAllElements (Function &function) const |
| This method calls forElements for all matrix rows (for constant instances).
|
|
void | forAllRows (Function &&function) |
| Method for parallel iteration over all matrix rows.
|
|
void | forAllRows (Function &&function) const |
| Method for parallel iteration over all matrix rows for constant instances.
|
|
void | forElements (IndexType begin, IndexType end, Function &function) |
| Method for iteration over all matrix rows for non-constant instances.
|
|
void | forElements (IndexType begin, IndexType end, Function &function) const |
| Method for iteration over all matrix rows for constant instances.
|
|
void | forRows (IndexType begin, IndexType end, Function &&function) |
| Method for parallel iteration over matrix rows from interval [begin, end) .
|
|
void | forRows (IndexType begin, IndexType end, Function &&function) const |
| Method for parallel iteration over matrix rows from interval [begin, end) for constant instances.
|
|
void | getCompressedRowLengths (Vector &rowLengths) const |
| Computes number of non-zeros in each row.
|
|
__cuda_callable__ DiagonalOffsetsView | getDiagonalOffsets () |
| Returns a view for the vector of diagonal offsets.
|
|
__cuda_callable__ DiagonalOffsetsView::ConstViewType | getDiagonalOffsets () const |
| Returns a view for the vector of diagonal offsets.
|
|
__cuda_callable__ IndexType | getDiagonalsCount () const |
| Returns number of diagonals.
|
|
__cuda_callable__ RealType | getElement (IndexType row, IndexType column) const |
| Returns value of matrix element at position given by its row and column index.
|
|
__cuda_callable__ IndexerType & | getIndexer () |
| This method returns matrix elements indexer used by this matrix.
|
|
__cuda_callable__ const IndexerType & | getIndexer () const |
| This method returns matrix elements indexer used by this matrix.
|
|
IndexType | getNonzeroElementsCount () const override |
| Returns number of non-zero matrix elements.
|
|
__cuda_callable__ RowView | getRow (IndexType rowIdx) |
| Non-constant getter of simple structure for accessing given matrix row.
|
|
__cuda_callable__ ConstRowView | getRow (IndexType rowIdx) const |
| Constant getter of simple structure for accessing given matrix row.
|
|
void | getRowCapacities (Vector &rowCapacities) const |
| Compute capacities of all rows.
|
|
bool | operator!= (const MultidiagonalMatrixBase< Real_, Device_, Index_, Organization_ > &matrix) const |
| Comparison operator with another multidiagonal matrix.
|
|
MultidiagonalMatrixBase & | operator= (const MultidiagonalMatrixBase &)=delete |
| Copy-assignment operator.
|
|
MultidiagonalMatrixBase & | operator= (MultidiagonalMatrixBase &&)=delete |
| Move-assignment operator.
|
|
bool | operator== (const MultidiagonalMatrixBase< Real_, Device_, Index_, Organization_ > &matrix) const |
| Comparison operator with another multidiagonal matrix.
|
|
void | print (std::ostream &str) const |
| Method for printing the matrix to output stream.
|
|
void | reduceAllRows (Fetch &&fetch, const Reduce &reduce, Keep &&keep, const FetchReal &identity) const |
| Method for performing general reduction on all matrix rows for constant instances.
|
|
void | reduceRows (IndexType begin, IndexType end, Fetch &&fetch, const Reduce &reduce, Keep &&keep, const FetchReal &identity) const |
| Method for performing general reduction on matrix rows for constant instances.
|
|
void | sequentialForAllRows (Function &function) |
| This method calls sequentialForRows for all matrix rows.
|
|
void | sequentialForAllRows (Function &function) const |
| This method calls sequentialForRows for all matrix rows (for constant instances).
|
|
void | sequentialForRows (IndexType begin, IndexType end, Function &function) |
| Method for sequential iteration over all matrix rows for non-constant instances.
|
|
void | sequentialForRows (IndexType begin, IndexType end, Function &function) const |
| Method for sequential iteration over all matrix rows for constant instances.
|
|
__cuda_callable__ void | setElement (IndexType row, IndexType column, const RealType &value) |
| Sets element at given row and column to given value.
|
|
void | setValue (const RealType &value) |
| Set all matrix elements to given value.
|
|
void | vectorProduct (const InVector &inVector, OutVector &outVector, RealType matrixMultiplicator=1.0, RealType outVectorMultiplicator=0.0, IndexType begin=0, IndexType end=0) const |
| Computes product of matrix and vector.
|
|
__cuda_callable__ | MatrixBase ()=default |
| Basic constructor with no parameters.
|
|
__cuda_callable__ | MatrixBase (const MatrixBase &view)=default |
| Shallow copy constructor.
|
|
__cuda_callable__ | MatrixBase (IndexType rows, IndexType columns, ValuesViewType values) |
| Constructor with matrix dimensions and matrix elements values.
|
|
__cuda_callable__ | MatrixBase (MatrixBase &&view) noexcept=default |
| Move constructor.
|
|
IndexType | getAllocatedElementsCount () const |
| Tells the number of allocated matrix elements.
|
|
__cuda_callable__ IndexType | getColumns () const |
| Returns number of matrix columns.
|
|
__cuda_callable__ IndexType | getRows () const |
| Returns number of matrix rows.
|
|
__cuda_callable__ ValuesViewType & | getValues () |
| Returns a reference to a vector with the matrix elements values.
|
|
__cuda_callable__ const ValuesViewType & | getValues () const |
| Returns a constant reference to a vector with the matrix elements values.
|
|
bool | operator!= (const Matrix &matrix) const |
| Comparison operator with another arbitrary matrix view type.
|
|
bool | operator!= (const MatrixT &matrix) const |
|
__cuda_callable__ MatrixBase & | operator= (const MatrixBase &)=delete |
| Copy-assignment operator.
|
|
__cuda_callable__ MatrixBase & | operator= (MatrixBase &&)=delete |
| Move-assignment operator.
|
|
bool | operator== (const Matrix &matrix) const |
| Comparison operator with another arbitrary matrix view type.
|
|
bool | operator== (const MatrixT &matrix) const |
|
template<typename
Real = double, typename Device = Devices::Host, typename Index = int,
ElementsOrganization Organization = Algorithms::Segments::DefaultElementsOrganization< Device >::getOrganization(), typename RealAllocator = typename Allocators::Default< Device >::template Allocator< Real >, typename IndexAllocator = typename Allocators::Default< Device >::template Allocator< Index >>
class TNL::Matrices::MultidiagonalMatrix< Real, Device, Index, Organization, RealAllocator, IndexAllocator >
Implementation of sparse multidiagonal matrix.
Use this matrix type for storing of matrices where the offsets of non-zero elements from the diagonal are the same in each row. Typically such matrices arise from discretization of partial differential equations on regular numerical grids. This is one example (dots represent zero matrix elements):
\[
\left(
\begin{array}{ccccccc}
4 & -1 & . & -1 & . & . \\
-1 & 4 & -1 & . & -1 & . \\
. & -1 & 4 & -1 & . & -1 \\
-1 & . & -1 & 4 & -1 & . \\
. & -1 & . & -1 & 4 & -1 \\
. & . & -1 & . & -1 & 4
\end{array}
\right)
\]
In this matrix, the column indexes in each row \(i\) can be expressed as \(\{i-3, i-1, i, i+1, i+3\}\) (where the resulting index is non-negative and smaller than the number of matrix columns). Therefore the diagonals offsets are \(\{-3,-1,0,1,3\}\). Advantage is that we do not store the column indexes explicitly as it is in SparseMatrix. This can reduce significantly the memory requirements which also means better performance. See the following table for the storage requirements comparison between TNL::Matrices::MultidiagonalMatrix and TNL::Matrices::SparseMatrix.
Real | Index | SparseMatrix | MultidiagonalMatrix | Ratio |
float | 32-bit int | 8 bytes per element | 4 bytes per element | 50% |
double | 32-bit int | 12 bytes per element | 8 bytes per element | 75% |
float | 64-bit int | 12 bytes per element | 4 bytes per element | 30% |
double | 64-bit int | 16 bytes per element | 8 bytes per element | 50% |
- Template Parameters
-
Real | is a type of matrix elements. |
Device | is a device where the matrix is allocated. |
Index | is a type for indexing of the matrix elements. |
Organization | tells the ordering of matrix elements. It is either RowMajorOrder or ColumnMajorOrder. |
RealAllocator | is allocator for the matrix elements. |
IndexAllocator | is allocator for the matrix elements offsets. |