Ginkgo Generated from branch based on master. Ginkgo version 1.7.0
A numerical linear algebra library targeting many-core architectures
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
gko::matrix::Diagonal< ValueType > Class Template Reference

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

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

Inheritance diagram for gko::matrix::Diagonal< ValueType >:
[legend]
Collaboration 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
 
- 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
 Returns a LinOp representing the transpose of the Transposable object.
 
std::unique_ptr< LinOpconj_transpose () const override
 Returns a LinOp representing the conjugate transpose of the Transposable object.
 
void convert_to (Diagonal< next_precision< ValueType > > *result) const override
 
void move_to (Diagonal< 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
 Gets the AbsoluteLinOp.
 
void compute_absolute_inplace () override
 Compute absolute inplace on each element.
 
value_type * get_values () noexcept
 Returns a pointer to the array of values of the matrix.
 
const value_type * get_const_values () const noexcept
 Returns a pointer to the array of values of the matrix.
 
void rapply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const
 Applies the diagonal matrix from the right side to a matrix b, which means scales the columns of b with the according diagonal entries.
 
void inverse_apply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const
 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.
 
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 ConcreteLinOpapply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const
 
ConcreteLinOpapply (ptr_param< const LinOp > b, ptr_param< LinOp > x)
 
const ConcreteLinOpapply (ptr_param< const LinOp > alpha, ptr_param< const LinOp > b, ptr_param< const LinOp > beta, ptr_param< LinOp > x) const
 
ConcreteLinOpapply (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< AbstractObjectcreate_default (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< AbstractObjectcreate_default () const
 
std::unique_ptr< AbstractObjectclone (std::shared_ptr< const Executor > exec) const
 
std::unique_ptr< AbstractObjectclone () const
 
AbstractObjectcopy_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)
 
AbstractObjectcopy_from (const std::shared_ptr< const PolymorphicObject > &other)
 
AbstractObjectmove_from (ptr_param< PolymorphicObject > other)
 
AbstractObjectclear ()
 
- Public Member Functions inherited from gko::PolymorphicObject
PolymorphicObjectoperator= (const PolymorphicObject &)
 
std::unique_ptr< PolymorphicObjectcreate_default (std::shared_ptr< const Executor > exec) const
 Creates a new "default" object of the same dynamic type as this object.
 
std::unique_ptr< PolymorphicObjectcreate_default () const
 Creates a new "default" object of the same dynamic type as this object.
 
std::unique_ptr< PolymorphicObjectclone (std::shared_ptr< const Executor > exec) const
 Creates a clone of the object.
 
std::unique_ptr< PolymorphicObjectclone () const
 Creates a clone of the object.
 
PolymorphicObjectcopy_from (const PolymorphicObject *other)
 Copies another object into this object.
 
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)
 Moves another object into this object.
 
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)
 Copies another object into this object.
 
PolymorphicObjectcopy_from (const std::shared_ptr< const PolymorphicObject > &other)
 Copies another object into this object.
 
PolymorphicObjectmove_from (ptr_param< PolymorphicObject > other)
 Moves another object into this object.
 
PolymorphicObjectclear ()
 Transforms the object into its default state.
 
std::shared_ptr< const Executorget_executor () const noexcept
 Returns the Executor of the object.
 
- Public Member Functions inherited from gko::log::EnableLogging< PolymorphicObject >
void add_logger (std::shared_ptr< const Logger > logger) override
 Adds a new logger to the list of subscribed loggers.
 
void remove_logger (const Logger *logger) override
 Removes a logger from the list of subscribed loggers.
 
void remove_logger (ptr_param< const Logger > logger)
 
const std::vector< std::shared_ptr< const Logger > > & get_loggers () const override
 Returns the vector containing all loggers registered at this object.
 
void clear_loggers () override
 Remove all loggers registered at this object.
 
- 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
 Converts the implementer to an object of type result_type.
 
void move_to (result_type *result) override
 Converts the implementer to an object of type result_type by moving data from this object.
 
- Public Member Functions inherited from gko::ConvertibleTo< ResultType >
virtual void convert_to (result_type *result) const =0
 Converts the implementer to an object of type result_type.
 
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.
 
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
 Writes a matrix to a matrix_data structure.
 
- Public Member Functions inherited from gko::ReadableFromMatrixData< ValueType, IndexType >
virtual void read (const matrix_data< ValueType, IndexType > &data)=0
 Reads a matrix from a matrix_data structure.
 
void read (const matrix_assembly_data< ValueType, IndexType > &data)
 Reads a matrix from a matrix_assembly_data structure.
 
virtual void read (const device_matrix_data< ValueType, IndexType > &data)
 Reads a matrix from a device_matrix_data structure.
 
virtual void read (device_matrix_data< ValueType, IndexType > &&data)
 Reads a matrix from a device_matrix_data structure.
 
- Public Member Functions inherited from gko::EnableAbsoluteComputation< AbsoluteLinOp >
std::unique_ptr< LinOpcompute_absolute_linop () const override
 Gets the absolute LinOp.
 

Static Public Member Functions

static std::unique_ptr< const Diagonalcreate_const (std::shared_ptr< const Executor > exec, size_type size, gko::detail::const_array_view< ValueType > &&values)
 Creates a constant (immutable) Diagonal matrix from a constant array.
 
- Static Public Member Functions inherited from gko::EnableCreateMethod< ConcreteType >
template<typename... Args>
static std::unique_ptr< ConcreteTypecreate (Args &&... args)
 

Friends

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

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_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 )
inlinestatic

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: