Ell< ValueType, IndexType > Class Template Reference

Ell&lt; ValueType, IndexType &gt; Class Template Reference#

Reference API: gko::batch::matrix::Ell< ValueType, IndexType > Class Template Reference
Reference API

#include <ginkgo/core/matrix/batch_ell.hpp>

Inheritance diagram for gko::batch::matrix::Ell< ValueType, IndexType >:
[legend]

Public Types

using value_type = ValueType
 
using index_type = IndexType
 
using unbatch_type = gko::matrix::Ell< value_type, index_type >
 
using absolute_type = remove_complex< Ell >
 
using complex_type = to_complex< Ell >
 
- Public Types inherited from gko::EnablePolymorphicAssignment< ConcreteBatchLinOp >
using result_type = ConcreteBatchLinOp
 
- Public Types inherited from gko::ConvertibleTo< ResultType >
using result_type = ResultType
 

Public Member Functions

void convert_to (Ell< next_precision< ValueType >, IndexType > *result) const override
 
void move_to (Ell< next_precision< ValueType >, IndexType > *result) override
 
void convert_to (Ell< next_precision< next_precision< ValueType > >, IndexType > *result) const override
 
void move_to (Ell< next_precision< next_precision< ValueType > >, IndexType > *result) override
 
std::unique_ptr< unbatch_typecreate_view_for_item (size_type item_id)
 
std::unique_ptr< const unbatch_typecreate_const_view_for_item (size_type item_id) const
 
value_type * get_values () noexcept
 
const value_type * get_const_values () const noexcept
 
index_type * get_col_idxs () noexcept
 
const index_type * get_const_col_idxs () const noexcept
 
index_type get_num_stored_elements_per_row () const noexcept
 
size_type get_num_stored_elements () const noexcept
 
size_type get_num_elements_per_item () const noexcept
 
index_type * get_col_idxs_for_item (size_type batch_id) noexcept
 
const index_type * get_const_col_idxs_for_item (size_type batch_id) const noexcept
 
value_type * get_values_for_item (size_type batch_id) noexcept
 
const value_type * get_const_values_for_item (size_type batch_id) const noexcept
 
Ellapply (ptr_param< const MultiVector< value_type > > b, ptr_param< MultiVector< value_type > > x)
 
Ellapply (ptr_param< const MultiVector< value_type > > alpha, ptr_param< const MultiVector< value_type > > b, ptr_param< const MultiVector< value_type > > beta, ptr_param< MultiVector< value_type > > x)
 
const Ellapply (ptr_param< const MultiVector< value_type > > b, ptr_param< MultiVector< value_type > > x) const
 
const Ellapply (ptr_param< const MultiVector< value_type > > alpha, ptr_param< const MultiVector< value_type > > b, ptr_param< const MultiVector< value_type > > beta, ptr_param< MultiVector< value_type > > x) const
 
void scale (const array< value_type > &row_scale, const array< value_type > &col_scale)
 
void add_scaled_identity (ptr_param< const MultiVector< value_type > > alpha, ptr_param< const MultiVector< value_type > > beta)
 
- Public Member Functions inherited from gko::EnableAbstractPolymorphicObject< AbstractObject, PolymorphicBase >
std::unique_ptr< AbstractObject > create_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< AbstractObject > create_default () const
 
std::unique_ptr< AbstractObject > clone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< AbstractObject > clone () const
 
AbstractObject * copy_from (const PolymorphicObject *other)
 
template<typename Derived >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, AbstractObject > * copy_from (std::unique_ptr< Derived > &&other)
 
template<typename Derived >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, AbstractObject > * copy_from (const std::unique_ptr< Derived > &other)
 
AbstractObject * copy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
AbstractObject * move_from (ptr_param< PolymorphicObject > other)
 
AbstractObject * clear ()
 
- Public Member Functions inherited from gko::PolymorphicObject
PolymorphicObjectoperator= (const PolymorphicObject &)
 
std::unique_ptr< PolymorphicObjectcreate_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< PolymorphicObjectcreate_default () const
 
std::unique_ptr< PolymorphicObjectclone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< PolymorphicObjectclone () const
 
PolymorphicObjectcopy_from (const PolymorphicObject *other)
 
template<typename Derived , typename Deleter >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * copy_from (std::unique_ptr< Derived, Deleter > &&other)
 
template<typename Derived , typename Deleter >
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * copy_from (const std::unique_ptr< Derived, Deleter > &other)
 
PolymorphicObjectcopy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
PolymorphicObjectmove_from (ptr_param< PolymorphicObject > other)
 
PolymorphicObjectclear ()
 
std::shared_ptr< const Executorget_executor () const noexcept
 
- Public Member Functions inherited from gko::log::EnableLogging< PolymorphicObject >
void add_logger (std::shared_ptr< const Logger > logger) override
 
void remove_logger (const Logger *logger) override
 
void remove_logger (ptr_param< const Logger > logger)
 
const std::vector< std::shared_ptr< const Logger > > & get_loggers () const override
 
void clear_loggers () override
 
- Public Member Functions inherited from gko::log::Loggable
void remove_logger (ptr_param< const Logger > logger)
 
- Public Member Functions inherited from gko::EnablePolymorphicAssignment< ConcreteBatchLinOp >
void convert_to (result_type *result) const override
 
void move_to (result_type *result) override
 
- Public Member Functions inherited from gko::ConvertibleTo< ResultType >
virtual void convert_to (result_type *result) const =0
 
void convert_to (ptr_param< result_type > result) const
 
virtual void move_to (result_type *result)=0
 
void move_to (ptr_param< result_type > result)
 

Static Public Member Functions

static std::unique_ptr< Ellcreate (std::shared_ptr< const Executor > exec, const batch_dim< 2 > &size=batch_dim< 2 >{}, const IndexType num_elems_per_row=0)
 
static std::unique_ptr< Ellcreate (std::shared_ptr< const Executor > exec, const batch_dim< 2 > &size, const IndexType num_elems_per_row, array< value_type > values, array< index_type > col_idxs)
 
template<typename InputValueType , typename ColIndexType >
static std::unique_ptr< Ellcreate (std::shared_ptr< const Executor > exec, const batch_dim< 2 > &size, const IndexType num_elems_per_row, std::initializer_list< InputValueType > values, std::initializer_list< ColIndexType > col_idxs)
 create(std::shared_ptr<const Executor>,const batch_dim<2>&, const IndexType, array<value_type>,array<index_type>)
 
static std::unique_ptr< const Ellcreate_const (std::shared_ptr< const Executor > exec, const batch_dim< 2 > &sizes, const index_type num_elems_per_row, gko::detail::const_array_view< value_type > &&values, gko::detail::const_array_view< index_type > &&col_idxs)
 

Friends

class EnablePolymorphicObject< Ell, BatchLinOp >
 
class Ell< to_complex< ValueType >, IndexType >
 
class Ell< previous_precision< ValueType >, IndexType >
 
class Ell< previous_precision< previous_precision< ValueType > >, IndexType >
 

Additional Inherited Members

- Protected Member Functions inherited from gko::EnablePolymorphicObject< ConcreteObject, PolymorphicBase >
std::unique_ptr< PolymorphicObjectcreate_default_impl (std::shared_ptr< const Executor > exec) const override
 
PolymorphicObjectcopy_from_impl (const PolymorphicObject *other) override
 
PolymorphicObjectcopy_from_impl (std::unique_ptr< PolymorphicObject > other) override
 
PolymorphicObjectmove_from_impl (PolymorphicObject *other) override
 
PolymorphicObjectmove_from_impl (std::unique_ptr< PolymorphicObject > other) override
 
PolymorphicObjectclear_impl () override
 
- Protected Member Functions inherited from gko::PolymorphicObject
 PolymorphicObject (std::shared_ptr< const Executor > exec)
 
 PolymorphicObject (const PolymorphicObject &other)
 
- Protected Member Functions inherited from gko::log::EnableLogging< PolymorphicObject >
void log (Params &&... params) const
 
- Protected Attributes inherited from gko::log::EnableLogging< PolymorphicObject >
std::vector< std::shared_ptr< const Logger > > loggers_
 

Detailed Description

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

Ell is a sparse matrix format that stores the same number of nonzeros in each row, enabling coalesced accesses. It is suitable for sparsity patterns that have a similar number of nonzeros in every row. The values are stored in a column-major fashion similar to the monolithic gko::matrix::Ell class.

Similar to the monolithic gko::matrix::Ell class, invalid_index<IndexType> is used as the column index for padded zero entries.

Note
It is also assumed that the sparsity pattern of all the items in the batch is the same and therefore only a single copy of the sparsity pattern is stored.
Currently only IndexType of int32 is supported.
Template Parameters
ValueTypevalue precision of matrix elements
IndexTypeindex precision of matrix elements

Member Function Documentation

◆ add_scaled_identity()

template<typename ValueType = default_precision, typename IndexType = int32>
void gko::batch::matrix::Ell< ValueType, IndexType >::add_scaled_identity ( ptr_param< const MultiVector< value_type > >  alpha,
ptr_param< const MultiVector< value_type > >  beta 
)

Performs the operation this = alpha*I + beta*this.

Parameters
alphathe scalar for identity
betathe scalar to multiply this matrix
Note
Performs the operation in-place for this batch matrix.
This operation fails in case this matrix does not have all its diagonal entries.

◆ apply() [1/4]

template<typename ValueType = default_precision, typename IndexType = int32>
Ell * gko::batch::matrix::Ell< ValueType, IndexType >::apply ( ptr_param< const MultiVector< value_type > >  alpha,
ptr_param< const MultiVector< value_type > >  b,
ptr_param< const MultiVector< value_type > >  beta,
ptr_param< MultiVector< value_type > >  x 
)

Apply the matrix to a multi-vector with a linear combination of the given input vector. Represents the matrix vector multiplication, x = alpha * A

  • b + beta * x, where x and b are both multi-vectors.
Parameters
alphathe scalar to scale the matrix-vector product with
bthe multi-vector to be applied to
betathe scalar to scale the x vector with
xthe output multi-vector

◆ apply() [2/4]

template<typename ValueType = default_precision, typename IndexType = int32>
const Ell * gko::batch::matrix::Ell< ValueType, IndexType >::apply ( ptr_param< const MultiVector< value_type > >  alpha,
ptr_param< const MultiVector< value_type > >  b,
ptr_param< const MultiVector< value_type > >  beta,
ptr_param< MultiVector< value_type > >  x 
) const

◆ apply() [3/4]

template<typename ValueType = default_precision, typename IndexType = int32>
Ell * gko::batch::matrix::Ell< ValueType, IndexType >::apply ( ptr_param< const MultiVector< value_type > >  b,
ptr_param< MultiVector< value_type > >  x 
)

Apply the matrix to a multi-vector. Represents the matrix vector multiplication, x = A * b, where x and b are both multi-vectors.

Parameters
bthe multi-vector to be applied to
xthe output multi-vector

◆ apply() [4/4]

template<typename ValueType = default_precision, typename IndexType = int32>
const Ell * gko::batch::matrix::Ell< ValueType, IndexType >::apply ( ptr_param< const MultiVector< value_type > >  b,
ptr_param< MultiVector< value_type > >  x 
) const

◆ create() [1/3]

template<typename ValueType = default_precision, typename IndexType = int32>
static std::unique_ptr< Ell > gko::batch::matrix::Ell< ValueType, IndexType >::create ( std::shared_ptr< const Executor exec,
const batch_dim< 2 > &  size,
const IndexType  num_elems_per_row,
array< value_type >  values,
array< index_type >  col_idxs 
)
static

Creates a Ell matrix from an already allocated (and initialized) array. The column indices array needs to be the same for all batch items.

Parameters
execExecutor associated to the matrix
sizesize of the matrix
num_elems_per_rowthe number of elements to be stored in each row
valuesarray of matrix values
col_idxsthe col_idxs array of a single batch item of the matrix.
Note
If values is not an rvalue, not an array of ValueType, or is on the wrong executor, an internal copy 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/3]

template<typename ValueType = default_precision, typename IndexType = int32>
template<typename InputValueType , typename ColIndexType >
static std::unique_ptr< Ell > gko::batch::matrix::Ell< ValueType, IndexType >::create ( std::shared_ptr< const Executor exec,
const batch_dim< 2 > &  size,
const IndexType  num_elems_per_row,
std::initializer_list< InputValueType >  values,
std::initializer_list< ColIndexType >  col_idxs 
)
inlinestatic

◆ create() [3/3]

template<typename ValueType = default_precision, typename IndexType = int32>
static std::unique_ptr< Ell > gko::batch::matrix::Ell< ValueType, IndexType >::create ( std::shared_ptr< const Executor exec,
const batch_dim< 2 > &  size = batch_dim< 2 >{},
const IndexType  num_elems_per_row = 0 
)
static

Creates an uninitialized Ell matrix of the specified size.

Parameters
execExecutor associated to the matrix
sizesize of the matrix
num_elems_per_rowthe number of elements to be stored in each row
Returns
A smart pointer to the newly created matrix.

Referenced by gko::batch::matrix::Ell< ValueType, IndexType >::create().

◆ create_const()

template<typename ValueType = default_precision, typename IndexType = int32>
static std::unique_ptr< const Ell > gko::batch::matrix::Ell< ValueType, IndexType >::create_const ( std::shared_ptr< const Executor exec,
const batch_dim< 2 > &  sizes,
const index_type  num_elems_per_row,
gko::detail::const_array_view< value_type > &&  values,
gko::detail::const_array_view< index_type > &&  col_idxs 
)
static

Creates a constant (immutable) batch ell matrix from a constant array. The column indices array needs to be the same for all batch items.

Parameters
execthe executor to create the matrix on
sizethe dimensions of the matrix
num_elems_per_rowthe number of elements to be stored in each row
valuesthe value array of the matrix
col_idxsthe col_idxs array of a single batch item of the matrix.
Returns
A smart pointer to the constant matrix wrapping the input array (if it resides on the same executor as the matrix) or a copy of the array on the correct executor.
A smart pointer to the newly created matrix.

◆ create_const_view_for_item()

template<typename ValueType = default_precision, typename IndexType = int32>
std::unique_ptr< const unbatch_type > gko::batch::matrix::Ell< ValueType, IndexType >::create_const_view_for_item ( size_type  item_id) const

Creates a mutable view (of matrix::Ell type) of one item of the batch::matrix::Ell<value_type> object. Does not perform any deep copies, but only returns a view of the data.

Parameters
item_idThe index of the batch item
Returns
a batch::matrix::Ell object with the data from the batch item at the given index.

◆ create_view_for_item()

template<typename ValueType = default_precision, typename IndexType = int32>
std::unique_ptr< unbatch_type > gko::batch::matrix::Ell< ValueType, IndexType >::create_view_for_item ( size_type  item_id)

Creates a mutable view (of matrix::Ell type) of one item of the batch::matrix::Ell<value_type> object. Does not perform any deep copies, but only returns a view of the data.

Parameters
item_idThe index of the batch item
Returns
a batch::matrix::Ell object with the data from the batch item at the given index.

◆ get_col_idxs()

template<typename ValueType = default_precision, typename IndexType = int32>
index_type * gko::batch::matrix::Ell< ValueType, IndexType >::get_col_idxs ( )
inlinenoexcept

Returns a pointer to the array of column indices of the matrix

Returns
the pointer to the array of column indices

References gko::array< ValueType >::get_data().

◆ get_col_idxs_for_item()

template<typename ValueType = default_precision, typename IndexType = int32>
index_type * gko::batch::matrix::Ell< ValueType, IndexType >::get_col_idxs_for_item ( size_type  batch_id)
inlinenoexcept

Returns a pointer to the array of col_idxs of the matrix. This is shared across all batch items.

Parameters
batch_idthe id of the batch item.
Returns
the pointer to the array of col_idxs

References gko::array< ValueType >::get_data().

◆ get_const_col_idxs()

template<typename ValueType = default_precision, typename IndexType = int32>
const index_type * gko::batch::matrix::Ell< ValueType, IndexType >::get_const_col_idxs ( ) const
inlinenoexcept

Returns a pointer to the array of column indices of the matrix

Returns
the pointer to the array of column indices
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.

References gko::array< ValueType >::get_const_data().

◆ get_const_col_idxs_for_item()

template<typename ValueType = default_precision, typename IndexType = int32>
const index_type * gko::batch::matrix::Ell< ValueType, IndexType >::get_const_col_idxs_for_item ( size_type  batch_id) const
inlinenoexcept

Returns a pointer to the array of col_idxs of the matrix. This is shared across all batch items.

Parameters
batch_idthe id of the batch item.
Returns
the pointer to the array of col_idxs
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.

References gko::array< ValueType >::get_const_data().

◆ get_const_values()

template<typename ValueType = default_precision, typename IndexType = int32>
const value_type * gko::batch::matrix::Ell< ValueType, IndexType >::get_const_values ( ) const
inlinenoexcept

Returns a pointer to the array of values of the matrix

Returns
the pointer to the array of values
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.

References gko::array< ValueType >::get_const_data().

◆ get_const_values_for_item()

template<typename ValueType = default_precision, typename IndexType = int32>
const value_type * gko::batch::matrix::Ell< ValueType, IndexType >::get_const_values_for_item ( size_type  batch_id) const
inlinenoexcept

Returns a pointer to the array of values of the matrix for a specific batch item.

Parameters
batch_idthe id of the batch item.
Returns
the pointer to the array of values
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.

References gko::array< ValueType >::get_const_data(), and gko::batch::matrix::Ell< ValueType, IndexType >::get_num_elements_per_item().

◆ get_num_elements_per_item()

template<typename ValueType = default_precision, typename IndexType = int32>
size_type gko::batch::matrix::Ell< ValueType, IndexType >::get_num_elements_per_item ( ) const
inlinenoexcept

Returns the number of stored elements in each batch item.

Returns
the number of stored elements per batch item.

References gko::batch::matrix::Ell< ValueType, IndexType >::get_num_stored_elements().

Referenced by gko::batch::matrix::Ell< ValueType, IndexType >::get_const_values_for_item(), and gko::batch::matrix::Ell< ValueType, IndexType >::get_values_for_item().

◆ get_num_stored_elements()

template<typename ValueType = default_precision, typename IndexType = int32>
size_type gko::batch::matrix::Ell< ValueType, IndexType >::get_num_stored_elements ( ) const
inlinenoexcept

Returns the number of elements explicitly stored in the batch matrix, cumulative across all the batch items.

Returns
the number of elements explicitly stored in the vector, cumulative across all the batch items

References gko::array< ValueType >::get_size().

Referenced by gko::batch::matrix::Ell< ValueType, IndexType >::get_num_elements_per_item().

◆ get_num_stored_elements_per_row()

template<typename ValueType = default_precision, typename IndexType = int32>
index_type gko::batch::matrix::Ell< ValueType, IndexType >::get_num_stored_elements_per_row ( ) const
inlinenoexcept

Returns the number of elements per row explicitly stored.

Returns
the number of elements stored in each row of the ELL matrix. Same for each batch item

◆ get_values()

template<typename ValueType = default_precision, typename IndexType = int32>
value_type * gko::batch::matrix::Ell< ValueType, IndexType >::get_values ( )
inlinenoexcept

Returns a pointer to the array of values of the matrix

Returns
the pointer to the array of values

References gko::array< ValueType >::get_data().

◆ get_values_for_item()

template<typename ValueType = default_precision, typename IndexType = int32>
value_type * gko::batch::matrix::Ell< ValueType, IndexType >::get_values_for_item ( size_type  batch_id)
inlinenoexcept

Returns a pointer to the array of values of the matrix for a specific batch item.

Parameters
batch_idthe id of the batch item.
Returns
the pointer to the array of values

References gko::array< ValueType >::get_data(), and gko::batch::matrix::Ell< ValueType, IndexType >::get_num_elements_per_item().

◆ scale()

template<typename ValueType = default_precision, typename IndexType = int32>
void gko::batch::matrix::Ell< ValueType, IndexType >::scale ( const array< value_type > &  row_scale,
const array< value_type > &  col_scale 
)

Performs in-place row and column scaling for this matrix.

Parameters
row_scalethe row scalars
col_scalethe column scalars

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