NeoN
A framework for CFD software
Loading...
Searching...
No Matches
NeoN::la::Matrix< ValueType, SparsityType > Class Template Reference

Sparse matrix class with compact storage by row (CSR) format. More...

#include <matrix.hpp>

Inheritance diagram for NeoN::la::Matrix< ValueType, SparsityType >:
NeoN::SupportsCopyTo< Matrix< ValueType, SparsityType > >

Public Types

using MatrixValueType = ValueType
using MatrixSparsityType = SparsityType

Public Member Functions

 Matrix (const Vector< ValueType > &values, std::shared_ptr< const SparsityType > sp)
 Constructor for Matrix.
 Matrix (const Vector< ValueType > &values, const Vector< typename SparsityType::SparsityIndexType > &colIdxs, const Vector< typename SparsityType::SparsityIndexType > &rowOffs, Dimensions dimensions)
 Constructor for Matrix.
 Matrix (const Vector< ValueType > &values, std::shared_ptr< const SparsityType > sparsity, std::shared_ptr< const FaceToMatrixAddress > faceToMatrixAddress)
 Constructor for Matrix with a FaceToMatrixAddress.
 ~Matrix ()=default
 Default destructor.
const Executor & exec () const
 Get the executor associated with this matrix.
localIdx nRows () const
 Get the number of rows in the matrix.
localIdx nNonZeros () const
 Get the number of non-zero values in the matrix.
void reset ()
Vector< ValueType > & values ()
 Get a reference to values vector.
const Vector< typename SparsityType::SparsityIndexType > & colIdxs () const
 Get a reference to column indices vector.
const Vector< typename SparsityType::SparsityIndexType > & rowOffs () const
 Get a reference to row offset vector.
const Vector< ValueType > & values () const
 Get a const reference to values vector.
Matrix< ValueType, SparsityType > copyToExecutor (Executor dstExec) const override
 Copy the matrix to another executor.
std::shared_ptr< const SparsityType > sparsity () const
 Get a reference to column indices vector.
std::shared_ptr< const FaceToMatrixAddress > faceToMatrixAddress () const
 Get the FaceToMatrixAddress associated with this matrix (may be null).
MatrixView< ValueType, SparsityView< typename SparsityType::SparsityIndexType > > view ()
 Get a view representation of the matrix's data.
MatrixView< const ValueType, SparsityView< typename SparsityType::SparsityIndexType > > view () const
 Get a const view representation of the matrix's data.
Vector< ValueType > diag () const
 extract the diagonal of the matrix
Public Member Functions inherited from NeoN::SupportsCopyTo< Matrix< ValueType, SparsityType > >
virtual ~SupportsCopyTo ()=default
Matrix< ValueType, SparsityType > copyToHost () const

Detailed Description

template<typename ValueType, typename SparsityType>
class NeoN::la::Matrix< ValueType, SparsityType >

Sparse matrix class with compact storage by row (CSR) format.

Template Parameters
ValueTypeThe value type of the non-zero entries.
IndexTypeThe index type of the rows and columns.

Definition at line 71 of file matrix.hpp.

Member Typedef Documentation

◆ MatrixSparsityType

template<typename ValueType, typename SparsityType>
using NeoN::la::Matrix< ValueType, SparsityType >::MatrixSparsityType = SparsityType

Definition at line 87 of file matrix.hpp.

◆ MatrixValueType

template<typename ValueType, typename SparsityType>
using NeoN::la::Matrix< ValueType, SparsityType >::MatrixValueType = ValueType

Definition at line 86 of file matrix.hpp.

Constructor & Destructor Documentation

◆ Matrix() [1/3]

template<typename ValueType, typename SparsityType>
NeoN::la::Matrix< ValueType, SparsityType >::Matrix ( const Vector< ValueType > & values,
std::shared_ptr< const SparsityType > sp )
inline

Constructor for Matrix.

Parameters
valuesThe non-zero values of the matrix.
spThe sparsity pattern of the matrix

Definition at line 94 of file matrix.hpp.

◆ Matrix() [2/3]

template<typename ValueType, typename SparsityType>
NeoN::la::Matrix< ValueType, SparsityType >::Matrix ( const Vector< ValueType > & values,
const Vector< typename SparsityType::SparsityIndexType > & colIdxs,
const Vector< typename SparsityType::SparsityIndexType > & rowOffs,
Dimensions dimensions )
inline

Constructor for Matrix.

Parameters
valuesThe non-zero values of the matrix.
colIdxsThe column indices for each non-zero value.
rowOffsThe starting index in values/colIdxs for each row.

Definition at line 106 of file matrix.hpp.

◆ Matrix() [3/3]

template<typename ValueType, typename SparsityType>
NeoN::la::Matrix< ValueType, SparsityType >::Matrix ( const Vector< ValueType > & values,
std::shared_ptr< const SparsityType > sparsity,
std::shared_ptr< const FaceToMatrixAddress > faceToMatrixAddress )
inline

Constructor for Matrix with a FaceToMatrixAddress.

The sparsity pattern and the face-to-matrix address are passed as independent objects. Only available for matrices whose index type is localIdx.

Parameters
valuesThe non-zero values of the matrix.
sparsityThe sparsity pattern of the matrix.
faceToMatrixAddressThe face-to-matrix address mapping.

Definition at line 130 of file matrix.hpp.

◆ ~Matrix()

template<typename ValueType, typename SparsityType>
NeoN::la::Matrix< ValueType, SparsityType >::~Matrix ( )
default

Default destructor.

Member Function Documentation

◆ colIdxs()

template<typename ValueType, typename SparsityType>
const Vector< typename SparsityType::SparsityIndexType > & NeoN::la::Matrix< ValueType, SparsityType >::colIdxs ( ) const
inlinenodiscard

Get a reference to column indices vector.

Returns
Vector containing the column indices.

Definition at line 177 of file matrix.hpp.

◆ copyToExecutor()

template<typename ValueType, typename SparsityType>
Matrix< ValueType, SparsityType > NeoN::la::Matrix< ValueType, SparsityType >::copyToExecutor ( Executor dstExec) const
nodiscardoverridevirtual

Copy the matrix to another executor.

Parameters
dstExecThe destination executor.
Returns
A copy of the matrix on the destination executor.

Implements NeoN::SupportsCopyTo< Matrix< ValueType, SparsityType > >.

◆ diag()

template<typename ValueType, typename SparsityType>
Vector< ValueType > NeoN::la::Matrix< ValueType, SparsityType >::diag ( ) const
nodiscard

extract the diagonal of the matrix

◆ exec()

template<typename ValueType, typename SparsityType>
const Executor & NeoN::la::Matrix< ValueType, SparsityType >::exec ( ) const
inlinenodiscard

Get the executor associated with this matrix.

Returns
Reference to the executor.

Definition at line 150 of file matrix.hpp.

◆ faceToMatrixAddress()

template<typename ValueType, typename SparsityType>
std::shared_ptr< const FaceToMatrixAddress > NeoN::la::Matrix< ValueType, SparsityType >::faceToMatrixAddress ( ) const
inlinenodiscard

Get the FaceToMatrixAddress associated with this matrix (may be null).

Definition at line 213 of file matrix.hpp.

◆ nNonZeros()

template<typename ValueType, typename SparsityType>
localIdx NeoN::la::Matrix< ValueType, SparsityType >::nNonZeros ( ) const
inlinenodiscard

Get the number of non-zero values in the matrix.

Returns
Number of non-zero values.

Definition at line 162 of file matrix.hpp.

◆ nRows()

template<typename ValueType, typename SparsityType>
localIdx NeoN::la::Matrix< ValueType, SparsityType >::nRows ( ) const
inlinenodiscard

Get the number of rows in the matrix.

Returns
Number of rows.

Definition at line 156 of file matrix.hpp.

◆ reset()

template<typename ValueType, typename SparsityType>
void NeoN::la::Matrix< ValueType, SparsityType >::reset ( )
inline

Definition at line 164 of file matrix.hpp.

◆ rowOffs()

template<typename ValueType, typename SparsityType>
const Vector< typename SparsityType::SparsityIndexType > & NeoN::la::Matrix< ValueType, SparsityType >::rowOffs ( ) const
inlinenodiscard

Get a reference to row offset vector.

Returns
Vector containing the row pointers.

Definition at line 186 of file matrix.hpp.

◆ sparsity()

template<typename ValueType, typename SparsityType>
std::shared_ptr< const SparsityType > NeoN::la::Matrix< ValueType, SparsityType >::sparsity ( ) const
inlinenodiscard

Get a reference to column indices vector.

Returns
Vector containing the column indices.

Definition at line 208 of file matrix.hpp.

◆ values() [1/2]

template<typename ValueType, typename SparsityType>
Vector< ValueType > & NeoN::la::Matrix< ValueType, SparsityType >::values ( )
inlinenodiscard

Get a reference to values vector.

Returns
Vector containing the matrix values.

Definition at line 171 of file matrix.hpp.

◆ values() [2/2]

template<typename ValueType, typename SparsityType>
const Vector< ValueType > & NeoN::la::Matrix< ValueType, SparsityType >::values ( ) const
inlinenodiscard

Get a const reference to values vector.

Returns
Const vector containing the matrix values.

Definition at line 195 of file matrix.hpp.

◆ view() [1/2]

template<typename ValueType, typename SparsityType>
MatrixView< ValueType, SparsityView< typename SparsityType::SparsityIndexType > > NeoN::la::Matrix< ValueType, SparsityType >::view ( )
inlinenodiscard

Get a view representation of the matrix's data.

Returns
MatrixView for easy access to matrix elements.

Definition at line 223 of file matrix.hpp.

◆ view() [2/2]

template<typename ValueType, typename SparsityType>
MatrixView< const ValueType, SparsityView< typename SparsityType::SparsityIndexType > > NeoN::la::Matrix< ValueType, SparsityType >::view ( ) const
inlinenodiscard

Get a const view representation of the matrix's data.

Returns
Const MatrixView for read-only access to matrix elements.

Definition at line 237 of file matrix.hpp.


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