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
batch_identity.hpp
1/*******************************<GINKGO LICENSE>******************************
2Copyright (c) 2017-2023, the Ginkgo authors
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions
7are met:
8
91. Redistributions of source code must retain the above copyright
10notice, this list of conditions and the following disclaimer.
11
122. Redistributions in binary form must reproduce the above copyright
13notice, this list of conditions and the following disclaimer in the
14documentation and/or other materials provided with the distribution.
15
163. Neither the name of the copyright holder nor the names of its
17contributors may be used to endorse or promote products derived from
18this software without specific prior written permission.
19
20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31******************************<GINKGO LICENSE>*******************************/
32
33#ifndef GKO_PUBLIC_CORE_MATRIX_BATCH_IDENTITY_HPP_
34#define GKO_PUBLIC_CORE_MATRIX_BATCH_IDENTITY_HPP_
35
36
37#include <ginkgo/core/base/batch_lin_op.hpp>
38#include <ginkgo/core/base/batch_multi_vector.hpp>
39#include <ginkgo/core/base/executor.hpp>
40#include <ginkgo/core/base/types.hpp>
41#include <ginkgo/core/base/utils.hpp>
42#include <ginkgo/core/matrix/identity.hpp>
43
44
45namespace gko {
46namespace batch {
47namespace matrix {
48
49
59template <typename ValueType = default_precision>
60class Identity final : public EnableBatchLinOp<Identity<ValueType>>,
61 public EnableCreateMethod<Identity<ValueType>> {
62 friend class EnableCreateMethod<Identity>;
64
65public:
68
69 using value_type = ValueType;
70 using index_type = int32;
72 using absolute_type = remove_complex<Identity>;
73 using complex_type = to_complex<Identity>;
74
84
99
105
115
116private:
123 Identity(std::shared_ptr<const Executor> exec,
124 const batch_dim<2>& size = batch_dim<2>{});
125
126 void apply_impl(const MultiVector<value_type>* b,
127 MultiVector<value_type>* x) const;
128
129 void apply_impl(const MultiVector<value_type>* alpha,
131 const MultiVector<value_type>* beta,
132 MultiVector<value_type>* x) const;
133};
134
135
136} // namespace matrix
137} // namespace batch
138} // namespace gko
139
140
141#endif // GKO_PUBLIC_CORE_MATRIX_BATCH_IDENTITY_HPP_
This mixin implements a static create() method on ConcreteType that dynamically allocates the memory,...
Definition polymorphic_object.hpp:776
void move_to(result_type *result) override
Definition polymorphic_object.hpp:760
void convert_to(result_type *result) const override
Definition polymorphic_object.hpp:758
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:691
Definition batch_lin_op.hpp:88
The EnableBatchLinOp mixin can be used to provide sensible default implementations of the majority of...
Definition batch_lin_op.hpp:281
MultiVector stores multiple vectors in a batched fashion and is useful for batched operations.
Definition batch_multi_vector.hpp:85
The batch Identity matrix, which represents a batch of Identity matrices.
Definition batch_identity.hpp:61
Identity * apply(ptr_param< const MultiVector< value_type > > alpha, ptr_param< const MultiVector< value_type > > b, ptr_param< const MultiVector< value_type > > beta, ptr_param< MultiVector< value_type > > x)
Apply the matrix to a multi-vector with a linear combination of the given input vector.
const Identity * apply(ptr_param< const MultiVector< value_type > > alpha, ptr_param< const MultiVector< value_type > > b, ptr_param< const MultiVector< value_type > > beta, ptr_param< MultiVector< value_type > > x) const
Identity * apply(ptr_param< const MultiVector< value_type > > b, ptr_param< MultiVector< value_type > > x)
Apply the matrix to a multi-vector.
const Identity * apply(ptr_param< const MultiVector< value_type > > b, ptr_param< MultiVector< value_type > > x) const
This class is a utility which efficiently implements the identity matrix (a linear operator which map...
Definition identity.hpp:65
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::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
A type representing the dimensions of a multidimensional batch object.
Definition batch_dim.hpp:56