|
Ginkgo
Generated from pipelines/1589998975 branch based on develop. Ginkgo version 1.10.0
A numerical linear algebra library targeting many-core architectures
|
5 #ifndef GKO_PUBLIC_CORE_PRECONDITIONER_ISAI_HPP_
6 #define GKO_PUBLIC_CORE_PRECONDITIONER_ISAI_HPP_
11 #include <ginkgo/core/base/composition.hpp>
12 #include <ginkgo/core/base/exception_helpers.hpp>
13 #include <ginkgo/core/base/executor.hpp>
14 #include <ginkgo/core/base/lin_op.hpp>
15 #include <ginkgo/core/config/config.hpp>
16 #include <ginkgo/core/config/registry.hpp>
17 #include <ginkgo/core/matrix/csr.hpp>
18 #include <ginkgo/core/matrix/dense.hpp>
27 namespace preconditioner {
36 enum struct isai_type { lower, upper, general, spd };
78 template <isai_type IsaiType,
typename ValueType,
typename IndexType>
84 friend class
Isai<isai_type::lower, ValueType, IndexType>;
85 friend class
Isai<isai_type::upper, ValueType, IndexType>;
86 friend class
Isai<isai_type::spd, ValueType, IndexType>;
89 using value_type = ValueType;
90 using index_type = IndexType;
92 Isai<IsaiType == isai_type::general ? isai_type::general
93 : IsaiType == isai_type::spd ? isai_type::spd
94 : IsaiType == isai_type::lower ? isai_type::upper
96 ValueType, IndexType>;
100 static constexpr
isai_type type{IsaiType};
109 std::shared_ptr<
const typename std::conditional<IsaiType == isai_type::spd,
113 return as<
typename std::conditional<IsaiType == isai_type::spd,
Comp,
114 Csr>::type>(approximate_inverse_);
186 std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
187 excess_solver_factory);
190 excess_solver_reduction,
210 static parameters_type
parse(
213 config::make_type_descriptor<ValueType, IndexType>());
215 std::unique_ptr<LinOp>
transpose()
const override;
220 explicit Isai(std::shared_ptr<const Executor> exec)
231 std::shared_ptr<const LinOp> system_matrix)
233 parameters_{factory->get_parameters()}
238 generate_inverse(system_matrix, skip_sorting, power, excess_limit,
240 parameters_.excess_solver_reduction));
241 if (IsaiType == isai_type::spd) {
242 auto inv =
share(as<Csr>(approximate_inverse_));
243 auto inv_transp =
share(inv->conj_transpose());
244 approximate_inverse_ =
249 void apply_impl(
const LinOp* b,
LinOp* x)
const override
251 approximate_inverse_->apply(b, x);
255 LinOp* x)
const override
257 approximate_inverse_->apply(alpha, b, beta, x);
271 void generate_inverse(std::shared_ptr<const LinOp> to_invert,
272 bool skip_sorting,
int power, index_type excess_limit,
273 remove_complex<value_type> excess_solver_reduction);
276 std::shared_ptr<LinOp> approximate_inverse_;
280 template <
typename ValueType = default_precision,
typename IndexType =
int32>
281 using LowerIsai = Isai<isai_type::lower, ValueType, IndexType>;
283 template <
typename ValueType = default_precision,
typename IndexType =
int32>
284 using UpperIsai = Isai<isai_type::upper, ValueType, IndexType>;
286 template <
typename ValueType = default_precision,
typename IndexType =
int32>
287 using GeneralIsai = Isai<isai_type::general, ValueType, IndexType>;
289 template <
typename ValueType = default_precision,
typename IndexType =
int32>
290 using SpdIsai = Isai<isai_type::spd, ValueType, IndexType>;
297 #endif // GKO_PUBLIC_CORE_PRECONDITIONER_ISAI_HPP_
Isai(const Isai &other)
Copy-constructs an ISAI preconditioner.
CSR is a matrix format which stores only the nonzero coefficients by compressing each row of the matr...
Definition: matrix.hpp:28
pnode describes a tree of properties.
Definition: property_tree.hpp:28
Definition: lin_op.hpp:117
Dense is a matrix format which explicitly stores all values of the matrix.
Definition: dense_cache.hpp:19
static parameters_type parse(const config::pnode &config, const config::registry &context, const config::type_descriptor &td_for_child=config::make_type_descriptor< ValueType, IndexType >())
Create the parameters from the property_tree.
Linear operators which support transposition should implement the Transposable interface.
Definition: lin_op.hpp:433
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:89
std::unique_ptr< LinOp > conj_transpose() const override
Returns a LinOp representing the conjugate transpose of the Transposable object.
size_type excess_limit
Size limit for the excess system.
Definition: isai.hpp:178
isai_type
This enum lists the types of the ISAI preconditioner.
Definition: isai.hpp:36
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Creates a scalar factory parameter in the factory parameters structure.
Definition: abstract_factory.hpp:445
The Incomplete Sparse Approximate Inverse (ISAI) Preconditioner generates an approximate inverse matr...
Definition: isai.hpp:79
This class describes the value and index types to be used when building a Ginkgo type from a configur...
Definition: type_descriptor.hpp:39
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
The Composition class can be used to compose linear operators op1, op2, ..., opn and obtain the opera...
Definition: composition.hpp:39
std::decay_t< T > * as(U *obj)
Performs polymorphic type conversion.
Definition: utils_helper.hpp:307
#define GKO_ENABLE_LIN_OP_FACTORY(_lin_op, _parameters_name, _factory_name)
This macro will generate a default implementation of a LinOpFactory for the LinOp subclass it is defi...
Definition: lin_op.hpp:1017
bool skip_sorting
Optimization parameter that skips the sorting of the input matrix (only skip if it is known that it i...
Definition: isai.hpp:155
detail::shared_type< OwningPointer > share(OwningPointer &&p)
Marks the object pointed to by p as shared.
Definition: utils_helper.hpp:224
std::shared_ptr< const typename std::conditional< IsaiType==isai_type::spd, Comp, Csr >::type > get_approximate_inverse() const
Returns the approximate inverse of the given matrix (either a CSR matrix for IsaiType general,...
Definition: isai.hpp:111
int sparsity_power
Which power of the input matrix should be used for the sparsity pattern.
Definition: isai.hpp:165
std::unique_ptr< LinOp > transpose() const override
Returns a LinOp representing the transpose of the Transposable object.
This class stores additional context for creating Ginkgo objects from configuration files.
Definition: registry.hpp:167
#define GKO_ENABLE_BUILD_METHOD(_factory_name)
Defines a build method for the factory, simplifying its construction by removing the repetitive typin...
Definition: abstract_factory.hpp:394
#define GKO_CREATE_FACTORY_PARAMETERS(_parameters_name, _factory_name)
This Macro will generate a new type containing the parameters for the factory _factory_name.
Definition: abstract_factory.hpp:280
std::shared_ptr< const Executor > get_executor() const noexcept
Returns the Executor of the object.
Definition: polymorphic_object.hpp:243
const dim< 2 > & get_size() const noexcept
Returns the size of the operator.
Definition: lin_op.hpp:210
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:260
The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the ...
Definition: lin_op.hpp:877
Isai & operator=(const Isai &other)
Copy-assigns an ISAI preconditioner.
LinOp(const LinOp &)=default
Copy-constructs a LinOp.
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition: polymorphic_object.hpp:667