5#ifndef GKO_PUBLIC_CORE_SOLVER_WORKSPACE_HPP_
6#define GKO_PUBLIC_CORE_SOLVER_WORKSPACE_HPP_
12#include <ginkgo/core/matrix/dense.hpp>
25 template <
typename ValueType>
28 auto container = std::make_unique<concrete_container<ValueType>>(
29 std::move(exec), size);
35 bool empty()
const {
return data_.get() ==
nullptr; }
37 template <
typename ValueType>
43 template <
typename ValueType>
50 template <
typename ValueType>
58 void clear() { data_.reset(); }
61 struct generic_container {
62 virtual ~generic_container() =
default;
65 template <
typename ValueType>
66 struct concrete_container : generic_container {
67 template <
typename...
Args>
74 std::unique_ptr<generic_container> data_;
80 workspace(std::shared_ptr<const Executor> exec) : exec_{std::
move(exec)} {}
82 workspace(
const workspace&
other) : workspace{
other.get_executor()} {}
84 workspace(workspace&&
other) : workspace{
other.get_executor()}
89 workspace& operator=(
const workspace&
other) {
return *
this; }
91 workspace& operator=(workspace&&
other)
97 template <
typename LinOpType,
typename CreateOperation>
102 GKO_ASSERT(
op_id >= 0 &&
op_id < operators_.size());
116 if (
op->get_size() != size ||
op->get_stride() != stride) {
124 const LinOp* get_op(
int op_id)
const
126 GKO_ASSERT(
op_id >= 0 &&
op_id < operators_.size());
127 return operators_[
op_id].get();
130 template <
typename ValueType>
145 template <
typename ValueType>
149 if (
result.get_size() != size) {
150 result.resize_and_reset(size);
155 std::shared_ptr<const Executor> get_executor()
const {
return exec_; }
160 arrays_.resize(num_arrays);
165 for (
auto&
op : operators_) {
168 for (
auto&
array : arrays_) {
174 std::shared_ptr<const Executor> exec_;
175 std::vector<std::unique_ptr<LinOp>> operators_;
176 std::vector<any_array> arrays_;
The Ginkgo namespace.
Definition abstract_factory.hpp:20
constexpr T one()
Returns the multiplicative identity for T.
Definition math.hpp:775
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:92
@ array
The matrix should be written as dense matrix in column-major order.