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
56 Ell<next_precision<next_precision<ValueType>>, IndexType>>,
58 public ConvertibleTo<Dense<ValueType>>,
59 public ConvertibleTo<Csr<ValueType, IndexType>>,
60 public DiagonalExtractable<ValueType>,
61 public ReadableFromMatrixData<ValueType, IndexType>,
62 public WritableToMatrixData<ValueType, IndexType>,
63 public EnableAbsoluteComputation<
64 remove_complex<Ell<ValueType, IndexType>>> {
65 friend class EnablePolymorphicObject<
Ell,
LinOp>;
66 friend class Dense<ValueType>;
67 friend class Coo<ValueType, IndexType>;
68 friend class Csr<ValueType, IndexType>;
70 friend class Ell<previous_precision<ValueType>, IndexType>;
71 friend class Hybrid<ValueType, IndexType>;
76 using ConvertibleTo<Ell<next_precision<ValueType>, IndexType>>::convert_to;
77 using ConvertibleTo<Ell<next_precision<ValueType>, IndexType>>::move_to;
78 using ConvertibleTo<Dense<ValueType>>::convert_to;
79 using ConvertibleTo<Dense<ValueType>>::move_to;
80 using ConvertibleTo<Csr<ValueType, IndexType>>::convert_to;
81 using ConvertibleTo<Csr<ValueType, IndexType>>::move_to;
84 using value_type = ValueType;
85 using index_type = IndexType;
86 using mat_data = matrix_data<ValueType, IndexType>;
87 using device_mat_data = device_matrix_data<ValueType, IndexType>;
88 using absolute_type = remove_complex<Ell>;
91 Ell<next_precision<ValueType>, IndexType>* result)
const override;
93 void move_to(
Ell<next_precision<ValueType>, IndexType>* result)
override;
95 #if GINKGO_ENABLE_HALF
96 friend class Ell<previous_precision<previous_precision<ValueType>>,
99 Ell<next_precision<next_precision<ValueType>>, IndexType>>::convert_to;
101 Ell<next_precision<next_precision<ValueType>>, IndexType>>::move_to;
104 result)
const override;
110 void convert_to(Dense<ValueType>* other)
const override;
112 void move_to(Dense<ValueType>* other)
override;
114 void convert_to(Csr<ValueType, IndexType>* other)
const override;
116 void move_to(Csr<ValueType, IndexType>* other)
override;
118 void read(
const mat_data& data)
override;
120 void read(
const device_mat_data& data)
override;
122 void read(device_mat_data&& data)
override;
124 void write(mat_data& data)
const override;
177 return num_stored_elements_per_row_;
209 return values_.
get_data()[this->linearize_index(row, idx)];
232 return this->
get_col_idxs()[this->linearize_index(row, idx)];
254 static std::unique_ptr<Ell>
create(
255 std::shared_ptr<const Executor> exec,
const dim<2>& size = {},
277 static std::unique_ptr<Ell>
create(std::shared_ptr<const Executor> exec,
289 template <
typename InputValueType,
typename InputColumnIndexType>
291 "explicitly construct the gko::array argument instead of passing "
294 std::shared_ptr<const
Executor> exec, const
dim<2>& size,
295 std::initializer_list<InputValueType> values,
296 std::initializer_list<InputColumnIndexType> col_idxs,
301 num_stored_elements_per_row, stride);
318 std::shared_ptr<const Executor> exec,
const dim<2>& size,
319 gko::detail::const_array_view<ValueType>&& values,
320 gko::detail::const_array_view<IndexType>&& col_idxs,
350 Ell(std::shared_ptr<const Executor> exec,
const dim<2>& size = {},
353 Ell(std::shared_ptr<const Executor> exec,
const dim<2>& size,
368 void apply_impl(
const LinOp* b,
LinOp* x)
const override;
371 LinOp* x)
const override;
375 return row + stride_ * col;
381 array<value_type> values_;
382 array<index_type> col_idxs_;
390 #endif // GKO_PUBLIC_CORE_MATRIX_ELL_HPP_