Template Numerical Library version main:e6bb26f
Public Types | Public Member Functions | Protected Attributes | List of all members
TNL::Matrices::Matrix< Real, Device, Index, RealAllocator > Class Template Reference

Base class for other matrix types. More...

#include <TNL/Matrices/Matrix.h>

Inheritance diagram for TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >:
Inheritance graph
[legend]
Collaboration diagram for TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >:
Collaboration graph
[legend]

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.
 
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.
 

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...
 
ValuesTypegetValues ()
 Returns a reference to a vector with the matrix elements values. More...
 
const ValuesTypegetValues () 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...
 
- Public Member Functions inherited from TNL::Object
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 Public Member Functions inherited from TNL::Object
static std::string getSerializationType ()
 Static serialization type getter. More...
 

Detailed Description

template<typename Real = double, typename Device = Devices::Host, typename Index = int, typename RealAllocator = typename Allocators::Default< Device >::template Allocator< std::remove_const_t< Real > >>
class TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >

Base class for other 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.
RealAllocatoris allocator for the matrix elements values.

Constructor & Destructor Documentation

◆ Matrix() [1/2]

template<typename Real , typename Device , typename Index , typename RealAllocator >
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.

Parameters
allocatoris is a user defined allocator of the matrix values.

◆ Matrix() [2/2]

template<typename Real , typename Device , typename Index , typename RealAllocator >
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.

Parameters
rowsis a number of matrix rows.
columnsis a number of matrix columns.
allocatoris a user defined allocator of the matrix values.

Member Function Documentation

◆ getAllocatedElementsCount()

template<typename Real , typename Device , typename Index , typename RealAllocator >
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.

Returns
Number of allocated matrix elements.

◆ getColumns()

template<typename Real , typename Device , typename Index , typename RealAllocator >
__cuda_callable__ Index TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::getColumns

Returns number of matrix columns.

Returns
number of matrix columns.

◆ getNonzeroElementsCount()

template<typename Real , typename Device , typename Index , typename RealAllocator >
Index TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::getNonzeroElementsCount
virtual

◆ getRows()

template<typename Real , typename Device , typename Index , typename RealAllocator >
__cuda_callable__ Index TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::getRows

Returns number of matrix rows.

Returns
number of matrix row.

◆ getValues() [1/2]

template<typename Real , typename Device , typename Index , typename RealAllocator >
auto TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::getValues

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 RealAllocator >
auto TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::getValues

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

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

◆ load()

template<typename Real , typename Device , typename Index , typename RealAllocator >
void TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::load ( File file)
overridevirtual

◆ operator!=()

template<typename Real = double, typename Device = Devices::Host, typename Index = int, typename RealAllocator = typename Allocators::Default< Device >::template Allocator< std::remove_const_t< Real > >>
template<typename 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.

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

◆ operator==()

template<typename Real = double, typename Device = Devices::Host, typename Index = int, typename RealAllocator = typename Allocators::Default< Device >::template Allocator< std::remove_const_t< Real > >>
template<typename 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.

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

◆ print()

template<typename Real , typename Device , typename Index , typename RealAllocator >
void TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::print ( std::ostream str) const
virtual

◆ reset()

template<typename Real , typename Device , typename Index , typename 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.

◆ save()

template<typename Real , typename Device , typename Index , typename RealAllocator >
void TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::save ( File file) const
overridevirtual

◆ setDimensions()

template<typename Real , typename Device , typename Index , typename RealAllocator >
void TNL::Matrices::Matrix< Real, Device, Index, RealAllocator >::setDimensions ( IndexType  rows,
IndexType  columns 
)
virtual

◆ setLike()

template<typename Real , typename Device , typename Index , typename RealAllocator >
template<typename Matrix_ >
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.

Template Parameters
Matrix_is a type if the input matrix.
Parameters
matrixis an instance of the matrix.

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