5 #ifndef GINKGO_BLOCK_MATRIX_HPP
6 #define GINKGO_BLOCK_MATRIX_HPP
8 #include <ginkgo/config.hpp>
9 #include <ginkgo/core/base/dense_cache.hpp>
10 #include <ginkgo/core/base/lin_op.hpp>
11 #include <ginkgo/core/base/polymorphic_object.hpp>
23 constexpr value_span(
size_type point) noexcept
24 : value_span{point, point + 1}
28 : begin{begin}, end{end}
31 constexpr
operator span()
const {
return {begin, end}; }
33 constexpr value_span(
const span& s) noexcept : value_span(s.begin, s.end) {}
35 constexpr
bool is_valid()
const {
return begin <= end; }
37 constexpr
size_type length()
const {
return end - begin; }
98 GKO_ENSURE_IN_DIMENSION_BOUNDS(i, j, block_size_);
99 return blocks_[i * block_size_[1] + j].get();
109 static std::unique_ptr<BlockOperator>
create(
110 std::shared_ptr<const Executor> exec);
121 static std::unique_ptr<BlockOperator>
create(
122 std::shared_ptr<const Executor> exec,
123 std::vector<std::vector<std::shared_ptr<const LinOp>>> blocks);
153 explicit BlockOperator(std::shared_ptr<const Executor> exec);
156 std::shared_ptr<const Executor> exec,
157 std::vector<std::vector<std::shared_ptr<const LinOp>>> blocks);
159 void apply_impl(
const LinOp* b,
LinOp* x)
const override;
162 LinOp* x)
const override;
165 std::vector<detail::value_span> row_spans_;
166 std::vector<detail::value_span> col_spans_;
167 std::vector<std::shared_ptr<const LinOp>> blocks_;
175 detail::DenseCache<default_precision> one_;
181 #endif // GINKGO_BLOCK_MATRIX_HPP