Template Numerical Library version\ main:8b8c8226
|
Base class for other matrix types. More...
#include <TNL/Matrices/Matrix.h>
Public Types | |
using | ConstRowsCapacitiesView = typename RowsCapacitiesView::ConstViewType |
using | ConstValuesType = Containers::Vector< std::add_const_t< Real >, Device, Index, RealAllocator > |
Type of constant vector holding values of matrix elements. | |
using | ConstValuesView = typename ViewType::ConstValuesView |
Type of constant vector view holding values of matrix elements. | |
using | ConstViewType = typename MatrixView< Real, Device, Index >::ConstViewType |
Type of base matrix view for constant instances. More... | |
using | DeviceType = Device |
The device where the matrix is allocated. | |
using | IndexType = Index |
The type used for matrix elements indexing. | |
using | RealAllocatorType = RealAllocator |
using | RealType = Real |
The type of matrix elements. | |
using | RowsCapacitiesType = Containers::Vector< Index, Device, Index > |
using | RowsCapacitiesView = Containers::VectorView< Index, Device, Index > |
using | ValuesType = Containers::Vector< Real, Device, Index, RealAllocator > |
Type of vector holding values of matrix elements. | |
using | ValuesView = typename ViewType::ValuesView |
Type of vector view holding values of matrix elements. | |
using | ViewType = MatrixView< Real, Device, Index > |
Type of base matrix view. More... | |
Public Member Functions | |
Matrix (const RealAllocatorType &allocator=RealAllocatorType()) | |
Construct a new Matrix object possibly with user defined allocator of the matrix values. More... | |
Matrix (IndexType rows, IndexType columns, const RealAllocatorType &allocator=RealAllocatorType()) | |
Construct a new Matrix object with given dimensions and possibly user defined allocator of the matrix values. More... | |
IndexType | getAllocatedElementsCount () const |
Tells the number of allocated matrix elements. More... | |
__cuda_callable__ IndexType | getColumns () const |
Returns number of matrix columns. More... | |
virtual IndexType | getNonzeroElementsCount () const |
Computes a current number of nonzero matrix elements. More... | |
__cuda_callable__ IndexType | getRows () const |
Returns number of matrix rows. More... | |
ValuesType & | getValues () |
Returns a reference to a vector with the matrix elements values. More... | |
const ValuesType & | getValues () const |
Returns a constant reference to a vector with the matrix elements values. More... | |
void | load (File &file) override |
Method for loading the matrix from a file. More... | |
template<typename Matrix > | |
bool | operator!= (const Matrix &matrix) const |
Comparison operator with another arbitrary matrix type. More... | |
template<typename MatrixT > | |
bool | operator!= (const MatrixT &matrix) const |
template<typename Matrix > | |
bool | operator== (const Matrix &matrix) const |
Comparison operator with another arbitrary matrix type. More... | |
template<typename MatrixT > | |
bool | operator== (const MatrixT &matrix) const |
virtual void | print (std::ostream &str) const |
Method for printing the matrix to output stream. More... | |
void | reset () |
Reset the matrix. More... | |
void | save (File &file) const override |
Method for saving the matrix to a file. More... | |
virtual void | setDimensions (IndexType rows, IndexType columns) |
Method for setting or changing of the matrix dimensions. More... | |
template<typename Matrix_ > | |
void | setLike (const Matrix_ &matrix) |
Set the matrix dimensions to be equal to those of the input matrix. More... | |
![]() | |
virtual | ~Object ()=default |
Destructor. More... | |
virtual std::string | getSerializationTypeVirtual () const |
void | load (const String &fileName) |
Method for restoring the object from a file. More... | |
virtual void | load (File &file) |
Method for restoring the object from a file. More... | |
void | save (const String &fileName) const |
Method for saving the object to a file as a binary data. More... | |
virtual void | save (File &file) const |
Method for saving the object to a file as a binary data. More... | |
Protected Attributes | |
IndexType | columns |
IndexType | rows |
ValuesType | values |
Array containing the allocated matrix elements. | |
Additional Inherited Members | |
![]() | |
static std::string | getSerializationType () |
Static serialization type getter. More... | |
Base class for other matrix types.
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. |
RealAllocator | is allocator for the matrix elements values. |
using TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::ConstViewType = typename MatrixView< Real, Device, Index >::ConstViewType |
Type of base matrix view for constant instances.
using TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::ViewType = MatrixView< Real, Device, Index > |
Type of base matrix view.
TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::Matrix | ( | const RealAllocatorType & | allocator = RealAllocatorType() | ) |
Construct a new Matrix object possibly with user defined allocator of the matrix values.
allocator | is is a user defined allocator of the matrix values. |
TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::Matrix | ( | IndexType | rows, |
IndexType | columns, | ||
const RealAllocatorType & | allocator = RealAllocatorType() |
||
) |
Construct a new Matrix object with given dimensions and possibly user defined allocator of the matrix values.
rows | is a number of matrix rows. |
columns | is a number of matrix columns. |
allocator | is a user defined allocator of the matrix values. |
Index TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::getAllocatedElementsCount |
Tells the number of allocated matrix elements.
In the case of dense matrices, this is just product of the number of rows and the number of columns. But for other matrix types like sparse matrices, this can be different.
__cuda_callable__ Index TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::getColumns |
Returns number of matrix columns.
|
virtual |
Computes a current number of nonzero matrix elements.
Reimplemented in TNL::Matrices::DenseMatrix< Real, Device, Index, Organization, RealAllocator >, TNL::Matrices::DenseMatrix< GlobalIndexType, TNL::Devices::Host, int >, TNL::Matrices::DenseMatrix< RealType, Devices::Sequential, IndexType >, TNL::Matrices::MultidiagonalMatrix< Real, Device, Index, Organization, RealAllocator, IndexAllocator >, TNL::Matrices::Sandbox::SparseSandboxMatrix< Real, Device, Index, MatrixType, RealAllocator, IndexAllocator >, TNL::Matrices::SparseMatrix< Real, Device, Index, MatrixType, Segments, ComputeReal, RealAllocator, IndexAllocator >, TNL::Matrices::SparseMatrix< RealType, DeviceType, IndexType, Matrices::GeneralMatrix, Algorithms::Segments::CSRScalar >, TNL::Matrices::SparseMatrix< TNL::Real, TNL::Devices::Host, IndexType, TNL::Matrices::GeneralMatrix, TNL::Algorithms::Segments::CSR >, and TNL::Matrices::TridiagonalMatrix< Real, Device, Index, Organization, RealAllocator >.
__cuda_callable__ Index TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::getRows |
Returns number of matrix rows.
auto TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::getValues |
Returns a reference to a vector with the matrix elements values.
auto TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::getValues |
Returns a constant reference to a vector with the matrix elements values.
|
overridevirtual |
Method for loading the matrix from a file.
file | is the input file. |
Reimplemented from TNL::Object.
Reimplemented in TNL::Matrices::DenseMatrix< GlobalIndexType, TNL::Devices::Host, int >, TNL::Matrices::DenseMatrix< RealType, Devices::Sequential, IndexType >, TNL::Matrices::MultidiagonalMatrix< Real, Device, Index, Organization, RealAllocator, IndexAllocator >, TNL::Matrices::Sandbox::SparseSandboxMatrix< Real, Device, Index, MatrixType, RealAllocator, IndexAllocator >, TNL::Matrices::SparseMatrix< Real, Device, Index, MatrixType, Segments, ComputeReal, RealAllocator, IndexAllocator >, TNL::Matrices::SparseMatrix< RealType, DeviceType, IndexType, Matrices::GeneralMatrix, Algorithms::Segments::CSRScalar >, TNL::Matrices::SparseMatrix< TNL::Real, TNL::Devices::Host, IndexType, TNL::Matrices::GeneralMatrix, TNL::Algorithms::Segments::CSR >, and TNL::Matrices::TridiagonalMatrix< Real, Device, Index, Organization, RealAllocator >.
bool TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::operator!= | ( | const Matrix< Real, Device, Index, RealAllocator > & | matrix | ) | const |
Comparison operator with another arbitrary matrix type.
matrix | is the right-hand side matrix. |
bool TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::operator== | ( | const Matrix< Real, Device, Index, RealAllocator > & | matrix | ) | const |
Comparison operator with another arbitrary matrix type.
matrix | is the right-hand side matrix. |
|
virtual |
Method for printing the matrix to output stream.
str | is the output stream. |
Reimplemented in TNL::Matrices::DenseMatrix< Real, Device, Index, Organization, RealAllocator >, TNL::Matrices::DenseMatrix< GlobalIndexType, TNL::Devices::Host, int >, TNL::Matrices::DenseMatrix< RealType, Devices::Sequential, IndexType >, TNL::Matrices::MultidiagonalMatrix< Real, Device, Index, Organization, RealAllocator, IndexAllocator >, TNL::Matrices::Sandbox::SparseSandboxMatrix< Real, Device, Index, MatrixType, RealAllocator, IndexAllocator >, TNL::Matrices::SparseMatrix< Real, Device, Index, MatrixType, Segments, ComputeReal, RealAllocator, IndexAllocator >, TNL::Matrices::SparseMatrix< RealType, DeviceType, IndexType, Matrices::GeneralMatrix, Algorithms::Segments::CSRScalar >, TNL::Matrices::SparseMatrix< TNL::Real, TNL::Devices::Host, IndexType, TNL::Matrices::GeneralMatrix, TNL::Algorithms::Segments::CSR >, and TNL::Matrices::TridiagonalMatrix< Real, Device, Index, Organization, RealAllocator >.
void TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::reset |
Reset the matrix.
The matrix dimensions are set to zero and all matrix elements are freed from the memrory.
|
overridevirtual |
Method for saving the matrix to a file.
file | is the output file. |
Reimplemented from TNL::Object.
Reimplemented in TNL::Matrices::DenseMatrix< GlobalIndexType, TNL::Devices::Host, int >, TNL::Matrices::DenseMatrix< RealType, Devices::Sequential, IndexType >, TNL::Matrices::MultidiagonalMatrix< Real, Device, Index, Organization, RealAllocator, IndexAllocator >, TNL::Matrices::Sandbox::SparseSandboxMatrix< Real, Device, Index, MatrixType, RealAllocator, IndexAllocator >, TNL::Matrices::SparseMatrix< Real, Device, Index, MatrixType, Segments, ComputeReal, RealAllocator, IndexAllocator >, TNL::Matrices::SparseMatrix< RealType, DeviceType, IndexType, Matrices::GeneralMatrix, Algorithms::Segments::CSRScalar >, TNL::Matrices::SparseMatrix< TNL::Real, TNL::Devices::Host, IndexType, TNL::Matrices::GeneralMatrix, TNL::Algorithms::Segments::CSR >, and TNL::Matrices::TridiagonalMatrix< Real, Device, Index, Organization, RealAllocator >.
|
virtual |
Method for setting or changing of the matrix dimensions.
rows | is a number of matrix rows. |
columns | is a number of matrix columns. |
Reimplemented in TNL::Matrices::DenseMatrix< Real, Device, Index, Organization, RealAllocator >, TNL::Matrices::DenseMatrix< GlobalIndexType, TNL::Devices::Host, int >, TNL::Matrices::DenseMatrix< RealType, Devices::Sequential, IndexType >, TNL::Matrices::Sandbox::SparseSandboxMatrix< Real, Device, Index, MatrixType, RealAllocator, IndexAllocator >, TNL::Matrices::SparseMatrix< Real, Device, Index, MatrixType, Segments, ComputeReal, RealAllocator, IndexAllocator >, TNL::Matrices::SparseMatrix< RealType, DeviceType, IndexType, Matrices::GeneralMatrix, Algorithms::Segments::CSRScalar >, TNL::Matrices::SparseMatrix< TNL::Real, TNL::Devices::Host, IndexType, TNL::Matrices::GeneralMatrix, TNL::Algorithms::Segments::CSR >, and TNL::Matrices::TridiagonalMatrix< Real, Device, Index, Organization, RealAllocator >.
void TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::setLike | ( | const Matrix_ & | matrix | ) |
Set the matrix dimensions to be equal to those of the input matrix.
Matrix_ | is a type if the input matrix. |
matrix | is an instance of the matrix. |