Ginkgo  Generated from pipelines/1570051012 branch based on develop. Ginkgo version 1.9.0
A numerical linear algebra library targeting many-core architectures
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
gko::batch::matrix::Dense< ValueType > Class Template Referencefinal

Dense is a batch matrix format which explicitly stores all values of the matrix in each of the batches. More...

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

Inheritance diagram for gko::batch::matrix::Dense< ValueType >:
[legend]
Collaboration diagram for gko::batch::matrix::Dense< ValueType >:
[legend]

Public Types

using value_type = ValueType
 
using index_type = int32
 
using transposed_type = Dense< ValueType >
 
using unbatch_type = gko::matrix::Dense< ValueType >
 
using absolute_type = remove_complex< Dense >
 
using complex_type = to_complex< Dense >
 
- Public Types inherited from gko::EnablePolymorphicAssignment< Dense< ValueType > >
using result_type = Dense< ValueType >
 
- Public Types inherited from gko::ConvertibleTo< Dense< ValueType > >
using result_type = Dense< ValueType >
 
- Public Types inherited from gko::ConvertibleTo< Dense< next_precision_with_half< ValueType > > >
using result_type = Dense< next_precision_with_half< ValueType > >
 

Public Member Functions

void convert_to (Dense< next_precision_with_half< ValueType >> *result) const override
 
void move_to (Dense< next_precision_with_half< ValueType >> *result) override
 
std::unique_ptr< unbatch_typecreate_view_for_item (size_type item_id)
 Creates a mutable view (of gko::matrix::Dense type) of one item of the batch::matrix::Dense<value_type> object. More...
 
std::unique_ptr< const unbatch_typecreate_const_view_for_item (size_type item_id) const
 Creates a mutable view (of gko::matrix::Dense type) of one item of the batch::matrix::Dense<value_type> object. More...
 
size_type get_cumulative_offset (size_type batch_id) const
 Get the cumulative storage size offset. More...
 
value_type * get_values () noexcept
 Returns a pointer to the array of values of the multi-vector. More...
 
const value_type * get_const_values () const noexcept
 Returns a pointer to the array of values of the multi-vector. More...
 
value_type & at (size_type batch_id, size_type row, size_type col)
 Returns a single element for a particular batch item. More...
 
value_type at (size_type batch_id, size_type row, size_type col) const
 Returns a single element for a particular batch item. More...
 
ValueType & at (size_type batch_id, size_type idx) noexcept
 Returns a single element for a particular batch item. More...
 
ValueType at (size_type batch_id, size_type idx) const noexcept
 Returns a single element for a particular batch item. More...
 
value_type * get_values_for_item (size_type batch_id) noexcept
 Returns a pointer to the array of values of the matrix for a specific batch item. More...
 
const value_type * get_const_values_for_item (size_type batch_id) const noexcept
 Returns a pointer to the array of values of the matrix for a specific batch item. More...
 
size_type get_num_stored_elements () const noexcept
 Returns the number of elements explicitly stored in the batch matrix, cumulative across all the batch items. More...
 
size_type get_num_elements_per_item () const noexcept
 Returns the number of stored elements in each batch item. More...
 
Denseapply (ptr_param< const MultiVector< value_type >> b, ptr_param< MultiVector< value_type >> x)
 Apply the matrix to a multi-vector. More...
 
Denseapply (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. More...
 
const Denseapply (ptr_param< const MultiVector< value_type >> b, ptr_param< MultiVector< value_type >> x) const
 
const Denseapply (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)
 Performs in-place row and column scaling for this matrix. More...
 
void scale_add (ptr_param< const MultiVector< value_type >> alpha, ptr_param< const batch::matrix::Dense< value_type >> b)
 Performs the operation this = alpha*this + b. More...
 
void 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. More...
 
- Public Member Functions inherited from gko::EnableAbstractPolymorphicObject< Dense< ValueType >, BatchLinOp >
std::unique_ptr< Dense< ValueType > > create_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< Dense< ValueType > > create_default () const
 
std::unique_ptr< Dense< ValueType > > clone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< Dense< ValueType > > clone () const
 
Dense< ValueType > * copy_from (const PolymorphicObject *other)
 
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, Dense< ValueType > > * copy_from (std::unique_ptr< Derived > &&other)
 
std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, Dense< ValueType > > * copy_from (const std::unique_ptr< Derived > &other)
 
Dense< ValueType > * copy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
Dense< ValueType > * move_from (ptr_param< PolymorphicObject > other)
 
Dense< ValueType > * clear ()
 
- Public Member Functions inherited from gko::EnablePolymorphicAssignment< Dense< ValueType > >
void convert_to (result_type *result) const override
 Converts the implementer to an object of type result_type. More...
 
void move_to (result_type *result) override
 Converts the implementer to an object of type result_type by moving data from this object. More...
 
- Public Member Functions inherited from gko::ConvertibleTo< Dense< ValueType > >
void convert_to (ptr_param< result_type > result) const
 
void move_to (ptr_param< result_type > result)
 
- Public Member Functions inherited from gko::ConvertibleTo< Dense< next_precision_with_half< ValueType > > >
virtual void convert_to (result_type *result) const=0
 Converts the implementer to an object of type result_type. More...
 
void convert_to (ptr_param< result_type > result) const
 
virtual void move_to (result_type *result)=0
 Converts the implementer to an object of type result_type by moving data from this object. More...
 
void move_to (ptr_param< result_type > result)
 

Static Public Member Functions

static std::unique_ptr< Densecreate (std::shared_ptr< const Executor > exec, const batch_dim< 2 > &size=batch_dim< 2 >{})
 Creates an uninitialized Dense matrix of the specified size. More...
 
static std::unique_ptr< Densecreate (std::shared_ptr< const Executor > exec, const batch_dim< 2 > &size, array< value_type > values)
 Creates a Dense matrix from an already allocated (and initialized) array. More...
 
template<typename InputValueType >
static std::unique_ptr< Densecreate (std::shared_ptr< const Executor > exec, const batch_dim< 2 > &size, std::initializer_list< InputValueType > values)
 create(std::shared_ptr<const Executor>, More...
 
static std::unique_ptr< const Densecreate_const (std::shared_ptr< const Executor > exec, const batch_dim< 2 > &sizes, gko::detail::const_array_view< ValueType > &&values)
 Creates a constant (immutable) batch dense matrix from a constant array. More...
 

Friends

class EnablePolymorphicObject< Dense, BatchLinOp >
 
class Dense< to_complex< ValueType > >
 
class Dense< previous_precision_with_half< ValueType > >
 

Detailed Description

template<typename ValueType = default_precision>
class gko::batch::matrix::Dense< ValueType >

Dense is a batch matrix format which explicitly stores all values of the matrix in each of the batches.

The values in each of the batches are stored in row-major format (values belonging to the same row appear consecutive in the memory and the values of each batch item are also stored consecutively in memory).

Note
Though the storage layout is the same as the multi-vector object, the class semantics and the operations it aims to provide are different. Hence it is recommended to create multi-vector objects if the user means to view the data as a set of vectors.
Template Parameters
ValueTypeprecision of matrix elements

Member Function Documentation

◆ add_scaled_identity()

template<typename ValueType = default_precision>
void gko::batch::matrix::Dense< ValueType >::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

◆ apply() [1/4]

template<typename ValueType = default_precision>
Dense* gko::batch::matrix::Dense< ValueType >::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>
const Dense* gko::batch::matrix::Dense< ValueType >::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>
Dense* gko::batch::matrix::Dense< ValueType >::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>
const Dense* gko::batch::matrix::Dense< ValueType >::apply ( ptr_param< const MultiVector< value_type >>  b,
ptr_param< MultiVector< value_type >>  x 
) const

◆ at() [1/4]

template<typename ValueType = default_precision>
ValueType gko::batch::matrix::Dense< ValueType >::at ( size_type  batch_id,
size_type  idx 
) const
inlinenoexcept

Returns a single element for a particular batch item.

Parameters
batch_idthe batch item index to be queried
rowthe row of the requested element
colthe column of the requested element
Note
the method has to be called on the same Executor the matrix is stored at (e.g. trying to call this method on a GPU Dense object from the OMP may result in incorrect behaviour)

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

◆ at() [2/4]

template<typename ValueType = default_precision>
ValueType& gko::batch::matrix::Dense< ValueType >::at ( size_type  batch_id,
size_type  idx 
)
inlinenoexcept

Returns a single element for a particular batch item.

Useful for iterating across all elements of the matrix. However, it is less efficient than the two-parameter variant of this method.

Parameters
batch_idthe batch item index to be queried
idxa linear index of the requested element
Note
the method has to be called on the same Executor the matrix is stored at (e.g. trying to call this method on a GPU Dense object from the OMP may result in incorrect behaviour)

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

◆ at() [3/4]

template<typename ValueType = default_precision>
value_type& gko::batch::matrix::Dense< ValueType >::at ( size_type  batch_id,
size_type  row,
size_type  col 
)
inline

Returns a single element for a particular batch item.

Parameters
batch_idthe batch item index to be queried
rowthe row of the requested element
colthe column of the requested element
Note
the method has to be called on the same Executor the matrix is stored at (e.g. trying to call this method on a GPU Dense object from the OMP may result in incorrect behaviour)

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

◆ at() [4/4]

template<typename ValueType = default_precision>
value_type gko::batch::matrix::Dense< ValueType >::at ( size_type  batch_id,
size_type  row,
size_type  col 
) const
inline

Returns a single element for a particular batch item.

Parameters
batch_idthe batch item index to be queried
rowthe row of the requested element
colthe column of the requested element
Note
the method has to be called on the same Executor the matrix is stored at (e.g. trying to call this method on a GPU Dense object from the OMP may result in incorrect behaviour)

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

◆ create() [1/3]

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

Creates a Dense matrix from an already allocated (and initialized) array.

Parameters
execExecutor associated to the matrix
sizesizes of the batch matrices in a batch_dim object
valuesarray of matrix values
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>
template<typename InputValueType >
static std::unique_ptr<Dense> gko::batch::matrix::Dense< ValueType >::create ( std::shared_ptr< const Executor exec,
const batch_dim< 2 > &  size,
std::initializer_list< InputValueType >  values 
)
inlinestatic

create(std::shared_ptr<const Executor>,

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

References gko::batch::matrix::Dense< ValueType >::create().

◆ create() [3/3]

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

Creates an uninitialized Dense matrix of the specified size.

Parameters
execExecutor associated to the matrix
sizesize of the matrix
Returns
A smart pointer to the newly created matrix.

Referenced by gko::batch::matrix::Dense< ValueType >::create().

◆ create_const()

template<typename ValueType = default_precision>
static std::unique_ptr<const Dense> gko::batch::matrix::Dense< ValueType >::create_const ( std::shared_ptr< const Executor exec,
const batch_dim< 2 > &  sizes,
gko::detail::const_array_view< ValueType > &&  values 
)
static

Creates a constant (immutable) batch dense matrix from a constant array.

Parameters
execthe executor to create the matrix on
sizethe dimensions of the matrix
valuesthe value array 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>
std::unique_ptr<const unbatch_type> gko::batch::matrix::Dense< ValueType >::create_const_view_for_item ( size_type  item_id) const

Creates a mutable view (of gko::matrix::Dense type) of one item of the batch::matrix::Dense<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 gko::matrix::Dense object with the data from the batch item at the given index.

◆ create_view_for_item()

template<typename ValueType = default_precision>
std::unique_ptr<unbatch_type> gko::batch::matrix::Dense< ValueType >::create_view_for_item ( size_type  item_id)

Creates a mutable view (of gko::matrix::Dense type) of one item of the batch::matrix::Dense<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 gko::matrix::Dense object with the data from the batch item at the given index.

◆ get_const_values()

template<typename ValueType = default_precision>
const value_type* gko::batch::matrix::Dense< ValueType >::get_const_values ( ) const
inlinenoexcept

Returns a pointer to the array of values of the multi-vector.

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>
const value_type* gko::batch::matrix::Dense< ValueType >::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::Dense< ValueType >::get_cumulative_offset().

◆ get_cumulative_offset()

template<typename ValueType = default_precision>
size_type gko::batch::matrix::Dense< ValueType >::get_cumulative_offset ( size_type  batch_id) const
inline

Get the cumulative storage size offset.

Parameters
batch_idthe batch id
Returns
the cumulative offset

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

◆ get_num_elements_per_item()

template<typename ValueType = default_precision>
size_type gko::batch::matrix::Dense< ValueType >::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::Dense< ValueType >::get_num_stored_elements().

◆ get_num_stored_elements()

template<typename ValueType = default_precision>
size_type gko::batch::matrix::Dense< ValueType >::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::Dense< ValueType >::get_num_elements_per_item().

◆ get_values()

template<typename ValueType = default_precision>
value_type* gko::batch::matrix::Dense< ValueType >::get_values ( )
inlinenoexcept

Returns a pointer to the array of values of the multi-vector.

Returns
the pointer to the array of values

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

◆ get_values_for_item()

template<typename ValueType = default_precision>
value_type* gko::batch::matrix::Dense< ValueType >::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::batch::matrix::Dense< ValueType >::get_cumulative_offset(), and gko::array< ValueType >::get_data().

◆ scale()

template<typename ValueType = default_precision>
void gko::batch::matrix::Dense< ValueType >::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

◆ scale_add()

template<typename ValueType = default_precision>
void gko::batch::matrix::Dense< ValueType >::scale_add ( ptr_param< const MultiVector< value_type >>  alpha,
ptr_param< const batch::matrix::Dense< value_type >>  b 
)

Performs the operation this = alpha*this + b.

Parameters
alphathe scalar to multiply this matrix
bthe matrix to add
Note
Performs the operation in-place for this batch matrix

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