|
using | ConstViewType = typename ViewType::ConstViewType |
| Matrix view type for constant instances.
|
using | RealAllocatorType = RealAllocator |
| The allocator for matrix elements values.
|
template<typename _Real = Real, typename _Device = Device, typename _Index = Index, ElementsOrganization _Organization = Algorithms::Segments::DefaultElementsOrganization< _Device >::getOrganization(), typename _RealAllocator = typename Allocators::Default< _Device >::template Allocator< _Real >> |
using | Self = TridiagonalMatrix< _Real, _Device, _Index, _Organization, _RealAllocator > |
| Helper type for getting self type or its modifications.
|
using | ValuesVectorType = Containers::Vector< Real, Device, Index, RealAllocator > |
| Type of vector holding values of matrix elements.
|
using | ViewType = TridiagonalMatrixView< Real, Device, Index, Organization > |
| Type of related matrix view.
|
using | ConstRowView |
| Type for accessing constant matrix rows.
|
using | DeviceType |
| The device where the matrix is allocated.
|
using | IndexerType |
using | IndexType |
| The type used for matrix elements indexing.
|
using | RealType |
| The type of matrix elements.
|
using | RowView |
| Type for accessing matrix rows.
|
using | ConstValuesViewType |
| Type of constant vector view holding values of matrix elements.
|
using | DeviceType |
| The device where the matrix is allocated.
|
using | IndexType |
| The type used for matrix elements indexing.
|
using | RealType |
| The type of matrix elements.
|
using | RowCapacitiesType |
using | ValuesViewType |
| Type of vector view holding values of matrix elements.
|
|
| TridiagonalMatrix ()=default |
| Constructor with no parameters.
|
| TridiagonalMatrix (const TridiagonalMatrix &matrix) |
| Copy constructor.
|
template<typename ListReal> |
| TridiagonalMatrix (Index columns, const std::initializer_list< std::initializer_list< ListReal > > &data) |
| Constructor with matrix dimensions, diagonals offsets and matrix elements.
|
| TridiagonalMatrix (Index rows, Index columns) |
| Constructor with matrix dimensions.
|
| TridiagonalMatrix (TridiagonalMatrix &&) noexcept=default |
| Move constructor.
|
ConstViewType | getConstView () const |
| Returns a non-modifiable view of the tridiagonal matrix.
|
template<typename Real2, typename Index2> |
void | getTransposition (const TridiagonalMatrix< Real2, Device, Index2 > &matrix, const Real &matrixMultiplicator=1.0) |
ViewType | getView () |
| Returns a modifiable view of the tridiagonal matrix.
|
void | load (const String &fileName) |
| Method for loading the matrix from the file with given filename.
|
TridiagonalMatrix & | operator= (const TridiagonalMatrix &matrix) |
| Assignment of exactly the same matrix type.
|
template<typename Real_, typename Device_, typename Index_, ElementsOrganization Organization_, typename RealAllocator_> |
TridiagonalMatrix & | operator= (const TridiagonalMatrix< Real_, Device_, Index_, Organization_, RealAllocator_ > &matrix) |
| Assignment of another tridiagonal matrix.
|
template<typename Real_, typename Device_, typename Index_, ElementsOrganization Organization_, typename RealAllocator_> |
TridiagonalMatrix< Real, Device, Index, Organization, RealAllocator > & | operator= (const TridiagonalMatrix< Real_, Device_, Index_, Organization_, RealAllocator_ > &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 | setDimensions (Index rows, Index columns) |
| Set matrix dimensions.
|
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_> |
void | setLike (const TridiagonalMatrix< Real_, Device_, Index_, Organization_, RealAllocator_ > &matrix) |
| Setup the matrix dimensions and diagonals offsets based on another tridiagonal matrix.
|
template<typename RowCapacitiesVector> |
void | setRowCapacities (const RowCapacitiesVector &rowCapacities) |
| This method is for compatibility with SparseMatrix.
|
__cuda_callable__ | TridiagonalMatrixBase ()=default |
| Constructor with no parameters.
|
__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 TridiagonalMatrixBase< Real_, Device_, Index_, Organization_ > &matrix, const RealType &matrixMultiplicator=1.0, const RealType &thisMatrixMultiplicator=1.0) |
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 | 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 | getCompressedRowLengths (Vector &rowLengths) const |
| Computes number of non-zeros in each row.
|
__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__ const IndexerType & | getIndexer () const |
| This method returns matrix elements indexer used by this matrix.
|
IndexType | getNonzeroElementsCount () const |
| Returns number of non-zero matrix elements.
|
__cuda_callable__ RowView | getRow (IndexType rowIdx) |
| Non-constant getter of simple structure for accessing given matrix row.
|
void | getRowCapacities (Vector &rowCapacities) const |
| Compute capacities of all rows.
|
bool | operator!= (const TridiagonalMatrixBase< Real_, Device_, Index_, Organization_ > &matrix) const |
| Comparison operator with another multidiagonal matrix.
|
TridiagonalMatrixBase & | operator= (const TridiagonalMatrixBase &)=delete |
| Copy-assignment operator.
|
bool | operator== (const TridiagonalMatrixBase< Real_, Device_, Index_, Organization_ > &matrix) const |
| Comparison operator with another tridiagonal 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) const |
| This method calls sequentialForRows for all matrix rows (for 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.
|
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__ const ValuesViewType & | getValues () const |
| Returns a constant reference to a vector with the matrix elements values.
|
__cuda_callable__ MatrixBase & | operator= (const MatrixBase &)=delete |
| Copy-assignment operator.
|
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 >>
class TNL::Matrices::TridiagonalMatrix< Real, Device, Index, Organization, RealAllocator >
Implementation of sparse tridiagonal matrix.
Use this matrix type for storing of tridiagonal matrices i.e., matrices having non-zero matrix elements only on its diagonal and immediately above and bellow the diagonal. This is an example:
\[\left(
\begin{array}{ccccccc}
4 & -1 & . & . & . & . \\
-1 & 4 & -1 & . & . & . \\
. & -1 & 4 & -1 & . & . \\
. & . & -1 & 4 & -1 & . \\
. & . & . & -1 & 4 & -1 \\
. & . & . & . & -1 & 4
\end{array}
\right)
\]
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 TridiagonalMatrix and SparseMatrix.
Real | Index | SparseMatrix | TridiagonalMatrix | 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. |