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_;
A BlockOperator represents a linear operator that is partitioned into multiple blocks.
Definition block_operator.hpp:76
BlockOperator & operator=(const BlockOperator &other)
Copy assigns a BlockOperator.
static std::unique_ptr< BlockOperator > create(std::shared_ptr< const Executor > exec, std::vector< std::vector< std::shared_ptr< const LinOp > > > blocks)
Create BlockOperator from the given blocks.
BlockOperator(BlockOperator &&other) noexcept
Move constructs a BlockOperator.
BlockOperator & operator=(BlockOperator &&other)
Move assigns a BlockOperator.
dim< 2 > get_block_size() const
Get the block dimension of this, i.e.
Definition block_operator.hpp:86
const LinOp * block_at(size_type i, size_type j) const
Const access to a specific block.
Definition block_operator.hpp:96
BlockOperator(const BlockOperator &other)
Copy constructs a BlockOperator.
static std::unique_ptr< BlockOperator > create(std::shared_ptr< const Executor > exec)
Create empty BlockOperator.
The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the ...
Definition lin_op.hpp:880
This mixin inherits from (a subclass of) PolymorphicObject and provides a base implementation of a ne...
Definition polymorphic_object.hpp:663
Definition lin_op.hpp:118
The Ginkgo namespace.
Definition abstract_factory.hpp:20
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:86
A type representing the dimensions of a multidimensional object.
Definition dim.hpp:27