ginkgo/core/matrix/scaled_permutation.hpp Source File

ginkgo/core/matrix/scaled_permutation.hpp Source File#

Reference API: ginkgo/core/matrix/scaled_permutation.hpp Source File
Reference API
scaled_permutation.hpp
1// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifndef GKO_PUBLIC_CORE_MATRIX_SCALED_PERMUTATION_HPP_
6#define GKO_PUBLIC_CORE_MATRIX_SCALED_PERMUTATION_HPP_
7
8
9#include <memory>
10
11#include <ginkgo/core/base/array.hpp>
12#include <ginkgo/core/base/executor.hpp>
13#include <ginkgo/core/base/lin_op.hpp>
14#include <ginkgo/core/base/types.hpp>
15#include <ginkgo/core/base/utils.hpp>
16#include <ginkgo/core/matrix/permutation.hpp>
17
18
19namespace gko {
20namespace matrix {
21
22
34template <typename ValueType = default_precision, typename IndexType = int32>
36 : public EnableLinOp<ScaledPermutation<ValueType, IndexType>>,
37 public WritableToMatrixData<ValueType, IndexType> {
39
40public:
41 using value_type = ValueType;
42 using index_type = IndexType;
43
49 value_type* get_scaling_factors() noexcept { return scale_.get_data(); }
50
58 const value_type* get_const_scaling_factors() const noexcept
59 {
60 return scale_.get_const_data();
61 }
62
68 index_type* get_permutation() noexcept { return permutation_.get_data(); }
69
77 const index_type* get_const_permutation() const noexcept
78 {
79 return permutation_.get_const_data();
80 }
81
90 std::unique_ptr<ScaledPermutation> compute_inverse() const;
91
100 std::unique_ptr<ScaledPermutation> compose(
102
104
113 static std::unique_ptr<ScaledPermutation> create(
114 std::shared_ptr<const Executor> exec, size_type size = 0);
115
124 static std::unique_ptr<ScaledPermutation> create(
125 ptr_param<const Permutation<IndexType>> permutation);
126
136 static std::unique_ptr<ScaledPermutation> create(
137 std::shared_ptr<const Executor> exec, array<value_type> scaling_factors,
138 array<index_type> permutation_indices);
139
151 static std::unique_ptr<const ScaledPermutation> create_const(
152 std::shared_ptr<const Executor> exec,
153 gko::detail::const_array_view<value_type>&& scale,
154 gko::detail::const_array_view<index_type>&& perm_idxs);
155
156private:
157 ScaledPermutation(std::shared_ptr<const Executor> exec, size_type size = 0);
158
159 ScaledPermutation(std::shared_ptr<const Executor> exec,
160 array<value_type> scaling_factors,
161 array<index_type> permutation_indices);
162
163 void apply_impl(const LinOp* in, LinOp* out) const override;
164
165 void apply_impl(const LinOp*, const LinOp* in, const LinOp*,
166 LinOp* out) const override;
167
168 array<value_type> scale_;
169 array<index_type> permutation_;
170};
171
172
173} // namespace matrix
174} // namespace gko
175
176
177#endif // GKO_PUBLIC_CORE_MATRIX_SCALED_PERMUTATION_HPP_
Definition lin_op.hpp:878
Definition polymorphic_object.hpp:668
Definition lin_op.hpp:117
Definition lin_op.hpp:660
Definition array.hpp:166
value_type * get_data() noexcept
Definition array.hpp:673
const value_type * get_const_data() const noexcept
Definition array.hpp:682
Definition permutation.hpp:111
Definition scaled_permutation.hpp:37
const value_type * get_const_scaling_factors() const noexcept
Definition scaled_permutation.hpp:58
index_type * get_permutation() noexcept
Definition scaled_permutation.hpp:68
const index_type * get_const_permutation() const noexcept
Definition scaled_permutation.hpp:77
static std::unique_ptr< ScaledPermutation > create(std::shared_ptr< const Executor > exec, array< value_type > scaling_factors, array< index_type > permutation_indices)
static std::unique_ptr< ScaledPermutation > create(ptr_param< const Permutation< IndexType > > permutation)
void write(gko::matrix_data< value_type, index_type > &data) const override
static std::unique_ptr< ScaledPermutation > create(std::shared_ptr< const Executor > exec, size_type size=0)
std::unique_ptr< ScaledPermutation > compose(ptr_param< const ScaledPermutation > other) const
std::unique_ptr< ScaledPermutation > compute_inverse() const
static std::unique_ptr< const ScaledPermutation > create_const(std::shared_ptr< const Executor > exec, gko::detail::const_array_view< value_type > &&scale, gko::detail::const_array_view< index_type > &&perm_idxs)
value_type * get_scaling_factors() noexcept
Definition scaled_permutation.hpp:49
Definition utils_helper.hpp:41
The Ginkgo namespace.
Definition abstract_factory.hpp:20
std::size_t size_type
Definition types.hpp:89
Definition matrix_data.hpp:126