NeoN
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
Public Member Functions | List of all members
NeoN::la::CSRMatrix< ValueType, IndexType > Class Template Reference

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

#include <CSRMatrix.hpp>

Public Member Functions

 CSRMatrix (const Vector< ValueType > &values, const Vector< IndexType > &colIdxs, const Vector< IndexType > &rowOffs)
 Constructor for CSRMatrix.
 
 CSRMatrix (const Executor exec)
 
 ~CSRMatrix ()=default
 Default destructor.
 
const Executorexec () const
 Get the executor associated with this matrix.
 
IndexType nRows () const
 Get the number of rows in the matrix.
 
IndexType nNonZeros () const
 Get the number of non-zero values in the matrix.
 
Vector< ValueType > & values ()
 Get a span to the values array.
 
Vector< IndexType > & colIdxs ()
 Get a span to the column indices array.
 
Vector< IndexType > & rowPtrs ()
 Get a span to the row pointers array.
 
const Vector< ValueType > & values () const
 Get a const span to the values array.
 
const Vector< IndexType > & colIdxs () const
 Get a const span to the column indices array.
 
const Vector< IndexType > & rowPtrs () const
 Get a const span to the row pointers array.
 
CSRMatrix< ValueType, IndexType > copyToExecutor (Executor dstExec) const
 Copy the matrix to another executor.
 
CSRMatrix< ValueType, IndexType > copyToHost () const
 Copy the matrix to the host.
 
CSRMatrixView< ValueType, IndexType > view ()
 Get a view representation of the matrix's data.
 
const CSRMatrixView< const ValueType, const IndexType > view () const
 Get a const view representation of the matrix's data.
 

Detailed Description

template<typename ValueType, typename IndexType>
class NeoN::la::CSRMatrix< ValueType, IndexType >

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 83 of file CSRMatrix.hpp.

Constructor & Destructor Documentation

◆ CSRMatrix() [1/2]

template<typename ValueType , typename IndexType >
NeoN::la::CSRMatrix< ValueType, IndexType >::CSRMatrix ( const Vector< ValueType > &  values,
const Vector< IndexType > &  colIdxs,
const Vector< IndexType > &  rowOffs 
)
inline

Constructor for CSRMatrix.

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 94 of file CSRMatrix.hpp.

◆ CSRMatrix() [2/2]

template<typename ValueType , typename IndexType >
NeoN::la::CSRMatrix< ValueType, IndexType >::CSRMatrix ( const Executor  exec)
inline

Definition at line 105 of file CSRMatrix.hpp.

◆ ~CSRMatrix()

template<typename ValueType , typename IndexType >
NeoN::la::CSRMatrix< ValueType, IndexType >::~CSRMatrix ( )
default

Default destructor.

Member Function Documentation

◆ colIdxs() [1/2]

template<typename ValueType , typename IndexType >
Vector< IndexType > & NeoN::la::CSRMatrix< ValueType, IndexType >::colIdxs ( )
inline

Get a span to the column indices array.

Returns
Span containing the column indices.

Definition at line 144 of file CSRMatrix.hpp.

◆ colIdxs() [2/2]

template<typename ValueType , typename IndexType >
const Vector< IndexType > & NeoN::la::CSRMatrix< ValueType, IndexType >::colIdxs ( ) const
inline

Get a const span to the column indices array.

Returns
Const span containing the column indices.

Definition at line 162 of file CSRMatrix.hpp.

◆ copyToExecutor()

template<typename ValueType , typename IndexType >
CSRMatrix< ValueType, IndexType > NeoN::la::CSRMatrix< ValueType, IndexType >::copyToExecutor ( Executor  dstExec) const
inline

Copy the matrix to another executor.

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

Definition at line 175 of file CSRMatrix.hpp.

◆ copyToHost()

template<typename ValueType , typename IndexType >
CSRMatrix< ValueType, IndexType > NeoN::la::CSRMatrix< ValueType, IndexType >::copyToHost ( ) const
inline

Copy the matrix to the host.

Returns
A copy of the matrix on the host.

Definition at line 191 of file CSRMatrix.hpp.

◆ exec()

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

Get the executor associated with this matrix.

Returns
Reference to the executor.

Definition at line 116 of file CSRMatrix.hpp.

◆ nNonZeros()

template<typename ValueType , typename IndexType >
IndexType NeoN::la::CSRMatrix< ValueType, IndexType >::nNonZeros ( ) const
inline

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

Returns
Number of non-zero values.

Definition at line 132 of file CSRMatrix.hpp.

◆ nRows()

template<typename ValueType , typename IndexType >
IndexType NeoN::la::CSRMatrix< ValueType, IndexType >::nRows ( ) const
inline

Get the number of rows in the matrix.

Returns
Number of rows.

Definition at line 122 of file CSRMatrix.hpp.

◆ rowPtrs() [1/2]

template<typename ValueType , typename IndexType >
Vector< IndexType > & NeoN::la::CSRMatrix< ValueType, IndexType >::rowPtrs ( )
inline

Get a span to the row pointers array.

Returns
Span containing the row pointers.

Definition at line 150 of file CSRMatrix.hpp.

◆ rowPtrs() [2/2]

template<typename ValueType , typename IndexType >
const Vector< IndexType > & NeoN::la::CSRMatrix< ValueType, IndexType >::rowPtrs ( ) const
inline

Get a const span to the row pointers array.

Returns
Const span containing the row pointers.

Definition at line 168 of file CSRMatrix.hpp.

◆ values() [1/2]

template<typename ValueType , typename IndexType >
Vector< ValueType > & NeoN::la::CSRMatrix< ValueType, IndexType >::values ( )
inline

Get a span to the values array.

Returns
Span containing the matrix values.

Definition at line 138 of file CSRMatrix.hpp.

◆ values() [2/2]

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

Get a const span to the values array.

Returns
Const span containing the matrix values.

Definition at line 156 of file CSRMatrix.hpp.

◆ view() [1/2]

template<typename ValueType , typename IndexType >
CSRMatrixView< ValueType, IndexType > NeoN::la::CSRMatrix< ValueType, IndexType >::view ( )
inline

Get a view representation of the matrix's data.

Returns
CSRMatrixView for easy access to matrix elements.

Definition at line 200 of file CSRMatrix.hpp.

◆ view() [2/2]

template<typename ValueType , typename IndexType >
const CSRMatrixView< const ValueType, const IndexType > NeoN::la::CSRMatrix< ValueType, IndexType >::view ( ) const
inline

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

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

Definition at line 209 of file CSRMatrix.hpp.


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