Template Numerical Library: TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization > Class Template Reference

Template Numerical Library version\ main:c7077e4fd

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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>`

Inheritance diagram for TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >:
[legend]
Collaboration diagram for TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >:
[legend]

## 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.
__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.
__cuda_callable__ MatrixBase & | operator= (const MatrixBase &)=delete
| Copy-assignment operator.
__cuda_callable__ MatrixBase & | operator= (MatrixBase &&)=delete
| Move-assignment operator.

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

  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.

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

  rows | is a number of matrix rows.
  columns | is a number of matrix columns.
  values | is 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

  view | is 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

  view | is 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>

IndexType 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__ IndexType TNL::Matrices::MatrixBase< Real, Device, Index, MatrixType, Organization >::getColumns | ( |  | ) | const
| nodiscard

Returns number of matrix columns.

Returns
  number of matrix columns.

## ◆ getOrganization()

template<typename Real, typename Device, typename Index, typename MatrixType, ElementsOrganization Organization>

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__ IndexType 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__ 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 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>

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>

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>

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

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

- src/TNL/Matrices/MatrixBase.h