Ginkgo: gko::matrix::Csr< ValueType, IndexType > Class Template Reference

| Ginkgo Generated from branch based on main. Ginkgo version 1.11.0 A numerical linear algebra library targeting many-core architectures

Loading...
Searching...
No Matches
gko::matrix::Csr< ValueType, IndexType > Class Template Reference
Linear Operators » SpMV employing different Matrix formats | Linear Operators

CSR is a matrix format which stores only the nonzero coefficients by compressing each row of the matrix (compressed sparse row format). More...

`#include <ginkgo/core/matrix/csr.hpp>`

Inheritance diagram for gko::matrix::Csr< ValueType, IndexType >:
[legend]
Collaboration diagram for gko::matrix::Csr< ValueType, IndexType >:
[legend]

## Classes
class | strategy_type
| strategy_type is to decide how to set the csr algorithm. More...
class | classical
| classical is a strategy_type which uses the same number of threads on each row. More...
class | merge_path
| merge_path is a strategy_type which uses the merge_path algorithm. More...
class | cusparse
| cusparse is a strategy_type which uses the sparselib csr. More...
class | sparselib
| sparselib is a strategy_type which uses the sparselib csr. More...
class | load_balance
| load_balance is a strategy_type which uses the load balance algorithm. More...
class | automatical
class | multiply_reuse_info
| Class describing the internal lookup structures created by multiply_reuse(const Csr*) to recompute a sparse matrix-matrix product with updated values. More...
class | multiply_add_reuse_info
| Class describing the internal lookup structures created by multiply_add_reuse to recompute a sparse matrix-matrix product with updated values. More...
class | scale_add_reuse_info
| Class describing the internal lookup structures created by scale_add_reuse to recompute a sparse matrix-matrix sum with updated values. More...
struct | permuting_reuse_info
| A struct describing a transformation of the matrix that reorders the values of the matrix into the transformed matrix. More...

## Public Types
using | value_type = ValueType
using | index_type = IndexType
using | transposed_type = Csr<ValueType, IndexType>
using | mat_data = matrix_data<ValueType, IndexType>
using | device_mat_data = device_matrix_data<ValueType, IndexType>
using | absolute_type = remove_complex<Csr>
Public Types inherited from gko::EnablePolymorphicAssignment< Csr< default_precision, int32 > >
using | result_type
Public Types inherited from gko::DiagonalExtractable< default_precision >
using | value_type
Public Types inherited from gko::ReadableFromMatrixData< default_precision, int32 >
using | value_type
using | index_type
Public Types inherited from gko::WritableToMatrixData< default_precision, int32 >
using | value_type
using | index_type
Public Types inherited from gko::EnableAbsoluteComputation< remove_complex< Csr< default_precision, int32 > > >
using | absolute_type

## Public Member Functions
void | convert_to (Csr< next_precision< ValueType >, IndexType > *result) const override
void | move_to (Csr< next_precision< ValueType >, IndexType > *result) override
void | convert_to (Dense< ValueType > *other) const override
void | move_to (Dense< ValueType > *other) override
void | convert_to (Coo< ValueType, IndexType > *result) const override
void | move_to (Coo< ValueType, IndexType > *result) override
void | convert_to (Ell< ValueType, IndexType > *result) const override
void | move_to (Ell< ValueType, IndexType > *result) override
void | convert_to (Fbcsr< ValueType, IndexType > *result) const override
void | move_to (Fbcsr< ValueType, IndexType > *result) override
void | convert_to (Hybrid< ValueType, IndexType > *result) const override
void | move_to (Hybrid< ValueType, IndexType > *result) override
void | convert_to (Sellp< ValueType, IndexType > *result) const override
void | move_to (Sellp< ValueType, IndexType > *result) override
void | convert_to (SparsityCsr< ValueType, IndexType > *result) const override
void | move_to (SparsityCsr< ValueType, IndexType > *result) override
void | read (const mat_data &data) override
void | read (const device_mat_data &data) override
void | read (device_mat_data &&data) override
void | write (mat_data &data) const override
std::unique_ptr< LinOp > | transpose () const override
| Returns a LinOp representing the transpose of the Transposable object.
std::unique_ptr< LinOp > | conj_transpose () const override
| Returns a LinOp representing the conjugate transpose of the Transposable object.
std::unique_ptr< Csr > | multiply (ptr_param< const Csr > other) const
| Computes the sparse matrix product this * other on the executor of this matrix.
std::pair< std::unique_ptr< Csr >, multiply_reuse_info > | multiply_reuse (ptr_param< const Csr > other) const
| Computes the sparse matrix product this * other on the executor of this matrix, and necessary data for value updates:
std::unique_ptr< Csr > | multiply_add (ptr_param< const Dense< value_type > > scale_mult, ptr_param< const Csr > mtx_mult, ptr_param< const Dense< value_type > > scale_add, ptr_param< const Csr > mtx_add) const
| Computes the sparse matrix product scale_mult * this * mtx_mult + scale_add * mtx_add on the executor of this matrix.
std::pair< std::unique_ptr< Csr >, multiply_add_reuse_info > | multiply_add_reuse (ptr_param< const Dense< value_type > > scale_mult, ptr_param< const Csr > mtx_mult, ptr_param< const Dense< value_type > > scale_add, ptr_param< const Csr > mtx_add) const
| Computes the sparse matrix product scale_mult * this * mtx_mult + scale_add * mtx_add on the executor of this matrix, and necessary data for value updates:
std::unique_ptr< Csr > | scale_add (ptr_param< const Dense< value_type > > scale_this, ptr_param< const Dense< value_type > > scale_other, ptr_param< const Csr > mtx_other) const
| Computes the sparse matrix sum scale_this * this + scale_other * mtx_add on the executor of this matrix.
std::pair< std::unique_ptr< Csr >, scale_add_reuse_info > | add_scale_reuse (ptr_param< const Dense< value_type > > scale_this, ptr_param< const Dense< value_type > > scale_other, ptr_param< const Csr > mtx_other) const
| Computes the sparse matrix sum scale_this * this + scale_other * mtx_add on the executor of this matrix, and necessary data for value updates:
std::pair< std::unique_ptr< Csr >, permuting_reuse_info > | transpose_reuse () const
| Computes the necessary data to update a transposed matrix from its original matrix.
std::unique_ptr< Csr > | permute (ptr_param< const Permutation< index_type > > permutation, permute_mode mode=permute_mode::symmetric) const
| Creates a permuted copy of this matrix with the given permutation .
std::unique_ptr< Csr > | permute (ptr_param< const Permutation< index_type > > row_permutation, ptr_param< const Permutation< index_type > > column_permutation, bool invert=false) const
| Creates a non-symmetrically permuted copy of this matrix with the given row and column permutations and .
std::pair< std::unique_ptr< Csr >, permuting_reuse_info > | permute_reuse (ptr_param< const Permutation< index_type > > permutation, permute_mode mode=permute_mode::symmetric) const
| Computes the operations necessary to propagate changed values from a matrix A to a permuted matrix.
std::pair< std::unique_ptr< Csr >, permuting_reuse_info > | permute_reuse (ptr_param< const Permutation< index_type > > row_permutation, ptr_param< const Permutation< index_type > > column_permutation, bool invert=false) const
| Computes the operations necessary to propagate changed values from a matrix A to a permuted matrix.
std::unique_ptr< Csr > | scale_permute (ptr_param< const ScaledPermutation< value_type, index_type > > permutation, permute_mode=permute_mode::symmetric) const
| Creates a scaled and permuted copy of this matrix.
std::unique_ptr< Csr > | scale_permute (ptr_param< const ScaledPermutation< value_type, index_type > > row_permutation, ptr_param< const ScaledPermutation< value_type, index_type > > column_permutation, bool invert=false) const
| Creates a scaled and permuted copy of this matrix.
std::unique_ptr< LinOp > | permute (const array< IndexType > *permutation_indices) const override
std::unique_ptr< LinOp > | inverse_permute (const array< IndexType > *inverse_permutation_indices) const override
std::unique_ptr< LinOp > | row_permute (const array< IndexType > *permutation_indices) const override
std::unique_ptr< LinOp > | column_permute (const array< IndexType > *permutation_indices) const override
std::unique_ptr< LinOp > | inverse_row_permute (const array< IndexType > *inverse_permutation_indices) const override
std::unique_ptr< LinOp > | inverse_column_permute (const array< IndexType > *inverse_permutation_indices) const override
std::unique_ptr< Diagonal< ValueType > > | extract_diagonal () const override
| Extracts the diagonal entries of the matrix into a vector.
std::unique_ptr< absolute_type > | compute_absolute () const override
| Gets the AbsoluteLinOp.
void | compute_absolute_inplace () override
| Compute absolute inplace on each element.
void | sort_by_column_index ()
| Sorts all (value, col_idx) pairs in each row by column index.
bool | is_sorted_by_column_index () const
value_type * | get_values () noexcept
| Returns the values of the matrix.
const value_type * | get_const_values () const noexcept
| Returns the values of the matrix.
std::unique_ptr< Dense< ValueType > > | create_value_view ()
| Creates a Dense view of the value array of this matrix as a column vector of dimensions nnz x 1.
std::unique_ptr< const Dense< ValueType > > | create_const_value_view () const
| Creates a const Dense view of the value array of this matrix as a column vector of dimensions nnz x 1.
index_type * | get_col_idxs () noexcept
| Returns the column indexes of the matrix.
const index_type * | get_const_col_idxs () const noexcept
| Returns the column indexes of the matrix.
index_type * | get_row_ptrs () noexcept
| Returns the row pointers of the matrix.
const index_type * | get_const_row_ptrs () const noexcept
| Returns the row pointers of the matrix.
index_type * | get_srow () noexcept
| Returns the starting rows.
const index_type * | get_const_srow () const noexcept
| Returns the starting rows.
size_type | get_num_srow_elements () const noexcept
| Returns the number of the srow stored elements (involved warps).
size_type | get_num_stored_elements () const noexcept
| Returns the number of elements explicitly stored in the matrix.
std::shared_ptr< strategy_type > | get_strategy () const noexcept
| Returns the strategy.
void | set_strategy (std::shared_ptr< strategy_type > strategy)
| Set the strategy.
void | scale (ptr_param< const LinOp > alpha)
| Scales the matrix with a scalar.
void | inv_scale (ptr_param< const LinOp > alpha)
| Scales the matrix with the inverse of a scalar.
std::unique_ptr< Csr< ValueType, IndexType > > | create_submatrix (const index_set< IndexType > &row_index_set, const index_set< IndexType > &column_index_set) const
| Creates a submatrix from this Csr matrix given row and column index_set objects.
std::unique_ptr< Csr< ValueType, IndexType > > | create_submatrix (const span &row_span, const span &column_span) const
| Creates a submatrix from this Csr matrix given row and column spans.
Csr & | operator= (const Csr &)
| Copy-assigns a Csr matrix.
Csr & | operator= (Csr &&)
| Move-assigns a Csr matrix.
| Csr (const Csr &)
| Copy-constructs a Csr matrix.
| Csr (Csr &&)
| Move-constructs a Csr matrix.
Public Member Functions inherited from gko::EnableLinOp< Csr< default_precision, int32 > >
const Csr< default_precision, int32 > * | apply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const
Public Member Functions inherited from gko::EnablePolymorphicAssignment< Csr< default_precision, int32 > >
void | convert_to (result_type *result) const override
void | move_to (result_type *result) override
Public Member Functions inherited from gko::DiagonalExtractable< default_precision >
std::unique_ptr< LinOp > | extract_diagonal_linop () const override
| Extracts the diagonal entries of the matrix into a vector.
Public Member Functions inherited from gko::ReadableFromMatrixData< default_precision, int32 >
virtual void | read (const matrix_data< default_precision, int32 > &data)=0
| Reads a matrix from a matrix_data structure.
Public Member Functions inherited from gko::WritableToMatrixData< default_precision, int32 >
virtual void | write (matrix_data< default_precision, int32 > &data) const=0
| Writes a matrix to a matrix_data structure.
Public Member Functions inherited from gko::Permutable< int32 >
virtual std::unique_ptr< LinOp > | permute (const array< int32 > *permutation_indices) const
| Returns a LinOp representing the symmetric row and column permutation of the Permutable object.
virtual std::unique_ptr< LinOp > | inverse_permute (const array< int32 > *permutation_indices) const
| Returns a LinOp representing the symmetric inverse row and column permutation of the Permutable object.
virtual std::unique_ptr< LinOp > | row_permute (const array< int32 > *permutation_indices) const=0
| Returns a LinOp representing the row permutation of the Permutable object.
virtual std::unique_ptr< LinOp > | column_permute (const array< int32 > *permutation_indices) const=0
| Returns a LinOp representing the column permutation of the Permutable object.
virtual std::unique_ptr< LinOp > | inverse_row_permute (const array< int32 > *permutation_indices) const=0
| Returns a LinOp representing the row permutation of the inverse permuted object.
virtual std::unique_ptr< LinOp > | inverse_column_permute (const array< int32 > *permutation_indices) const=0
| Returns a LinOp representing the row permutation of the inverse permuted object.
Public Member Functions inherited from gko::EnableAbsoluteComputation< remove_complex< Csr< default_precision, int32 > > >
std::unique_ptr< LinOp > | compute_absolute_linop () const override
| Gets the absolute LinOp.
Public Member Functions inherited from gko::ScaledIdentityAddable
void | add_scaled_identity (ptr_param< const LinOp > const a, ptr_param< const LinOp > const b)
| Scales this and adds another scalar times the identity to it.

## Static Public Member Functions
static std::unique_ptr< Csr > | create (std::shared_ptr< const Executor > exec, std::shared_ptr< strategy_type > strategy)
| Creates an uninitialized CSR matrix of the specified size.
static std::unique_ptr< Csr > | create (std::shared_ptr< const Executor > exec, const dim< 2 > &size={}, size_type num_nonzeros={}, std::shared_ptr< strategy_type > strategy=nullptr)
| Creates an uninitialized CSR matrix of the specified size.
static std::unique_ptr< Csr > | create (std::shared_ptr< const Executor > exec, const dim< 2 > &size, array< value_type > values, array< index_type > col_idxs, array< index_type > row_ptrs, std::shared_ptr< strategy_type > strategy=nullptr)
| Creates a CSR matrix from already allocated (and initialized) row pointer, column index and value arrays.
template<typename InputValueType, typename InputColumnIndexType, typename InputRowPtrType>
static std::unique_ptr< Csr > | create (std::shared_ptr< const Executor > exec, const dim< 2 > &size, std::initializer_list< InputValueType > values, std::initializer_list< InputColumnIndexType > col_idxs, std::initializer_list< InputRowPtrType > row_ptrs)
| create(std::shared_ptr<const Executor>,const dim<2>&, array<value_type>, array<index_type>, array<index_type>)
static std::unique_ptr< const Csr > | create_const (std::shared_ptr< const Executor > exec, const dim< 2 > &size, gko::detail::const_array_view< ValueType > &&values, gko::detail::const_array_view< IndexType > &&col_idxs, gko::detail::const_array_view< IndexType > &&row_ptrs, std::shared_ptr< strategy_type > strategy=nullptr)
| Creates a constant (immutable) Csr matrix from a set of constant arrays.

## Friends
class | EnablePolymorphicObject< Csr, LinOp >
class | Coo< ValueType, IndexType >
class | Dense< ValueType >
class | Diagonal< ValueType >
class | Ell< ValueType, IndexType >
class | Hybrid< ValueType, IndexType >
class | Sellp< ValueType, IndexType >
class | SparsityCsr< ValueType, IndexType >
class | Fbcsr< ValueType, IndexType >
class | CsrBuilder< ValueType, IndexType >
class | Csr< to_complex< ValueType >, IndexType >
class | Csr< previous_precision< ValueType >, IndexType >

## Detailed Description

template<typename ValueType = default_precision, typename IndexType = int32>
class gko::matrix::Csr< ValueType, IndexType >

CSR is a matrix format which stores only the nonzero coefficients by compressing each row of the matrix (compressed sparse row format).

The nonzero elements are stored in a 1D array row-wise, and accompanied with a row pointer array which stores the starting index of each row. An additional column index array is used to identify the column of each nonzero element.

The Csr LinOp supports different operations:

matrix::Csr *A, *B, *C; // matrices
matrix::Dense *b, *x; // vectors tall-and-skinny matrices
matrix::Dense *alpha, *beta; // scalars of dimension 1x1
matrix::Identity *I; // identity matrix
// Applying to Dense matrices computes an SpMV/SpMM product
A->apply(b, x) // x = A*b
A->apply(alpha, b, beta, x) // x = alpha*A*b + beta*x
// Applying to Csr matrices computes a SpGEMM product of two sparse matrices
A->apply(B, C) // C = A*B
A->apply(alpha, B, beta, C) // C = alpha*A*B + beta*C
// Applying to an Identity matrix computes a SpGEAM sparse matrix addition
A->apply(alpha, I, beta, B) // B = alpha*A + beta*B
gko::matrix::Csr
CSR is a matrix format which stores only the nonzero coefficients by compressing each row of the matr...
Definition csr.hpp:126
gko::matrix::Dense
Dense is a matrix format which explicitly stores all values of the matrix.
Definition dense.hpp:120
gko::matrix::Identity
This class is a utility which efficiently implements the identity matrix (a linear operator which map...
Definition identity.hpp:35

Both the SpGEMM and SpGEAM operation require the input matrices to be sorted by column index, otherwise the algorithms will produce incorrect results.

Template Parameters

  ValueType | precision of matrix elements
  IndexType | precision of matrix indexes

## Constructor & Destructor Documentation

## ◆ Csr() [1/2]

template<typename ValueType = default_precision, typename IndexType = int32>

gko::matrix::Csr< ValueType, IndexType >::Csr | ( | const Csr< ValueType, IndexType > & |  | ) |

Copy-constructs a Csr matrix.

Inherits executor, strategy and data.

## ◆ Csr() [2/2]

template<typename ValueType = default_precision, typename IndexType = int32>

gko::matrix::Csr< ValueType, IndexType >::Csr | ( | Csr< ValueType, IndexType > && |  | ) |

Move-constructs a Csr matrix.

Inherits executor and strategy, moves the data and leaves the moved-from object in an empty state (0x0 LinOp with unchanged executor and strategy, no nonzeros and valid row pointers).

## Member Function Documentation

## ◆ add_scale_reuse()

template<typename ValueType = default_precision, typename IndexType = int32>

std::pair< std::unique_ptr< Csr >, scale_add_reuse_info > gko::matrix::Csr< ValueType, IndexType >::add_scale_reuse | ( | ptr_param< const Dense< value_type > > | scale_this,
|  | ptr_param< const Dense< value_type > > | scale_other,
|  | ptr_param< const Csr< ValueType, IndexType > > | mtx_other ) const

Computes the sparse matrix sum scale_this * this + scale_other * mtx_add on the executor of this matrix, and necessary data for value updates:

auto [result, reuse] = mtx->add_scale_reuse(alpha, beta, mtx2);
change_values(alpha, mtx, beta, mtx2);
reuse->update_values(alpha, mtx, beta, mtx2, result);

This matrix needs to be sorted by column index, otherwise the result will be incorrect.

Parameters

  scale_this | the scalar by which this matrix will be scaled.
  scale_other | the scalar by which this matrix will be scaled.
  mtx_other | the matrix which will be added to this, scaled by scale_other. It needs to be sorted by column index, otherwise the result will be incorrect.

Returns
  std::pair containing the result of the computation, stored on the same executor as this matrix, and a scale_add_reuse_info object allowing value updates to the output matrix.

## ◆ compute_absolute()

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< absolute_type > gko::matrix::Csr< ValueType, IndexType >::compute_absolute | ( |  | ) | const
| overridevirtual

Gets the AbsoluteLinOp.

Returns
  a pointer to the new absolute object

Implements gko::EnableAbsoluteComputation< remove_complex< Csr< default_precision, int32 > > >.

## ◆ compute_absolute_inplace()

template<typename ValueType = default_precision, typename IndexType = int32>

void gko::matrix::Csr< ValueType, IndexType >::compute_absolute_inplace | ( |  | ) |
| overridevirtual

Compute absolute inplace on each element.

Implements gko::AbsoluteComputable.

## ◆ conj_transpose()

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< LinOp > gko::matrix::Csr< ValueType, IndexType >::conj_transpose | ( |  | ) | const
| overridevirtual

Returns a LinOp representing the conjugate transpose of the Transposable object.

Returns
  a pointer to the new conjugate transposed object

Implements gko::Transposable.

## ◆ create() [1/4]

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< Csr > gko::matrix::Csr< ValueType, IndexType >::create | ( | std::shared_ptr< const Executor > | exec,
|  | const dim< 2 > & | size,
|  | array< value_type > | values,
|  | array< index_type > | col_idxs,
|  | array< index_type > | row_ptrs,
|  | std::shared_ptr< strategy_type > | strategy = nullptr )
| static

Creates a CSR matrix from already allocated (and initialized) row pointer, column index and value arrays.

Parameters

  exec | Executor associated to the matrix
  size | size of the matrix
  values | array of matrix values
  col_idxs | array of column indexes
  row_ptrs | array of row pointers
  strategy | the strategy the matrix uses for SpMV operations

Note
  If one of row_ptrs, col_idxs or values is not an rvalue, not an array of IndexType, IndexType and ValueType, respectively, or is on the wrong executor, an internal copy of that array will be created, and the original array data will not be used in the matrix.

Returns
  A smart pointer to the newly created matrix.

## ◆ create() [2/4]

template<typename ValueType = default_precision, typename IndexType = int32>
template<typename InputValueType, typename InputColumnIndexType, typename InputRowPtrType>

std::unique_ptr< Csr > gko::matrix::Csr< ValueType, IndexType >::create | ( | std::shared_ptr< const Executor > | exec,
|  | const dim< 2 > & | size,
|  | std::initializer_list< InputValueType > | values,
|  | std::initializer_list< InputColumnIndexType > | col_idxs,
|  | std::initializer_list< InputRowPtrType > | row_ptrs )
| inlinestatic

create(std::shared_ptr<const Executor>,const dim<2>&, array<value_type>, array<index_type>, array<index_type>)

create(std::shared_ptr<const Executor>,const dim<2>&, array<value_type>, array<index_type>, array<index_type>)

## ◆ create() [3/4]

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< Csr > gko::matrix::Csr< ValueType, IndexType >::create | ( | std::shared_ptr< const Executor > | exec,
|  | const dim< 2 > & | size = {},
|  | size_type | num_nonzeros = {},
|  | std::shared_ptr< strategy_type > | strategy = nullptr )
| static

Creates an uninitialized CSR matrix of the specified size.

Parameters

  exec | Executor associated to the matrix
  size | size of the matrix
  num_nonzeros | number of nonzeros
  strategy | the strategy of CSR, or the default strategy if set to nullptr

Returns
  A smart pointer to the newly created matrix.

## ◆ create() [4/4]

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< Csr > gko::matrix::Csr< ValueType, IndexType >::create | ( | std::shared_ptr< const Executor > | exec,
|  | std::shared_ptr< strategy_type > | strategy )
| static

Creates an uninitialized CSR matrix of the specified size.

Parameters

  exec | Executor associated to the matrix
  strategy | the strategy of CSR

Returns
  A smart pointer to the newly created matrix.

Referenced by gko::matrix::Csr< ValueType, IndexType >::automatical::automatical(), gko::matrix::Csr< value_type, index_type >::create(), and gko::matrix::Csr< ValueType, IndexType >::load_balance::load_balance().

## ◆ create_const()

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< const Csr > gko::matrix::Csr< ValueType, IndexType >::create_const | ( | std::shared_ptr< const Executor > | exec,
|  | const dim< 2 > & | size,
|  | gko::detail::const_array_view< ValueType > && | values,
|  | gko::detail::const_array_view< IndexType > && | col_idxs,
|  | gko::detail::const_array_view< IndexType > && | row_ptrs,
|  | std::shared_ptr< strategy_type > | strategy = nullptr )
| static

Creates a constant (immutable) Csr matrix from a set of constant arrays.

Parameters

  exec | the executor to create the matrix on
  size | the dimensions of the matrix
  values | the value array of the matrix
  col_idxs | the column index array of the matrix
  row_ptrs | the row pointer array of the matrix
  strategy | the strategy the matrix uses for SpMV operations

Returns
  A smart pointer to the constant matrix wrapping the input arrays (if they reside on the same executor as the matrix) or a copy of these arrays on the correct executor.
  A smart pointer to the newly created matrix.

## ◆ create_submatrix() [1/2]

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< Csr< ValueType, IndexType > > gko::matrix::Csr< ValueType, IndexType >::create_submatrix | ( | const index_set< IndexType > & | row_index_set,
|  | const index_set< IndexType > & | column_index_set ) const

Creates a submatrix from this Csr matrix given row and column index_set objects.

Parameters

  row_index_set | the row index set containing the set of rows to be in the submatrix.
  column_index_set | the col index set containing the set of columns to be in the submatrix.

Returns
  A new CSR matrix with the elements that belong to the row and columns of this matrix as specified by the index sets.

Note
  This is not a view but creates a new, separate CSR matrix.

## ◆ create_submatrix() [2/2]

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< Csr< ValueType, IndexType > > gko::matrix::Csr< ValueType, IndexType >::create_submatrix | ( | const span & | row_span,
|  | const span & | column_span ) const

Creates a submatrix from this Csr matrix given row and column spans.

Parameters

  row_span | the row span containing the contiguous set of rows to be in the submatrix.
  column_span | the column span containing the contiguous set of columns to be in the submatrix.

Returns
  A new CSR matrix with the elements that belong to the row and columns of this matrix as specified by the index sets.

Note
  This is not a view but creates a new, separate CSR matrix.

## ◆ extract_diagonal()

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< Diagonal< ValueType > > gko::matrix::Csr< ValueType, IndexType >::extract_diagonal | ( |  | ) | const
| overridevirtual

Extracts the diagonal entries of the matrix into a vector.

Parameters

  diag | the vector into which the diagonal will be written

Implements gko::DiagonalExtractable< default_precision >.

## ◆ get_col_idxs()

template<typename ValueType = default_precision, typename IndexType = int32>

index_type * gko::matrix::Csr< ValueType, IndexType >::get_col_idxs | ( |  | ) |
| inlinenoexcept

Returns the column indexes of the matrix.

Returns
  the column indexes of the matrix.

## ◆ get_const_col_idxs()

template<typename ValueType = default_precision, typename IndexType = int32>

const index_type * gko::matrix::Csr< ValueType, IndexType >::get_const_col_idxs | ( |  | ) | const
| inlinenoexcept

Returns the column indexes of the matrix.

Returns
  the column indexes of the matrix.

Note
  This is the constant version of the function, which can be significantly more memory efficient than the non-constant version, so always prefer this version.

## ◆ get_const_row_ptrs()

template<typename ValueType = default_precision, typename IndexType = int32>

const index_type * gko::matrix::Csr< ValueType, IndexType >::get_const_row_ptrs | ( |  | ) | const
| inlinenoexcept

Returns the row pointers of the matrix.

Returns
  the row pointers of the matrix.

Note
  This is the constant version of the function, which can be significantly more memory efficient than the non-constant version, so always prefer this version.

## ◆ get_const_srow()

template<typename ValueType = default_precision, typename IndexType = int32>

const index_type * gko::matrix::Csr< ValueType, IndexType >::get_const_srow | ( |  | ) | const
| inlinenoexcept

Returns the starting rows.

Returns
  the starting rows.

Note
  This is the constant version of the function, which can be significantly more memory efficient than the non-constant version, so always prefer this version.

## ◆ get_const_values()

template<typename ValueType = default_precision, typename IndexType = int32>

const value_type * gko::matrix::Csr< ValueType, IndexType >::get_const_values | ( |  | ) | const
| inlinenoexcept

Returns the values of the matrix.

Returns
  the values of the matrix.

Note
  This is the constant version of the function, which can be significantly more memory efficient than the non-constant version, so always prefer this version.

## ◆ get_num_srow_elements()

template<typename ValueType = default_precision, typename IndexType = int32>

size_type gko::matrix::Csr< ValueType, IndexType >::get_num_srow_elements | ( |  | ) | const
| inlinenoexcept

Returns the number of the srow stored elements (involved warps).

Returns
  the number of the srow stored elements (involved warps)

## ◆ get_num_stored_elements()

template<typename ValueType = default_precision, typename IndexType = int32>

size_type gko::matrix::Csr< ValueType, IndexType >::get_num_stored_elements | ( |  | ) | const
| inlinenoexcept

Returns the number of elements explicitly stored in the matrix.

Returns
  the number of elements explicitly stored in the matrix

## ◆ get_row_ptrs()

template<typename ValueType = default_precision, typename IndexType = int32>

index_type * gko::matrix::Csr< ValueType, IndexType >::get_row_ptrs | ( |  | ) |
| inlinenoexcept

Returns the row pointers of the matrix.

Returns
  the row pointers of the matrix.

## ◆ get_srow()

template<typename ValueType = default_precision, typename IndexType = int32>

index_type * gko::matrix::Csr< ValueType, IndexType >::get_srow | ( |  | ) |
| inlinenoexcept

Returns the starting rows.

Returns
  the starting rows.

## ◆ get_strategy()

template<typename ValueType = default_precision, typename IndexType = int32>

std::shared_ptr< strategy_type > gko::matrix::Csr< ValueType, IndexType >::get_strategy | ( |  | ) | const
| inlinenoexcept

Returns the strategy.

Returns
  the strategy

## ◆ get_values()

template<typename ValueType = default_precision, typename IndexType = int32>

value_type * gko::matrix::Csr< ValueType, IndexType >::get_values | ( |  | ) |
| inlinenoexcept

Returns the values of the matrix.

Returns
  the values of the matrix.

## ◆ inv_scale()

template<typename ValueType = default_precision, typename IndexType = int32>

void gko::matrix::Csr< ValueType, IndexType >::inv_scale | ( | ptr_param< const LinOp > | alpha | ) |
| inline

Scales the matrix with the inverse of a scalar.

Parameters

  alpha | The entire matrix is scaled by 1 / alpha. alpha has to be a 1x1 Dense matrix.

## ◆ multiply()

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< Csr > gko::matrix::Csr< ValueType, IndexType >::multiply | ( | ptr_param< const Csr< ValueType, IndexType > > | other | ) | const

Computes the sparse matrix product this * other on the executor of this matrix.

Parameters

  other | the matrix with which the product will be computed. It needs to be sorted by column indices when using OmpExecutor or DpcppExecutor for this.

Returns
  the product of the two matrices, stored on the same executor as this matrix.

## ◆ multiply_add()

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< Csr > gko::matrix::Csr< ValueType, IndexType >::multiply_add | ( | ptr_param< const Dense< value_type > > | scale_mult,
|  | ptr_param< const Csr< ValueType, IndexType > > | mtx_mult,
|  | ptr_param< const Dense< value_type > > | scale_add,
|  | ptr_param< const Csr< ValueType, IndexType > > | mtx_add ) const

Computes the sparse matrix product scale_mult * this * mtx_mult + scale_add * mtx_add on the executor of this matrix.

Parameters

  scale_mult | the scalar by which the matrix product will be scaled.
  mtx_mult | the matrix with which the product will be computed. It needs to be sorted by column indices when using OmpExecutor or DpcppExecutor for this.
  scale_add | the scalar by which the matrix mtx_add will be scaled.
  mtx_add | the matrix which will be added to the product, scaled by scale_add.

Returns
  the result of the computation, stored on the same executor as this matrix.

## ◆ multiply_add_reuse()

template<typename ValueType = default_precision, typename IndexType = int32>

std::pair< std::unique_ptr< Csr >, multiply_add_reuse_info > gko::matrix::Csr< ValueType, IndexType >::multiply_add_reuse | ( | ptr_param< const Dense< value_type > > | scale_mult,
|  | ptr_param< const Csr< ValueType, IndexType > > | mtx_mult,
|  | ptr_param< const Dense< value_type > > | scale_add,
|  | ptr_param< const Csr< ValueType, IndexType > > | mtx_add ) const

Computes the sparse matrix product scale_mult * this * mtx_mult + scale_add * mtx_add on the executor of this matrix, and necessary data for value updates:

auto [result, reuse] = mtx->multiply_add_reuse(sm, mm, sa, ma);
change_values(mtx, sm, mm, sa, ma);
reuse->update_values(mtx, sm, mm, sa, ma, result);

Parameters

  scale_mult | the scalar by which the matrix product will be scaled.
  mtx_mult | the matrix with which the product will be computed. It needs to be sorted by column indices when using OmpExecutor or DpcppExecutor for this.
  scale_add | the scalar by which the matrix mtx_add will be scaled.
  mtx_add | the matrix which will be added to the product, scaled by scale_add.

Returns
  std::pair containing the result of the computation, stored on the same executor as this matrix, and a multiply_add_reuse_info object allowing value updates to the output matrix.

## ◆ multiply_reuse()

template<typename ValueType = default_precision, typename IndexType = int32>

std::pair< std::unique_ptr< Csr >, multiply_reuse_info > gko::matrix::Csr< ValueType, IndexType >::multiply_reuse | ( | ptr_param< const Csr< ValueType, IndexType > > | other | ) | const

Computes the sparse matrix product this * other on the executor of this matrix, and necessary data for value updates:

auto [C, reuse] = A->multiply_reuse(B);
change_values(A, B);
reuse->update_values(A, B, C);

Parameters

  other | the matrix with which the product will be computed. It needs to be sorted by column indices when using OmpExecutor or DpcppExecutor for this.

Returns
  std::pair containing the product of the two matrices, stored on the same executor as this matrix, and a multiply_reuse_info object allowing value updates to the output matrix.

## ◆ operator=() [1/2]

template<typename ValueType = default_precision, typename IndexType = int32>

Csr & gko::matrix::Csr< ValueType, IndexType >::operator= | ( | const Csr< ValueType, IndexType > & |  | ) |

Copy-assigns a Csr matrix.

Preserves executor, copies everything else.

## ◆ operator=() [2/2]

template<typename ValueType = default_precision, typename IndexType = int32>

Csr & gko::matrix::Csr< ValueType, IndexType >::operator= | ( | Csr< ValueType, IndexType > && |  | ) |

Move-assigns a Csr matrix.

Preserves executor, moves the data and leaves the moved-from object in an empty state (0x0 LinOp with unchanged executor and strategy, no nonzeros and valid row pointers).

## ◆ permute() [1/2]

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< Csr > gko::matrix::Csr< ValueType, IndexType >::permute | ( | ptr_param< const Permutation< index_type > > | permutation,
|  | permute_mode | mode = permute_mode::symmetric ) const

Creates a permuted copy of this matrix with the given permutation .

By default, this computes a symmetric permutation (permute_mode::symmetric). For the effect of the different permutation modes, see permute_mode

Parameters

  permutation | The input permutation.
  mode | The permutation mode. If permute_mode::inverse is set, we use the inverse permutation instead of . If permute_mode::rows is set, the rows will be permuted. If permute_mode::columns is set, the columns will be permuted.

Returns
  The permuted matrix.

## ◆ permute() [2/2]

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< Csr > gko::matrix::Csr< ValueType, IndexType >::permute | ( | ptr_param< const Permutation< index_type > > | row_permutation,
|  | ptr_param< const Permutation< index_type > > | column_permutation,
|  | bool | invert = false ) const

Creates a non-symmetrically permuted copy of this matrix with the given row and column permutations and .

The operation will compute , or if invert is false, and , or if invert is true.

Parameters

  row_permutation | The permutation to apply to the rows
  column_permutation | The permutation to apply to the columns
  invert | If set to false, uses the input permutations, otherwise uses their inverses

Returns
  The permuted matrix.

## ◆ permute_reuse() [1/2]

template<typename ValueType = default_precision, typename IndexType = int32>

std::pair< std::unique_ptr< Csr >, permuting_reuse_info > gko::matrix::Csr< ValueType, IndexType >::permute_reuse | ( | ptr_param< const Permutation< index_type > > | permutation,
|  | permute_mode | mode = permute_mode::symmetric ) const

Computes the operations necessary to propagate changed values from a matrix A to a permuted matrix.

The semantics of this function match those of permute(ptr_param<const Permutation<index_type>>, permute_mode). Updating values works as follows:

auto [permuted, reuse] = matrix->permute_reuse(permutation, mode);
change_values(matrix);
reuse->update_values(matrix, permuted);
gko::matrix
The matrix namespace.
Definition dense_cache.hpp:24

Parameters

  permutation | The input permutation.
  mode | The permutation mode. If permute_mode::inverse is set, we use the inverse permutation instead of . If permute_mode::rows is set, the rows will be permuted. If permute_mode::columns is set, the columns will be permuted.

Returns
  an std::pair consisting of the permuted matrix and the reuse info that can be used to update values in the permuted matrix.

## ◆ permute_reuse() [2/2]

template<typename ValueType = default_precision, typename IndexType = int32>

std::pair< std::unique_ptr< Csr >, permuting_reuse_info > gko::matrix::Csr< ValueType, IndexType >::permute_reuse | ( | ptr_param< const Permutation< index_type > > | row_permutation,
|  | ptr_param< const Permutation< index_type > > | column_permutation,
|  | bool | invert = false ) const

Computes the operations necessary to propagate changed values from a matrix A to a permuted matrix.

The semantics of this function match those of permute(ptr_param<const Permutation<index_type>>, ptr_param<const Permutation<index_type>>, bool). Updating values works as follows:

auto [permuted, reuse] = matrix->permute_reuse(row_perm, col_perm, inv);
change_values(matrix);
reuse->update_values(matrix, permuted);

Parameters

  row_permutation | The permutation to apply to the rows
  column_permutation | The permutation to apply to the columns
  invert | If set to false, uses the input permutations, otherwise uses their inverses

Returns
  an std::pair consisting of the permuted matrix and the reuse info that can be used to update values in the permuted matrix.

## ◆ scale()

template<typename ValueType = default_precision, typename IndexType = int32>

void gko::matrix::Csr< ValueType, IndexType >::scale | ( | ptr_param< const LinOp > | alpha | ) |
| inline

Scales the matrix with a scalar.

Parameters

  alpha | The entire matrix is scaled by alpha. alpha has to be a 1x1 Dense matrix.

## ◆ scale_add()

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< Csr > gko::matrix::Csr< ValueType, IndexType >::scale_add | ( | ptr_param< const Dense< value_type > > | scale_this,
|  | ptr_param< const Dense< value_type > > | scale_other,
|  | ptr_param< const Csr< ValueType, IndexType > > | mtx_other ) const

Computes the sparse matrix sum scale_this * this + scale_other * mtx_add on the executor of this matrix.

This matrix needs to be sorted by column index, otherwise the result will be incorrect.

Parameters

  scale_this | the scalar by which this matrix will be scaled.
  scale_other | the scalar by which this matrix will be scaled.
  mtx_other | the matrix which will be added to this, scaled by scale_other. It needs to be sorted by column index, otherwise the result will be incorrect.

Returns
  the result of the computation, stored on the same executor as this matrix.

Referenced by gko::matrix::Csr< ValueType, IndexType >::multiply_add_reuse_info::update_values().

## ◆ scale_permute() [1/2]

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< Csr > gko::matrix::Csr< ValueType, IndexType >::scale_permute | ( | ptr_param< const ScaledPermutation< value_type, index_type > > | permutation,
|  | permute_mode | = permute_mode::symmetric ) const

Creates a scaled and permuted copy of this matrix.

For an explanation of the permutation modes, see permute(ptr_param<const Permutation<index_type>>, permute_mode)

Parameters

  permutation | The scaled permutation.
  mode | The permutation mode.

Returns
  The permuted matrix.

## ◆ scale_permute() [2/2]

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< Csr > gko::matrix::Csr< ValueType, IndexType >::scale_permute | ( | ptr_param< const ScaledPermutation< value_type, index_type > > | row_permutation,
|  | ptr_param< const ScaledPermutation< value_type, index_type > > | column_permutation,
|  | bool | invert = false ) const

Creates a scaled and permuted copy of this matrix.

For an explanation of the parameters, see permute(ptr_param<const Permutation<index_type>>, ptr_param<const Permutation<index_type>>, permute_mode)

Parameters

  row_permutation | The scaled row permutation.
  column_permutation | The scaled column permutation.
  invert | If set to false, uses the input permutations, otherwise uses their inverses

Returns
  The permuted matrix.

## ◆ set_strategy()

template<typename ValueType = default_precision, typename IndexType = int32>

void gko::matrix::Csr< ValueType, IndexType >::set_strategy | ( | std::shared_ptr< strategy_type > | strategy | ) |
| inline

Set the strategy.

Parameters

  strategy | the csr strategy

## ◆ transpose()

template<typename ValueType = default_precision, typename IndexType = int32>

std::unique_ptr< LinOp > gko::matrix::Csr< ValueType, IndexType >::transpose | ( |  | ) | const
| overridevirtual

Returns a LinOp representing the transpose of the Transposable object.

Returns
  a pointer to the new transposed object

Implements gko::Transposable.

## ◆ transpose_reuse()

template<typename ValueType = default_precision, typename IndexType = int32>

std::pair< std::unique_ptr< Csr >, permuting_reuse_info > gko::matrix::Csr< ValueType, IndexType >::transpose_reuse | ( |  | ) | const

Computes the necessary data to update a transposed matrix from its original matrix.

auto [transposed, reuse] = matrix->transpose_reuse();
change_values(matrix);
reuse->update_values(matrix, transposed);

Returns
  an std::pair consisting of the transposed matrix and a reuse info struct that can be used to update values in the transposed matrix.

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

- ginkgo/core/distributed/matrix.hpp
- ginkgo/core/matrix/csr.hpp