 |
Ginkgo
Generated from pipelines/3133041809 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
|
10 #include <ginkgo/config.hpp>
11 #include <ginkgo/core/base/math.hpp>
12 #include <ginkgo/core/base/precision.hpp>
13 #include <ginkgo/core/base/range.hpp>
14 #include <ginkgo/core/base/temporary_conversion.hpp>
15 #include <ginkgo/core/base/type_traits.hpp>
16 #include <ginkgo/core/matrix/device_views.hpp>
23 template <
typename ValueType>
38 using variant_type = syn::variant_from_list<supported_value_types>;
42 std::enable_if_t<std::is_constructible_v<variant_type, T&&>,
int> = 0>
43 any_scalar(T&& value) : variant(std::forward<T>(value))
48 std::enable_if_t<!std::is_constructible_v<variant_type, T&&> &&
49 std::is_convertible_v<T, double>,
51 any_scalar(T&& value) : variant(static_cast<double>(value))
83 template <
typename ValueType>
94 [[nodiscard]]
static std::unique_ptr<AbstractMultiVector>
108 [[nodiscard]]
static std::unique_ptr<AbstractMultiVector>
110 std::shared_ptr<const Executor> exec);
129 [[nodiscard]]
static std::unique_ptr<AbstractMultiVector>
131 std::shared_ptr<const Executor> exec,
149 [[nodiscard]]
static std::unique_ptr<AbstractMultiVector>
151 std::shared_ptr<const Executor> exec,
162 [[nodiscard]] std::unique_ptr<AbstractMultiVector>
clone(
163 std::shared_ptr<const Executor> exec)
const;
170 [[nodiscard]] std::unique_ptr<AbstractMultiVector>
clone()
const;
205 [[nodiscard]] std::unique_ptr<AbstractMultiVector>
create_default(
206 std::shared_ptr<const Executor> exec)
const;
214 [[nodiscard]] std::unique_ptr<AbstractMultiVector>
create_default()
const;
225 [[nodiscard]] std::unique_ptr<AbstractMultiVector>
compute_absolute()
const;
257 [[nodiscard]] std::unique_ptr<AbstractMultiVector>
make_complex()
const;
279 [[nodiscard]] std::unique_ptr<AbstractMultiVector>
get_real()
const;
301 [[nodiscard]] std::unique_ptr<AbstractMultiVector>
get_imag()
const;
542 [[nodiscard]] std::unique_ptr<AbstractMultiVector>
create_subview(
551 [[nodiscard]] std::unique_ptr<const AbstractMultiVector>
create_subview(
555 [[nodiscard]] std::unique_ptr<AbstractMultiVector>
create_subview(
561 [[nodiscard]] std::unique_ptr<const AbstractMultiVector>
create_subview(
575 template <
typename ValueType>
579 template <
typename ValueType>
668 [[nodiscard]]
virtual std::unique_ptr<AbstractMultiVector>
669 create_generic_with_same_config_impl()
const = 0;
671 [[nodiscard]]
virtual std::unique_ptr<AbstractMultiVector>
672 create_generic_with_type_of_impl(std::shared_ptr<const Executor> exec,
673 const dim<2>& global_size,
677 [[nodiscard]]
virtual std::unique_ptr<AbstractMultiVector>
678 compute_absolute_generic_impl()
const = 0;
680 virtual void compute_absolute_generic_impl(
683 virtual void compute_absolute_inplace_impl() = 0;
685 [[nodiscard]]
virtual std::unique_ptr<AbstractMultiVector>
686 make_complex_generic_impl()
const = 0;
688 virtual void make_complex_generic_impl(
691 [[nodiscard]]
virtual std::unique_ptr<AbstractMultiVector>
692 get_real_generic_impl()
const = 0;
696 [[nodiscard]]
virtual std::unique_ptr<AbstractMultiVector>
697 get_imag_generic_impl()
const = 0;
730 [[nodiscard]]
virtual std::unique_ptr<const AbstractMultiVector>
731 create_real_view_generic_impl()
const = 0;
733 [[nodiscard]]
virtual std::unique_ptr<AbstractMultiVector>
734 create_real_view_generic_impl() = 0;
736 [[nodiscard]]
virtual std::unique_ptr<AbstractMultiVector>
739 [[nodiscard]]
virtual std::unique_ptr<const AbstractMultiVector>
742 [[nodiscard]]
virtual std::unique_ptr<AbstractMultiVector>
746 [[nodiscard]]
virtual std::unique_ptr<const AbstractMultiVector>
748 dim<2> global_size)
const = 0;
750 [[nodiscard]]
virtual std::variant<
751 #if GINKGO_ENABLE_HALF
754 #if GINKGO_ENABLE_BFLOAT16
759 get_local_device_view_generic_impl() = 0;
761 [[nodiscard]]
virtual std::variant<
762 #if GINKGO_ENABLE_HALF
765 #if GINKGO_ENABLE_BFLOAT16
770 get_const_local_device_view_generic_impl()
const = 0;
776 as_precision_impl(
precision p)
const = 0;
778 void set_size(
const dim<2>& global_size,
const dim<2>& local_size);
Non-owning view of a matrix::MultiVector to be used inside device kernels.
Definition: device_views.hpp:27
dim< 2 > get_local_size() const noexcept
Gets the size (number of rows and columns) locally owned by this vector.
std::unique_ptr< AbstractMultiVector > clone() const
Creates a copy of this vector on this vector's executor.
static std::unique_ptr< AbstractMultiVector > create_with_config_of(ptr_param< const AbstractMultiVector > other)
Creates an empty multi-vector with the same type, executor, size, stride and precision as other.
void compute_squared_norm2(ptr_param< AbstractMultiVector > result) const
Computes the square of the column-wise Euclidean (L^2) norm of this.
AbstractMultiVector & operator=(const AbstractMultiVector &other)
Copies the contents of another multi-vector.
void compute_norm2(ptr_param< AbstractMultiVector > result) const
Computes the column-wise Euclidean (L^2) norm of this.
std::unique_ptr< AbstractMultiVector > get_imag() const
Creates a new real vector with the imaginary parts of this vector.
device_view< const ValueType > get_const_local_device_view() const
Gets a local device view of this vector for the specified value type.
A PolymorphicObject is the abstract base for all "heavy" objects in Ginkgo that behave polymorphicall...
Definition: polymorphic_object.hpp:46
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:102
void compute_norm1(ptr_param< AbstractMultiVector > result) const
Computes the column-wise (L^1) norm of this.
static std::unique_ptr< AbstractMultiVector > create_with_type_of(ptr_param< const AbstractMultiVector > other, std::shared_ptr< const Executor > exec)
Creates an empty multi-vector with the same type as other on exec.
temporary_conversion< AbstractMultiVector > as_precision(precision p)
Creates a temporary conversion of this vector with another precision.
void compute_dot(ptr_param< const AbstractMultiVector > b, ptr_param< AbstractMultiVector > result) const
Computes the column-wise dot product of this and b.
std::unique_ptr< const AbstractMultiVector > create_real_view() const
Create a real view of the (potentially) complex original multi-vector.
Helper type for type-erased scalar arguments.
Definition: multivector.hpp:37
precision
An enum to specify the precision of stored data.
Definition: precision.hpp:19
void inv_scale(ptr_param< const AbstractMultiVector > alpha)
Divides this multi-vector element-wise by alpha.
dim< 2 > get_size() const noexcept
Gets the size (number of rows and columns) of this vector.
device_view< ValueType > get_local_device_view()
Gets a local device view of this vector for the specified value type.
The Ginkgo namespace.
Definition: abstract_factory.hpp:19
std::unique_ptr< AbstractMultiVector > make_complex() const
Creates a complex copy of this vector.
This class is used for function parameters in the place of raw pointers.
Definition: utils_helper.hpp:43
void add_scaled(ptr_param< const AbstractMultiVector > alpha, ptr_param< const AbstractMultiVector > b)
Adds b scaled by alpha to this (aka: BLAS axpy).
void sub_scaled(ptr_param< const AbstractMultiVector > alpha, ptr_param< const AbstractMultiVector > b)
Subtracts b scaled by alpha from this (aka: BLAS axpy).
std::unique_ptr< AbstractMultiVector > get_real() const
Creates a new real vector with the real parts of this vector.
std::unique_ptr< AbstractMultiVector > create_subview(local_span rows, local_span columns)
Creates a view containing the selected local rows and columns.
std::unique_ptr< AbstractMultiVector > create_default() const
Creates an empty vector with the same type as this vector on this vector's executor.
Interface for objects that can be cloned.
Definition: polymorphic_object.hpp:305
void compute_absolute_inplace()
Replaces each element of this vector with its absolute value.
AbstractMultiVector * move_from(ptr_param< AbstractMultiVector > other)
Moves the data of other into this vector.
A temporary_conversion is a special smart pointer-like object that is designed to hold an object temp...
Definition: temporary_conversion.hpp:129
void scale(ptr_param< const AbstractMultiVector > alpha)
Scales this multi-vector element-wise by alpha.
AbstractMultiVector * copy_from(ptr_param< const AbstractMultiVector > other)
Copies the data of other into this vector.
Abstract interface class for (multi-)vector types.
Definition: multivector.hpp:81
Same as span, except that it only represents a range of local rows/columns, and that it is copyable/m...
Definition: range.hpp:138
std::unique_ptr< AbstractMultiVector > compute_absolute() const
Creates a new vector with the element-wise absolute values of this vector.
precision get_precision() const noexcept
Gets the precision of this vector.
void compute_conj_dot(ptr_param< const AbstractMultiVector > b, ptr_param< AbstractMultiVector > result) const
Computes the column-wise dot product of conj(this) and b.
void fill(any_scalar value)
Fills this vector with a single value.