Ginkgo: gko::matrix::Diagonal< ValueType > 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::Diagonal< ValueType > Class Template Reference
Linear Operators » SpMV employing different Matrix formats | Linear Operators

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< Diagonal< default_precision > >
using | result_type
Public Types inherited from gko::WritableToMatrixData< default_precision, int32 >
using | value_type
using | index_type
Public Types inherited from gko::WritableToMatrixData< default_precision, int64 >
using | value_type
using | index_type
Public Types inherited from gko::ReadableFromMatrixData< default_precision, int32 >
using | value_type
using | index_type
Public Types inherited from gko::ReadableFromMatrixData< default_precision, int64 >
using | value_type
using | index_type
Public Types inherited from gko::EnableAbsoluteComputation< remove_complex< Diagonal< default_precision > > >
using | absolute_type

## Public Member Functions
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.
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< Diagonal< default_precision > >
const Diagonal< default_precision > * | apply (ptr_param< const LinOp > b, ptr_param< LinOp > x) const
Public Member Functions inherited from gko::EnablePolymorphicAssignment< Diagonal< default_precision > >
void | convert_to (result_type *result) const override
void | move_to (result_type *result) override
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::WritableToMatrixData< default_precision, int64 >
virtual void | write (matrix_data< default_precision, int64 > &data) const=0
| Writes a matrix to a matrix_data structure.
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::ReadableFromMatrixData< default_precision, int64 >
virtual void | read (const matrix_data< default_precision, int64 > &data)=0
| Reads a matrix from a matrix_data structure.
Public Member Functions inherited from gko::EnableAbsoluteComputation< remove_complex< Diagonal< default_precision > > >
std::unique_ptr< LinOp > | compute_absolute_linop () const override
| Gets the absolute LinOp.

## Static Public Member Functions
static std::unique_ptr< Diagonal > | create (std::shared_ptr< const Executor > exec, size_type size=0)
| Creates an Diagonal matrix of the specified size.
static std::unique_ptr< Diagonal > | create (std::shared_ptr< const Executor > exec, const size_type size, array< value_type > values)
| Creates a Diagonal matrix from an already allocated (and initialized) array.
template<typename InputValueType>
static std::unique_ptr< Diagonal > | create (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 Diagonal > | create_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.

## Friends
class | EnablePolymorphicObject< Diagonal, LinOp >
class | Csr< ValueType, int32 >
class | Csr< ValueType, int64 >
class | Diagonal< to_complex< ValueType > >
class | Diagonal< previous_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

  ValueType | precision of matrix elements
  IndexType | precision 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< remove_complex< Diagonal< default_precision > > >.

## ◆ 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>

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

  exec | Executor associated to the matrix
  size | size of the matrix
  values | array 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>

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

## ◆ create() [3/3]

template<typename ValueType = default_precision>

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

  exec | Executor associated to the matrix
  size | size of the matrix

Returns
  A smart pointer to the newly created matrix.

Referenced by create().

## ◆ create_const()

template<typename ValueType = default_precision>

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

  exec | the executor to create the matrix on
  size | the size of the square matrix
  values | the 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.

## ◆ 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

## ◆ 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

  b | the input vector(s) on which the inverse of the diagonal matrix is applied
  x | the output vector(s) where the result is stored

## ◆ 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

  b | the input vector(s) on which the diagonal matrix is applied
  x | the output vector(s) where the result is stored

## ◆ 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:

- ginkgo/core/base/lin_op.hpp
- ginkgo/core/matrix/diagonal.hpp