33#ifndef GKO_PUBLIC_CORE_BASE_BATCH_MULTI_VECTOR_HPP_
34#define GKO_PUBLIC_CORE_BASE_BATCH_MULTI_VECTOR_HPP_
37#include <initializer_list>
41#include <ginkgo/core/base/array.hpp>
42#include <ginkgo/core/base/batch_dim.hpp>
43#include <ginkgo/core/base/dim.hpp>
44#include <ginkgo/core/base/executor.hpp>
45#include <ginkgo/core/base/mtx_io.hpp>
46#include <ginkgo/core/base/polymorphic_object.hpp>
47#include <ginkgo/core/base/range_accessors.hpp>
48#include <ginkgo/core/base/types.hpp>
49#include <ginkgo/core/base/utils.hpp>
50#include <ginkgo/core/matrix/dense.hpp>
80template <
typename ValueType = default_precision>
85 public ConvertibleTo<MultiVector<next_precision<ValueType>>> {
97 using value_type = ValueType;
98 using index_type =
int32;
361 gko::detail::const_array_view<ValueType>&& values);
409 template <
typename ValuesArray>
410 MultiVector(std::shared_ptr<const Executor> exec,
const batch_dim<2>& size,
417 auto num_elems = compute_num_elems(size);
428 std::unique_ptr<MultiVector> create_with_same_config()
const;
444 batch_dim<2> batch_size_;
445 array<value_type> values_;
ConvertibleTo interface is used to mark that the implementer can be converted to the object of Result...
Definition polymorphic_object.hpp:499
This mixin implements a static create() method on ConcreteType that dynamically allocates the memory,...
Definition polymorphic_object.hpp:776
This mixin is used to enable a default PolymorphicObject::copy_from() implementation for objects that...
Definition polymorphic_object.hpp:752
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:691
value_type * get_data() noexcept
Returns a pointer to the block of memory used to store the elements of the array.
Definition array.hpp:646
const value_type * get_const_data() const noexcept
Returns a constant pointer to the block of memory used to store the elements of the array.
Definition array.hpp:655
size_type get_num_elems() const noexcept
Returns the number of elements in the array.
Definition array.hpp:637
MultiVector stores multiple vectors in a batched fashion and is useful for batched operations.
Definition batch_multi_vector.hpp:85
value_type * get_values_for_item(size_type batch_id) noexcept
Returns a pointer to the array of values of the multi-vector for a specific batch item.
Definition batch_multi_vector.hpp:186
void compute_conj_dot(ptr_param< const MultiVector< ValueType > > b, ptr_param< MultiVector< ValueType > > result) const
Computes the column-wise conjugate dot product of each multi-vector in this batch and its correspondi...
size_type get_cumulative_offset(size_type batch_id) const
Get the cumulative storage size offset.
Definition batch_multi_vector.hpp:225
const value_type * get_const_values_for_item(size_type batch_id) const noexcept
Returns a pointer to the array of values of the multi-vector for a specific batch item.
Definition batch_multi_vector.hpp:199
void scale(ptr_param< const MultiVector< ValueType > > alpha)
Scales the vector with a scalar (aka: BLAS scal).
value_type * get_values() noexcept
Returns a pointer to the array of values of the multi-vector.
Definition batch_multi_vector.hpp:164
dim< 2 > get_common_size() const
Returns the common size of the batch items.
Definition batch_multi_vector.hpp:157
void compute_dot(ptr_param< const MultiVector< ValueType > > b, ptr_param< MultiVector< ValueType > > result) const
Computes the column-wise dot product of each multi-vector in this batch and its corresponding entry i...
void fill(ValueType value)
Fills the input MultiVector with a given value.
static std::unique_ptr< const MultiVector< ValueType > > create_const(std::shared_ptr< const Executor > exec, const batch_dim< 2 > &sizes, gko::detail::const_array_view< ValueType > &&values)
Creates a constant (immutable) batch multi-vector from a constant array.
ValueType & at(size_type batch_id, size_type idx) noexcept
Returns a single element for a particular batch item.
Definition batch_multi_vector.hpp:271
size_type get_num_batch_items() const
Returns the number of batch items.
Definition batch_multi_vector.hpp:147
size_type get_num_stored_elements() const noexcept
Returns the number of elements explicitly stored in the batch matrix, cumulative across all the batch...
Definition batch_multi_vector.hpp:213
ValueType at(size_type batch_id, size_type idx) const noexcept
Returns a single element for a particular batch item.
Definition batch_multi_vector.hpp:279
batch_dim< 2 > get_size() const
Returns the batch size.
Definition batch_multi_vector.hpp:140
std::unique_ptr< unbatch_type > create_view_for_item(size_type item_id)
Creates a mutable view (of matrix::Dense type) of one item of the Batch MultiVector object.
const value_type * get_const_values() const noexcept
Returns a pointer to the array of values of the multi-vector.
Definition batch_multi_vector.hpp:173
void add_scaled(ptr_param< const MultiVector< ValueType > > alpha, ptr_param< const MultiVector< ValueType > > b)
Adds b scaled by alpha to the vector (aka: BLAS axpy).
void compute_norm2(ptr_param< MultiVector< remove_complex< ValueType > > > result) const
Computes the Euclidean (L^2) norm of each multi-vector in this batch.
value_type at(size_type batch_id, size_type row, size_type col) const
Returns a single element for a particular batch item.
Definition batch_multi_vector.hpp:251
static std::unique_ptr< MultiVector > create_with_config_of(ptr_param< const MultiVector > other)
Creates a MultiVector with the configuration of another MultiVector.
value_type & at(size_type batch_id, size_type row, size_type col)
Returns a single element for a particular batch item.
Definition batch_multi_vector.hpp:242
std::unique_ptr< const unbatch_type > create_const_view_for_item(size_type item_id) const
Creates a mutable view (of matrix::Dense type) of one item of the Batch MultiVector object.
Dense is a matrix format which explicitly stores all values of the matrix.
Definition dense.hpp:136
This class is used for function parameters in the place of raw pointers.
Definition utils_helper.hpp:71
The Ginkgo namespace.
Definition abstract_factory.hpp:48
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:803
typename detail::remove_complex_s< T >::type remove_complex
Obtain the type which removed the complex of complex/scalar type or the template parameter of class b...
Definition math.hpp:354
std::int32_t int32
32-bit signed integral type.
Definition types.hpp:137
typename detail::next_precision_impl< T >::type next_precision
Obtains the next type in the singly-linked precision list.
Definition math.hpp:490
typename detail::to_complex_s< T >::type to_complex
Obtain the type which adds the complex of complex/scalar type or the template parameter of class by a...
Definition math.hpp:373
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:120
A type representing the dimensions of a multidimensional batch object.
Definition batch_dim.hpp:56
dim< dimensionality, dimension_type > get_common_size() const
Get the common size of the batch items.
Definition batch_dim.hpp:72
size_type get_num_batch_items() const
Get the number of batch items stored.
Definition batch_dim.hpp:65
A type representing the dimensions of a multidimensional object.
Definition dim.hpp:55