33 #ifndef GKO_CORE_BASE_COMPOSITION_HPP_ 34 #define GKO_CORE_BASE_COMPOSITION_HPP_ 40 #include <ginkgo/core/base/lin_op.hpp> 54 template <
typename ValueType = default_precision>
61 using value_type = ValueType;
80 explicit Composition(std::shared_ptr<const Executor> exec)
93 template <
typename Iterator,
94 typename = xstd::void_t<
95 typename std::iterator_traits<Iterator>::iterator_category>>
96 explicit Composition(Iterator begin, Iterator end)
101 return (*begin)->get_executor();
103 operators_(begin, end)
105 this->set_size(
gko::dim<2>{operators_.front()->get_size()[0],
106 operators_.back()->get_size()[1]});
107 for (
size_type i = 1; i < operators_.size(); ++i) {
108 GKO_ASSERT_CONFORMANT(operators_[i - 1], operators_[i]);
120 template <
typename... Rest>
121 explicit Composition(std::shared_ptr<const LinOp> oper, Rest &&... rest)
122 : Composition(std::forward<Rest>(rest)...)
124 GKO_ASSERT_CONFORMANT(oper, operators_[0]);
125 operators_.insert(begin(operators_), oper);
126 this->set_size(
gko::dim<2>{operators_.front()->get_size()[0],
127 operators_.back()->get_size()[1]});
138 explicit Composition(std::shared_ptr<const LinOp> oper)
143 void apply_impl(
const LinOp *b, LinOp *x)
const override;
145 void apply_impl(
const LinOp *alpha,
const LinOp *b,
const LinOp *beta,
146 LinOp *x)
const override;
149 std::vector<std::shared_ptr<const LinOp>> operators_;
152 mutable struct cache_struct {
153 cache_struct() =
default;
154 cache_struct(
const cache_struct &other) {}
155 cache_struct &operator=(
const cache_struct &other) {
return *
this; }
159 std::vector<std::unique_ptr<LinOp>> intermediate;
167 #endif // GKO_CORE_BASE_COMPOSITION_HPP_
This mixin implements a static create() method on ConcreteType that dynamically allocates the memory...
Definition: polymorphic_object.hpp:576
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition: polymorphic_object.hpp:505
The Composition class can be used to compose linear operators op1, op2, ..., opn and obtain the opera...
Definition: composition.hpp:55
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:94
The Ginkgo namespace.
Definition: abstract_factory.hpp:45
OutOfBoundsError is thrown if a memory access is detected to be out-of-bounds.
Definition: exception.hpp:297
The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the ...
Definition: lin_op.hpp:509
const std::vector< std::shared_ptr< const LinOp > > & get_operators() const noexcept
Returns a list of operators of the composition.
Definition: composition.hpp:68