Template Numerical Library version\ main:4e58ea6
Loading...
Searching...
No Matches
TNL::Matrices::HypreCSRMatrix Class Reference

Wrapper for Hypre's sequential CSR matrix. More...

#include <TNL/Matrices/HypreCSRMatrix.h>

Public Types

using ColumnIndexesVectorType = Containers::Vector< IndexType, DeviceType, IndexType >
 
using ColumnIndexesViewType = typename ColumnIndexesVectorType::ViewType
 
using ConstColumnIndexesViewType = typename ColumnIndexesVectorType::ConstViewType
 
using ConstSegmentsViewType = Algorithms::Segments::CSRView< DeviceType, std::add_const_t< IndexType > >
 
using ConstValuesViewType = typename ValuesViewType::ConstViewType
 
using ConstViewType = typename MatrixType::ConstViewType
 
using DeviceType = HYPRE_Device
 
using IndexType = HYPRE_Int
 
using MatrixType = SparseMatrix< RealType, DeviceType, IndexType, GeneralMatrix, Algorithms::Segments::CSR >
 
using RealType = HYPRE_Real
 
using SegmentsViewType = Algorithms::Segments::CSRView< DeviceType, IndexType >
 
using ValuesViewType = Containers::VectorView< RealType, DeviceType, IndexType >
 
using ValueType = RealType
 
using ViewType = typename MatrixType::ViewType
 

Public Member Functions

 HypreCSRMatrix (const HypreCSRMatrix &other)=delete
 
 HypreCSRMatrix (hypre_CSRMatrix *handle, bool take_ownership=true)
 Convert Hypre's format to HypreCSRMatrix.
 
 HypreCSRMatrix (HypreCSRMatrix &&other) noexcept
 
 HypreCSRMatrix (IndexType rows, IndexType columns, ValuesViewType values, ColumnIndexesViewType columnIndexes, ColumnIndexesViewType rowOffsets)
 
 HypreCSRMatrix (ViewType view)
 
void bind (hypre_CSRMatrix *handle, bool take_ownership=true)
 Convert Hypre's format to HypreCSRMatrix.
 
void bind (HypreCSRMatrix &matrix)
 
void bind (IndexType rows, IndexType columns, ValuesViewType values, ColumnIndexesViewType columnIndexes, ColumnIndexesViewType rowOffsets)
 Drop previously set data (deallocate if the matrix was the owner) and bind to the given data (i.e., the matrix does not become the owner).
 
void bind (MatrixType &matrix)
 
void bind (ViewType view)
 
ColumnIndexesViewType getColumnIndexes ()
 
ConstColumnIndexesViewType getColumnIndexes () const
 
IndexType getColumns () const
 
ConstViewType getConstView () const
 
IndexType getNonzeroElementsCount () const
 
ColumnIndexesViewType getRowOffsets ()
 
ConstColumnIndexesViewType getRowOffsets () const
 
IndexType getRows () const
 
SegmentsViewType getSegments ()
 
ConstSegmentsViewType getSegments () const
 
ValuesViewType getValues ()
 
ConstValuesViewType getValues () const
 
ViewType getView ()
 
 operator const hypre_CSRMatrix * () const noexcept
 
 operator HYPRE_CSRMatrix () noexcept
 
 operator hypre_CSRMatrix * () noexcept
 
HypreCSRMatrixoperator= (const HypreCSRMatrix &other)=delete
 
HypreCSRMatrixoperator= (HypreCSRMatrix &&other) noexcept
 
void reorderDiagonalEntries ()
 Reorders the column and data arrays of a square matrix, such that the first entry in each row is the diagonal one.
 
void reset ()
 Reset the matrix to empty state.
 
void setDimensions (IndexType rows, IndexType cols)
 Set the new matrix dimensions.
 
template<typename RowCapacitiesVector >
void setRowCapacities (const RowCapacitiesVector &rowCapacities)
 
template<typename InVector , typename OutVector >
void vectorProduct (const InVector &inVector, OutVector &outVector, RealType matrixMultiplicator=1.0, RealType outVectorMultiplicator=0.0, IndexType begin=0, IndexType end=0) const
 

Protected Attributes

hypre_CSRMatrix * m = nullptr
 
bool owns_handle = true
 

Detailed Description

Constructor & Destructor Documentation

◆ HypreCSRMatrix()

TNL::Matrices::HypreCSRMatrix::HypreCSRMatrix ( hypre_CSRMatrix * handle,
bool take_ownership = true )
inlineexplicit

Convert Hypre's format to HypreCSRMatrix.

Parameters
handleis the Hypre vector handle.
take_ownershipindicates if the matrix should take ownership of the handle, i.e. whether to call hypre_CSRMatrixDestroy when it does not need it anymore.

Member Function Documentation

◆ bind()

void TNL::Matrices::HypreCSRMatrix::bind ( hypre_CSRMatrix * handle,
bool take_ownership = true )
inline

Convert Hypre's format to HypreCSRMatrix.

Parameters
handleis the Hypre vector handle.
take_ownershipindicates if the matrix should take ownership of the handle, i.e. whether to call hypre_CSRMatrixDestroy when it does not need it anymore.

◆ reorderDiagonalEntries()

void TNL::Matrices::HypreCSRMatrix::reorderDiagonalEntries ( )
inline

Reorders the column and data arrays of a square matrix, such that the first entry in each row is the diagonal one.

Note that the hypre_CSRMatrixReorder function only swaps the diagonal and first entries in the row, but this function also shifts the subdiagonal entries to ensure that the column indices (except for the diagonal one) remain in the original order.

◆ setDimensions()

void TNL::Matrices::HypreCSRMatrix::setDimensions ( IndexType rows,
IndexType cols )
inline

Set the new matrix dimensions.

  • if the matrix previously owned data, they are deallocated
  • new size is set
  • the matrix is initialized with hypre_CSRMatrixInitialize (i.e., data are allocated)

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