ginkgo/core/reorder/rcm.hpp Source File

ginkgo/core/reorder/rcm.hpp Source File#

Reference API: ginkgo/core/reorder/rcm.hpp Source File
Reference API
rcm.hpp
1// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifndef GKO_PUBLIC_CORE_REORDER_RCM_HPP_
6#define GKO_PUBLIC_CORE_REORDER_RCM_HPP_
7
8
9#include <memory>
10
11#include <ginkgo/core/base/abstract_factory.hpp>
12#include <ginkgo/core/base/array.hpp>
13#include <ginkgo/core/base/dim.hpp>
14#include <ginkgo/core/base/lin_op.hpp>
15#include <ginkgo/core/base/polymorphic_object.hpp>
16#include <ginkgo/core/base/types.hpp>
17#include <ginkgo/core/base/utils.hpp>
18#include <ginkgo/core/matrix/csr.hpp>
19#include <ginkgo/core/matrix/identity.hpp>
20#include <ginkgo/core/matrix/permutation.hpp>
21#include <ginkgo/core/matrix/sparsity_csr.hpp>
22#include <ginkgo/core/reorder/reordering_base.hpp>
23
24
25namespace gko {
31namespace reorder {
32
33
34enum class starting_strategy { minimum_degree, pseudo_peripheral };
35
36
70template <typename ValueType = default_precision, typename IndexType = int32>
71class Rcm : public EnablePolymorphicObject<Rcm<ValueType, IndexType>,
72 ReorderingBase<IndexType>>,
73 public EnablePolymorphicAssignment<Rcm<ValueType, IndexType>> {
74 friend class EnablePolymorphicObject<Rcm, ReorderingBase<IndexType>>;
75
76public:
79 using value_type = ValueType;
80 using index_type = IndexType;
81
88 std::shared_ptr<const PermutationMatrix> get_permutation() const
89 {
90 return permutation_;
91 }
92
99 std::shared_ptr<const PermutationMatrix> get_inverse_permutation() const
100 {
101 return inv_permutation_;
102 }
103
104 /*const array<index_type>& get_permutation_array() const override
105 {
106 return permutation_array_;
107 }*/
108
110 {
115 bool GKO_FACTORY_PARAMETER_SCALAR(construct_inverse_permutation, false);
116
121 starting_strategy GKO_FACTORY_PARAMETER_SCALAR(
122 strategy, starting_strategy::pseudo_peripheral);
123 };
124 GKO_ENABLE_REORDERING_BASE_FACTORY(Rcm, parameters, Factory);
126
127protected:
128 explicit Rcm(std::shared_ptr<const Executor> exec);
129
130 explicit Rcm(const Factory* factory, const ReorderingBaseArgs& args);
131
132private:
133 std::shared_ptr<PermutationMatrix> permutation_;
134 std::shared_ptr<PermutationMatrix> inv_permutation_;
135};
136
137
138} // namespace reorder
139
140
141namespace experimental {
142namespace reorder {
143
144
145using rcm_starting_strategy = gko::reorder::starting_strategy;
146
147
173template <typename IndexType = int32>
174class Rcm : public EnablePolymorphicObject<Rcm<IndexType>, LinOpFactory>,
175 public EnablePolymorphicAssignment<Rcm<IndexType>> {
176public:
177 struct parameters_type;
178 friend class EnablePolymorphicObject<Rcm<IndexType>, LinOpFactory>;
179 friend class enable_parameters_type<parameters_type, Rcm<IndexType>>;
180
181 using index_type = IndexType;
182 using permutation_type = matrix::Permutation<index_type>;
183
185 : public enable_parameters_type<parameters_type, Rcm<IndexType>> {
191
196 rcm_starting_strategy GKO_FACTORY_PARAMETER_SCALAR(
197 strategy, rcm_starting_strategy::pseudo_peripheral);
198 };
199
205 const parameters_type& get_parameters() { return parameters_; }
206
214 std::unique_ptr<permutation_type> generate(
215 std::shared_ptr<const LinOp> system_matrix) const;
216
218 static parameters_type build() { return {}; }
219
220protected:
221 explicit Rcm(std::shared_ptr<const Executor> exec,
222 const parameters_type& params = {});
223
224 std::unique_ptr<LinOp> generate_impl(
225 std::shared_ptr<const LinOp> system_matrix) const override;
226
227 parameters_type parameters_;
228};
229
230
231} // namespace reorder
232} // namespace experimental
233} // namespace gko
234
235
236#endif // GKO_PUBLIC_CORE_REORDER_RCM_HPP_
Definition polymorphic_object.hpp:743
Definition polymorphic_object.hpp:668
Definition lin_op.hpp:385
Definition abstract_factory.hpp:211
Definition permutation.hpp:111
Definition sparsity_csr.hpp:55
Definition rcm.hpp:124
Definition rcm.hpp:73
std::shared_ptr< const PermutationMatrix > get_inverse_permutation() const
Definition rcm.hpp:99
std::shared_ptr< const PermutationMatrix > get_permutation() const
Definition rcm.hpp:88
Definition reordering_base.hpp:35
#define GKO_CREATE_FACTORY_PARAMETERS(_parameters_name, _factory_name)
Definition abstract_factory.hpp:280
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Definition abstract_factory.hpp:445
#define GKO_ENABLE_BUILD_METHOD(_factory_name)
Definition abstract_factory.hpp:394
The Ginkgo namespace.
Definition abstract_factory.hpp:20
rcm_starting_strategy strategy
Definition rcm.hpp:197
Definition reordering_base.hpp:65