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 #if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
55 public ConvertibleTo<Ell<next_precision<ValueType, 2>, IndexType>>,
57 #if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
58 public ConvertibleTo<Ell<next_precision<ValueType, 3>, IndexType>>,
60 public ConvertibleTo<Dense<ValueType>>,
61 public ConvertibleTo<Csr<ValueType, IndexType>>,
62 public DiagonalExtractable<ValueType>,
63 public ReadableFromMatrixData<ValueType, IndexType>,
64 public WritableToMatrixData<ValueType, IndexType>,
65 public EnableAbsoluteComputation<
66 remove_complex<Ell<ValueType, IndexType>>> {
67 friend class EnablePolymorphicObject<
Ell,
LinOp>;
68 friend class Dense<ValueType>;
69 friend class Coo<ValueType, IndexType>;
70 friend class Csr<ValueType, IndexType>;
73 friend class Hybrid<ValueType, IndexType>;
74 GKO_ASSERT_SUPPORTED_VALUE_AND_INDEX_TYPE;
79 using ConvertibleTo<Ell<next_precision<ValueType>, IndexType>>::convert_to;
80 using ConvertibleTo<Ell<next_precision<ValueType>, IndexType>>::move_to;
81 using ConvertibleTo<Dense<ValueType>>::convert_to;
82 using ConvertibleTo<Dense<ValueType>>::move_to;
83 using ConvertibleTo<Csr<ValueType, IndexType>>::convert_to;
84 using ConvertibleTo<Csr<ValueType, IndexType>>::move_to;
87 using value_type = ValueType;
88 using index_type = IndexType;
89 using mat_data = matrix_data<ValueType, IndexType>;
90 using device_mat_data = device_matrix_data<ValueType, IndexType>;
91 using absolute_type = remove_complex<Ell>;
94 Ell<next_precision<ValueType>, IndexType>* result)
const override;
96 void move_to(
Ell<next_precision<ValueType>, IndexType>* result)
override;
98 #if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
101 Ell<next_precision<ValueType, 2>, IndexType>>::convert_to;
102 using ConvertibleTo<Ell<next_precision<ValueType, 2>, IndexType>>::move_to;
105 Ell<next_precision<ValueType, 2>, IndexType>* result)
const override;
107 void move_to(
Ell<next_precision<ValueType, 2>, IndexType>* result)
override;
110 #if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
113 Ell<next_precision<ValueType, 3>, IndexType>>::convert_to;
114 using ConvertibleTo<Ell<next_precision<ValueType, 3>, IndexType>>::move_to;
117 Ell<next_precision<ValueType, 3>, IndexType>* result)
const override;
119 void move_to(
Ell<next_precision<ValueType, 3>, IndexType>* result)
override;
122 void convert_to(Dense<ValueType>* other)
const override;
124 void move_to(Dense<ValueType>* other)
override;
126 void convert_to(Csr<ValueType, IndexType>* other)
const override;
128 void move_to(Csr<ValueType, IndexType>* other)
override;
130 void read(
const mat_data& data)
override;
132 void read(
const device_mat_data& data)
override;
134 void read(device_mat_data&& data)
override;
136 void write(mat_data& data)
const override;
189 return num_stored_elements_per_row_;
221 return values_.
get_data()[this->linearize_index(row, idx)];
244 return this->
get_col_idxs()[this->linearize_index(row, idx)];
266 static std::unique_ptr<Ell>
create(
267 std::shared_ptr<const Executor> exec,
const dim<2>& size = {},
289 static std::unique_ptr<Ell>
create(std::shared_ptr<const Executor> exec,
301 template <
typename InputValueType,
typename InputColumnIndexType>
303 "explicitly construct the gko::array argument instead of passing "
306 std::shared_ptr<const
Executor> exec, const
dim<2>& size,
307 std::initializer_list<InputValueType> values,
308 std::initializer_list<InputColumnIndexType> col_idxs,
313 num_stored_elements_per_row, stride);
330 std::shared_ptr<const Executor> exec,
const dim<2>& size,
331 gko::detail::const_array_view<ValueType>&& values,
332 gko::detail::const_array_view<IndexType>&& col_idxs,
362 Ell(std::shared_ptr<const Executor> exec,
const dim<2>& size = {},
365 Ell(std::shared_ptr<const Executor> exec,
const dim<2>& size,
380 void apply_impl(
const LinOp* b,
LinOp* x)
const override;
383 LinOp* x)
const override;
387 return row + stride_ * col;
393 array<value_type> values_;
394 array<index_type> col_idxs_;
402 #endif // GKO_PUBLIC_CORE_MATRIX_ELL_HPP_