5#ifndef GKO_PUBLIC_CORE_BASE_COMPOSITION_HPP_
6#define GKO_PUBLIC_CORE_BASE_COMPOSITION_HPP_
12#include <ginkgo/core/base/executor.hpp>
13#include <ginkgo/core/base/lin_op.hpp>
38template <
typename ValueType = default_precision>
46 using value_type = ValueType;
92 void add_operators() {}
94 template <
typename... Rest>
95 void add_operators(std::shared_ptr<const LinOp> oper, Rest&&... rest)
97 if (!operators_.empty()) {
98 GKO_ASSERT_CONFORMANT(
this, oper);
101 operators_.push_back(std::move(oper));
102 if (operators_.back()->get_executor() != exec) {
103 operators_.back() =
gko::clone(exec, operators_.back());
105 this->set_size(dim<2>{operators_.front()->get_size()[0],
106 operators_.back()->get_size()[1]});
107 add_operators(std::forward<Rest>(rest)...);
128 template <
typename Iterator,
129 typename = std::void_t<
130 typename std::iterator_traits<Iterator>::iterator_category>>
136 return (*begin)->get_executor();
140 for (
auto it = begin; it != end; ++it) {
153 template <
typename... Rest>
154 explicit Composition(std::shared_ptr<const LinOp> oper, Rest&&... rest)
157 add_operators(std::move(oper), std::forward<Rest>(rest)...);
160 void apply_impl(
const LinOp* b,
LinOp* x)
const override;
163 LinOp* x)
const override;
166 std::vector<std::shared_ptr<const LinOp>> operators_;
177template <
typename ValueType = default_precision>
180 using value_type = ValueType;
205 if (composition_ ==
nullptr) {
208 return composition_->get_operators().at(index);
216 template <
typename...
LinOp>
224 std::shared_ptr<Composition<ValueType>> composition_;
Definition composition.hpp:41
Composition(std::shared_ptr< const Executor > exec)
Definition composition.hpp:115
Composition & operator=(const Composition &)
Composition(Composition &&)
std::unique_ptr< LinOp > transpose() const override
Composition(const Composition &)
Composition(Iterator begin, Iterator end)
Definition composition.hpp:131
Composition & operator=(Composition &&)
Composition(std::shared_ptr< const LinOp > oper, Rest &&... rest)
Definition composition.hpp:154
std::unique_ptr< LinOp > conj_transpose() const override
const std::vector< std::shared_ptr< const LinOp > > & get_operators() const noexcept
Definition composition.hpp:54
Definition polymorphic_object.hpp:767
Definition lin_op.hpp:878
Definition polymorphic_object.hpp:668
Definition lin_op.hpp:117
Definition exception.hpp:558
std::shared_ptr< const Executor > get_executor() const noexcept
Definition polymorphic_object.hpp:243
Definition lin_op.hpp:433
Definition composition.hpp:178
std::shared_ptr< const LinOp > get_operator_at(size_type index) const
Definition composition.hpp:203
std::shared_ptr< Composition< ValueType > > get_composition() const
Definition composition.hpp:186
void set_composition(LinOp &&... linop)
Definition composition.hpp:217
The Ginkgo namespace.
Definition abstract_factory.hpp:20
std::size_t size_type
Definition types.hpp:89
detail::cloned_type< Pointer > clone(const Pointer &p)
Definition utils_helper.hpp:173