Template Numerical Library version\ main:bb09b17
Loading...
Searching...
No Matches
TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization > Class Template Reference

Base class for the implementation of concrete matrix types. More...

#include <TNL/Matrices/MatrixBase.h>

Collaboration diagram for TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >:

Public Types

using ConstValuesViewType = typename ValuesViewType::ConstViewType
 Type of constant vector view holding values of matrix elements.
 
using DeviceType = Device
 The device where the matrix is allocated.
 
using IndexType = Index
 The type used for matrix elements indexing.
 
using RealType = std::remove_const_t< Real >
 The type of matrix elements.
 
using RowCapacitiesType = Containers::Vector< Index, Device, Index >
 
using ValuesViewType = Containers::VectorView< Real, Device, Index >
 Type of vector view holding values of matrix elements.
 

Public Member Functions

__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.
 
virtual IndexType getNonzeroElementsCount () const
 Computes a current number of nonzero matrix elements.
 
__cuda_callable__ IndexType getRows () const
 Returns number of matrix rows.
 
__cuda_callable__ ValuesViewTypegetValues ()
 Returns a reference to a vector with the matrix elements values.
 
__cuda_callable__ const ValuesViewTypegetValues () const
 Returns a constant reference to a vector with the matrix elements values.
 
template<typename Matrix >
bool operator!= (const Matrix &matrix) const
 Comparison operator with another arbitrary matrix view type.
 
template<typename MatrixT >
bool operator!= (const MatrixT &matrix) const
 
__cuda_callable__ MatrixBaseoperator= (const MatrixBase &)=delete
 Copy-assignment operator.
 
__cuda_callable__ MatrixBaseoperator= (MatrixBase &&)=delete
 Move-assignment operator.
 
template<typename Matrix >
bool operator== (const Matrix &matrix) const
 Comparison operator with another arbitrary matrix view type.
 
template<typename MatrixT >
bool operator== (const MatrixT &matrix) const
 

Static Public Member Functions

static constexpr ElementsOrganization getOrganization ()
 Matrix elements organization getter.
 
static constexpr bool isBinary ()
 Test of binary matrix type.
 
static constexpr bool isSymmetric ()
 Test of symmetric matrix type.
 

Protected Member Functions

__cuda_callable__ void bind (IndexType rows, IndexType columns, ValuesViewType values)
 Re-initializes the internal attributes of the base class.
 

Protected Attributes

IndexType columns = 0
 
IndexType rows = 0
 
ValuesViewType values
 

Detailed Description

template<typename Real, typename Device, typename Index, typename MatrixType, ElementsOrganization Organization>
class TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >

Base class for the implementation of concrete matrix types.

Template Parameters
Realis a type of matrix elements.
Deviceis a device where the matrix is allocated.
Indexis a type for indexing of the matrix elements.

Constructor & Destructor Documentation

◆ MatrixBase() [1/3]

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
__cuda_callable__ TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::MatrixBase ( IndexType rows,
IndexType columns,
ValuesViewType values )

Constructor with matrix dimensions and matrix elements values.

The matrix elements values are passed in a form vector view.

Parameters
rowsis a number of matrix rows.
columnsis a number of matrix columns.
valuesis a vector view with matrix elements values.

◆ MatrixBase() [2/3]

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
__cuda_callable__ TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::MatrixBase ( const MatrixBase< Real, Device, Index, MatrixType, Organization > & view)
default

Shallow copy constructor.

Parameters
viewis an input matrix view.

◆ MatrixBase() [3/3]

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
__cuda_callable__ TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::MatrixBase ( MatrixBase< Real, Device, Index, MatrixType, Organization > && view)
defaultnoexcept

Move constructor.

Parameters
viewis an input matrix view.

Member Function Documentation

◆ bind()

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
__cuda_callable__ void TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::bind ( IndexType rows,
IndexType columns,
ValuesViewType values )
protected

Re-initializes the internal attributes of the base class.

Note that this function is protected to ensure that the user cannot modify the base class of a matrix. For the same reason, in future code development we also need to make sure that all non-const functions in the base class return by value and not by reference.

◆ getAllocatedElementsCount()

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
Index TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::getAllocatedElementsCount ( ) const
nodiscard

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.

Returns
Number of allocated matrix elements.

◆ getColumns()

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
__cuda_callable__ Index TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::getColumns ( ) const
nodiscard

Returns number of matrix columns.

Returns
number of matrix columns.

◆ getNonzeroElementsCount()

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
Index TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::getNonzeroElementsCount ( ) const
nodiscardvirtual

Computes a current number of nonzero matrix elements.

Returns
number of nonzero matrix elements.

Reimplemented in TNL::Matrices::MultidiagonalMatrixBase< Real, Device, Index, Organization >, TNL::Matrices::MultidiagonalMatrixBase< double, Devices::Host, int, Algorithms::Segments::DefaultElementsOrganization< Devices::Host >::getOrganization() >, TNL::Matrices::Sandbox::SparseSandboxMatrixView< Real, Device, Index, MatrixType >, TNL::Matrices::Sandbox::SparseSandboxMatrixView< double, Devices::Host, int, GeneralMatrix >, TNL::Matrices::SparseMatrixBase< Real, Device, Index, MatrixType, SegmentsView, ComputeReal >, TNL::Matrices::SparseMatrixBase< double, Devices::Host, int, GeneralMatrix, Algorithms::Segments::CSR< Devices::Host, int, typename Allocators::Default< Devices::Host >::template Allocator< int > >::ViewType, typename ChooseSparseMatrixComputeReal< double, int >::type >, TNL::Matrices::SparseMatrixBase< Real, Devices::Host, int, GeneralMatrix, std::conditional_t< std::is_const_v< Real >, Algorithms::Segments::CSRView< Devices::Host, int >::ConstViewType, Algorithms::Segments::CSRView< Devices::Host, int > >, typename ChooseSparseMatrixComputeReal< Real, int >::type >, TNL::Matrices::SparseMatrixBase< Real, TNL::Devices::Host, IndexType, TNL::Matrices::GeneralMatrix, Segments< TNL::Devices::Host, IndexType, typename Allocators::Default< TNL::Devices::Host >::template Allocator< IndexType > >::ViewType, typename ChooseSparseMatrixComputeReal< Real, IndexType >::type >, TNL::Matrices::SparseMatrixBase< RealType, DeviceType, IndexType, Matrices::GeneralMatrix, Segments< DeviceType, IndexType, typename Allocators::Default< DeviceType >::template Allocator< IndexType > >::ViewType, typename ChooseSparseMatrixComputeReal< RealType, IndexType >::type >, TNL::Matrices::TridiagonalMatrixBase< Real, Device, Index, Organization >, and TNL::Matrices::TridiagonalMatrixBase< double, Devices::Host, int, Algorithms::Segments::DefaultElementsOrganization< Devices::Host >::getOrganization() >.

◆ getOrganization()

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
static constexpr ElementsOrganization TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::getOrganization ( )
inlinestaticnodiscardconstexpr

Matrix elements organization getter.

Returns
matrix elements organization - RowMajorOrder of ColumnMajorOrder.

◆ getRows()

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
__cuda_callable__ Index TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::getRows ( ) const
nodiscard

Returns number of matrix rows.

Returns
number of matrix row.

◆ getValues() [1/2]

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
__cuda_callable__ MatrixBase< Real, Device, Index, MatrixType, Organization >::ValuesViewType & TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::getValues ( )
nodiscard

Returns a reference to a vector with the matrix elements values.

Returns
constant reference to a vector with the matrix elements values.

◆ getValues() [2/2]

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
__cuda_callable__ const MatrixBase< Real, Device, Index, MatrixType, Organization >::ValuesViewType & TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::getValues ( ) const
nodiscard

Returns a constant reference to a vector with the matrix elements values.

Returns
constant reference to a vector with the matrix elements values.

◆ isBinary()

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
static constexpr bool TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::isBinary ( )
inlinestaticnodiscardconstexpr

Test of binary matrix type.

Returns
true if the matrix is stored as binary and false otherwise.

◆ isSymmetric()

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
static constexpr bool TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::isSymmetric ( )
inlinestaticnodiscardconstexpr

Test of symmetric matrix type.

Returns
true if the matrix is stored as symmetric and false otherwise.

◆ operator!=()

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
template<typename Matrix >
bool TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::operator!= ( const Matrix & matrix) const
nodiscard

Comparison operator with another arbitrary matrix view type.

Parameters
matrixis the right-hand side matrix.
Returns
true if the RHS matrix is equal, false otherwise.

◆ operator=()

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
__cuda_callable__ MatrixBase & TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::operator= ( const MatrixBase< Real, Device, Index, MatrixType, Organization > & )
delete

Copy-assignment operator.

It is a deleted function, because matrix assignment in general requires reallocation.

◆ operator==()

template<typename Real , typename Device , typename Index , typename MatrixType , ElementsOrganization Organization>
template<typename Matrix >
bool TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::operator== ( const Matrix & matrix) const
nodiscard

Comparison operator with another arbitrary matrix view type.

Parameters
matrixis the right-hand side matrix.
Returns
true if the RHS matrix is equal, false otherwise.

The documentation for this class was generated from the following files: