NeoN
A framework for CFD software
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
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 Executorexec () 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 FaceToMatrixAddressfaceToMatrixAddress () 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 70 of file matrix.hpp.

Member Typedef Documentation

◆ MatrixSparsityType

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

Definition at line 83 of file matrix.hpp.

◆ MatrixValueType

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

Definition at line 82 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 90 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 102 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 126 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
inline

Get a reference to column indices vector.

Returns
Vector containing the column indices.

Definition at line 173 of file matrix.hpp.

◆ copyToExecutor()

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

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

extract the diagonal of the matrix

◆ exec()

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

Get the executor associated with this matrix.

Returns
Reference to the executor.

Definition at line 146 of file matrix.hpp.

◆ faceToMatrixAddress()

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

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

Definition at line 209 of file matrix.hpp.

◆ nNonZeros()

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

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

Returns
Number of non-zero values.

Definition at line 158 of file matrix.hpp.

◆ nRows()

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

Get the number of rows in the matrix.

Returns
Number of rows.

Definition at line 152 of file matrix.hpp.

◆ reset()

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

Definition at line 160 of file matrix.hpp.

◆ rowOffs()

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

Get a reference to row offset vector.

Returns
Vector containing the row pointers.

Definition at line 182 of file matrix.hpp.

◆ sparsity()

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

Get a reference to column indices vector.

Returns
Vector containing the column indices.

Definition at line 204 of file matrix.hpp.

◆ values() [1/2]

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

Get a reference to values vector.

Returns
Vector containing the matrix values.

Definition at line 167 of file matrix.hpp.

◆ values() [2/2]

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

Get a const reference to values vector.

Returns
Const vector containing the matrix values.

Definition at line 191 of file matrix.hpp.

◆ view() [1/2]

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

Get a view representation of the matrix's data.

Returns
MatrixView for easy access to matrix elements.

Definition at line 219 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
inline

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

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

Definition at line 233 of file matrix.hpp.


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