5 #ifndef GKO_PUBLIC_CORE_MATRIX_ELL_HPP_
6 #define GKO_PUBLIC_CORE_MATRIX_ELL_HPP_
9 #include <ginkgo/core/base/array.hpp>
10 #include <ginkgo/core/base/lin_op.hpp>
17 template <
typename ValueType>
20 template <
typename ValueType,
typename IndexType>
23 template <
typename ValueType,
typename IndexType>
26 template <
typename ValueType,
typename IndexType>
51 template <
typename ValueType = default_precision,
typename IndexType =
int32>
52 class Ell :
public EnableLinOp<Ell<ValueType, IndexType>>,
53 public ConvertibleTo<Ell<next_precision<ValueType>, IndexType>>,
54 public ConvertibleTo<Dense<ValueType>>,
55 public ConvertibleTo<Csr<ValueType, IndexType>>,
56 public DiagonalExtractable<ValueType>,
57 public ReadableFromMatrixData<ValueType, IndexType>,
58 public WritableToMatrixData<ValueType, IndexType>,
59 public EnableAbsoluteComputation<
60 remove_complex<Ell<ValueType, IndexType>>> {
61 friend class EnablePolymorphicObject<
Ell,
LinOp>;
62 friend class Dense<ValueType>;
63 friend class Coo<ValueType, IndexType>;
64 friend class Csr<ValueType, IndexType>;
67 friend class Hybrid<ValueType, IndexType>;
72 using ConvertibleTo<Ell<next_precision<ValueType>, IndexType>>::convert_to;
73 using ConvertibleTo<Ell<next_precision<ValueType>, IndexType>>::move_to;
74 using ConvertibleTo<Dense<ValueType>>::convert_to;
75 using ConvertibleTo<Dense<ValueType>>::move_to;
76 using ConvertibleTo<Csr<ValueType, IndexType>>::convert_to;
77 using ConvertibleTo<Csr<ValueType, IndexType>>::move_to;
80 using value_type = ValueType;
81 using index_type = IndexType;
82 using mat_data = matrix_data<ValueType, IndexType>;
83 using device_mat_data = device_matrix_data<ValueType, IndexType>;
84 using absolute_type = remove_complex<Ell>;
87 Ell<next_precision<ValueType>, IndexType>* result)
const override;
89 void move_to(
Ell<next_precision<ValueType>, IndexType>* result)
override;
91 void convert_to(Dense<ValueType>* other)
const override;
93 void move_to(Dense<ValueType>* other)
override;
95 void convert_to(Csr<ValueType, IndexType>* other)
const override;
97 void move_to(Csr<ValueType, IndexType>* other)
override;
99 void read(
const mat_data& data)
override;
101 void read(
const device_mat_data& data)
override;
103 void read(device_mat_data&& data)
override;
105 void write(mat_data& data)
const override;
158 return num_stored_elements_per_row_;
190 return values_.
get_data()[this->linearize_index(row, idx)];
213 return this->
get_col_idxs()[this->linearize_index(row, idx)];
235 static std::unique_ptr<Ell>
create(
236 std::shared_ptr<const Executor> exec,
const dim<2>& size = {},
258 static std::unique_ptr<Ell>
create(std::shared_ptr<const Executor> exec,
270 template <
typename InputValueType,
typename InputColumnIndexType>
272 "explicitly construct the gko::array argument instead of passing "
275 std::shared_ptr<const
Executor> exec, const
dim<2>& size,
276 std::initializer_list<InputValueType> values,
277 std::initializer_list<InputColumnIndexType> col_idxs,
282 num_stored_elements_per_row, stride);
299 std::shared_ptr<const Executor> exec,
const dim<2>& size,
300 gko::detail::const_array_view<ValueType>&& values,
301 gko::detail::const_array_view<IndexType>&& col_idxs,
331 Ell(std::shared_ptr<const Executor> exec,
const dim<2>& size = {},
334 Ell(std::shared_ptr<const Executor> exec,
const dim<2>& size,
349 void apply_impl(
const LinOp* b,
LinOp* x)
const override;
352 LinOp* x)
const override;
356 return row + stride_ * col;
362 array<value_type> values_;
363 array<index_type> col_idxs_;
371 #endif // GKO_PUBLIC_CORE_MATRIX_ELL_HPP_