Diagonal< ValueType > Class Template Reference

Diagonal&lt; ValueType &gt; Class Template Reference#

Reference API: gko::matrix::Diagonal< ValueType > Class Template Reference
Reference API

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

Inheritance diagram for gko::matrix::Diagonal< ValueType >:
[legend]

Public Types

using value_type = ValueType
 
using index_type = int64
 
using mat_data = matrix_data< ValueType, int64 >
 
using mat_data32 = matrix_data< ValueType, int32 >
 
using device_mat_data = device_matrix_data< ValueType, int64 >
 
using device_mat_data32 = device_matrix_data< ValueType, int32 >
 
using absolute_type = remove_complex< Diagonal >
 
- Public Types inherited from gko::EnablePolymorphicAssignment< ConcreteLinOp >
using result_type = ConcreteLinOp
 
- Public Types inherited from gko::ConvertibleTo< ResultType >
using result_type = ResultType
 
- Public Types inherited from gko::WritableToMatrixData< ValueType, IndexType >
using value_type = ValueType
 
using index_type = IndexType
 
- Public Types inherited from gko::ReadableFromMatrixData< ValueType, IndexType >
using value_type = ValueType
 
using index_type = IndexType
 
- Public Types inherited from gko::EnableAbsoluteComputation< AbsoluteLinOp >
using absolute_type = AbsoluteLinOp
 

Public Member Functions

std::unique_ptr< LinOptranspose () const override
 
std::unique_ptr< LinOpconj_transpose () const override
 
void convert_to (Diagonal< next_precision< ValueType > > *result) const override
 
void move_to (Diagonal< next_precision< ValueType > > *result) override
 
void convert_to (Diagonal< next_precision< next_precision< ValueType > > > *result) const override
 
void move_to (Diagonal< next_precision< next_precision< ValueType > > > *result) override
 
void convert_to (Csr< ValueType, int32 > *result) const override
 
void move_to (Csr< ValueType, int32 > *result) override
 
void convert_to (Csr< ValueType, int64 > *result) const override
 
void move_to (Csr< ValueType, int64 > *result) override
 
std::unique_ptr< absolute_type > compute_absolute () const override
 
void compute_absolute_inplace () override
 
value_type * get_values () noexcept
 
const value_type * get_const_values () const noexcept
 
void rapply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const
 
void inverse_apply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const
 
void read (const mat_data &data) override
 
void read (const mat_data32 &data) override
 
void read (const device_mat_data &data) override
 
void read (const device_mat_data32 &data) override
 
void read (device_mat_data &&data) override
 
void read (device_mat_data32 &&data) override
 
void write (mat_data &data) const override
 
void write (mat_data32 &data) const override
 
- Public Member Functions inherited from gko::EnableLinOp< ConcreteLinOp, PolymorphicBase >
const ConcreteLinOp * apply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const
 
ConcreteLinOp * apply (ptr_param< const LinOp > b, ptr_param< LinOp > x)
 
const ConcreteLinOp * apply (ptr_param< const LinOp > alpha, ptr_param< const LinOp > b, ptr_param< const LinOp > beta, ptr_param< LinOp > x) const
 
ConcreteLinOp * apply (ptr_param< const LinOp > alpha, ptr_param< const LinOp > b, ptr_param< const LinOp > beta, ptr_param< LinOp > x)
 
- 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< ConcreteLinOp >
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)
 
- Public Member Functions inherited from gko::WritableToMatrixData< ValueType, IndexType >
virtual void write (matrix_data< ValueType, IndexType > &data) const =0
 
- Public Member Functions inherited from gko::ReadableFromMatrixData< ValueType, IndexType >
virtual void read (const matrix_data< ValueType, IndexType > &data)=0
 
void read (const matrix_assembly_data< ValueType, IndexType > &data)
 
virtual void read (const device_matrix_data< ValueType, IndexType > &data)
 
virtual void read (device_matrix_data< ValueType, IndexType > &&data)
 
- Public Member Functions inherited from gko::EnableAbsoluteComputation< AbsoluteLinOp >
std::unique_ptr< LinOpcompute_absolute_linop () const override
 

Static Public Member Functions

static std::unique_ptr< Diagonalcreate (std::shared_ptr< const Executor > exec, size_type size=0)
 
static std::unique_ptr< Diagonalcreate (std::shared_ptr< const Executor > exec, const size_type size, array< value_type > values)
 
template<typename InputValueType >
static std::unique_ptr< Diagonalcreate (std::shared_ptr< const Executor > exec, const size_type size, std::initializer_list< InputValueType > values)
 create(std::shared_ptr<constExecutor>, const size_type, array<value_type>)
 
static std::unique_ptr< const Diagonalcreate_const (std::shared_ptr< const Executor > exec, size_type size, gko::detail::const_array_view< ValueType > &&values)
 

Protected Member Functions

 Diagonal (std::shared_ptr< const Executor > exec, size_type size=0)
 
 Diagonal (std::shared_ptr< const Executor > exec, const size_type size, array< value_type > values)
 
void apply_impl (const LinOp *b, LinOp *x) const override
 
void apply_impl (const LinOp *alpha, const LinOp *b, const LinOp *beta, LinOp *x) const override
 
void rapply_impl (const LinOp *b, LinOp *x) const
 
void inverse_apply_impl (const LinOp *b, LinOp *x) const
 
- Protected Member Functions inherited from gko::EnableLinOp< ConcreteLinOp, PolymorphicBase >
ConcreteLinOp * self () noexcept
 
const ConcreteLinOp * self () const noexcept
 
- 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
 

Friends

class EnablePolymorphicObject< Diagonal, LinOp >
 
class Csr< ValueType, int32 >
 
class Csr< ValueType, int64 >
 
class Diagonal< to_complex< ValueType > >
 
class Diagonal< previous_precision< ValueType > >
 
class Diagonal< previous_precision< previous_precision< ValueType > > >
 

Additional Inherited Members

- Protected Attributes inherited from gko::log::EnableLogging< PolymorphicObject >
std::vector< std::shared_ptr< const Logger > > loggers_
 

Detailed Description

template<typename ValueType = default_precision>
class gko::matrix::Diagonal< ValueType >

This class is a utility which efficiently implements the diagonal matrix (a linear operator which scales a vector row wise).

Objects of the Diagonal class always represent a square matrix, and require one array to store their values.

Template Parameters
ValueTypeprecision of matrix elements
IndexTypeprecision of matrix indexes of a CSR matrix the diagonal is applied or converted to.

Member Function Documentation

◆ compute_absolute()

template<typename ValueType = default_precision>
std::unique_ptr< absolute_type > gko::matrix::Diagonal< ValueType >::compute_absolute ( ) const
overridevirtual

Gets the AbsoluteLinOp

Returns
a pointer to the new absolute object

Implements gko::EnableAbsoluteComputation< AbsoluteLinOp >.

◆ compute_absolute_inplace()

template<typename ValueType = default_precision>
void gko::matrix::Diagonal< ValueType >::compute_absolute_inplace ( )
overridevirtual

Compute absolute inplace on each element.

Implements gko::AbsoluteComputable.

◆ conj_transpose()

template<typename ValueType = default_precision>
std::unique_ptr< LinOp > gko::matrix::Diagonal< ValueType >::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/3]

template<typename ValueType = default_precision>
static std::unique_ptr< Diagonal > gko::matrix::Diagonal< ValueType >::create ( std::shared_ptr< const Executor exec,
const size_type  size,
array< value_type >  values 
)
static

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

Parameters
execExecutor associated to the matrix
sizesize of the matrix
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< Diagonal > gko::matrix::Diagonal< ValueType >::create ( std::shared_ptr< const Executor exec,
const size_type  size,
std::initializer_list< InputValueType >  values 
)
inlinestatic

create(std::shared_ptr<constExecutor>, const size_type, array<value_type>)

create(std::shared_ptr<constExecutor>, const size_type, array<value_type>)

References gko::matrix::Diagonal< ValueType >::create().

◆ create() [3/3]

template<typename ValueType = default_precision>
static std::unique_ptr< Diagonal > gko::matrix::Diagonal< ValueType >::create ( std::shared_ptr< const Executor exec,
size_type  size = 0 
)
static

Creates an Diagonal 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::matrix::Diagonal< ValueType >::create().

◆ create_const()

template<typename ValueType = default_precision>
static std::unique_ptr< const Diagonal > gko::matrix::Diagonal< ValueType >::create_const ( std::shared_ptr< const Executor exec,
size_type  size,
gko::detail::const_array_view< ValueType > &&  values 
)
static

Creates a constant (immutable) Diagonal matrix from a constant array.

Parameters
execthe executor to create the matrix on
sizethe size of the square 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.

◆ get_const_values()

template<typename ValueType = default_precision>
const value_type * gko::matrix::Diagonal< ValueType >::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_values()

template<typename ValueType = default_precision>
value_type * gko::matrix::Diagonal< ValueType >::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().

◆ inverse_apply()

template<typename ValueType = default_precision>
void gko::matrix::Diagonal< ValueType >::inverse_apply ( ptr_param< const LinOp b,
ptr_param< LinOp x 
) const
inline

Applies the inverse of the diagonal matrix to a matrix b, which means scales the columns of b with the inverse of the according diagonal entries.

Parameters
bthe input vector(s) on which the inverse of the diagonal matrix is applied
xthe output vector(s) where the result is stored

References gko::ptr_param< T >::get().

◆ rapply()

template<typename ValueType = default_precision>
void gko::matrix::Diagonal< ValueType >::rapply ( ptr_param< const LinOp b,
ptr_param< LinOp x 
) const
inline

Applies the diagonal matrix from the right side to a matrix b, which means scales the columns of b with the according diagonal entries.

Parameters
bthe input vector(s) on which the diagonal matrix is applied
xthe output vector(s) where the result is stored

References gko::ptr_param< T >::get().

◆ transpose()

template<typename ValueType = default_precision>
std::unique_ptr< LinOp > gko::matrix::Diagonal< ValueType >::transpose ( ) const
overridevirtual

Returns a LinOp representing the transpose of the Transposable object.

Returns
a pointer to the new transposed object

Implements gko::Transposable.


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