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>
11 #include <ginkgo/core/matrix/device_views.hpp>
18 template <
typename ValueType>
21 template <
typename ValueType,
typename IndexType>
24 template <
typename ValueType,
typename IndexType>
27 template <
typename ValueType,
typename IndexType>
52 template <
typename ValueType = default_precision,
typename IndexType =
int32>
53 class Ell :
public LinOp,
54 public EnableCloneable<Ell<ValueType, IndexType>>,
55 public ConvertibleTo<Ell<next_precision<ValueType>, IndexType>>,
56 #if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
57 public ConvertibleTo<Ell<next_precision<ValueType, 2>, IndexType>>,
59 #if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
60 public ConvertibleTo<Ell<next_precision<ValueType, 3>, IndexType>>,
62 public ConvertibleTo<Dense<ValueType>>,
63 public ConvertibleTo<Csr<ValueType, IndexType>>,
64 public DiagonalExtractable<ValueType>,
65 public ReadableFromMatrixData<ValueType, IndexType>,
66 public WritableToMatrixData<ValueType, IndexType>,
67 public EnableAbsoluteComputation<
68 remove_complex<Ell<ValueType, IndexType>>> {
69 friend class EnableCloneable<
Ell>;
70 friend class Dense<ValueType>;
71 friend class Coo<ValueType, IndexType>;
72 friend class Csr<ValueType, IndexType>;
75 friend class Hybrid<ValueType, IndexType>;
76 GKO_ASSERT_SUPPORTED_VALUE_AND_INDEX_TYPE;
81 using ConvertibleTo<Ell<next_precision<ValueType>, IndexType>>::convert_to;
82 using ConvertibleTo<Ell<next_precision<ValueType>, IndexType>>::move_to;
83 using ConvertibleTo<Dense<ValueType>>::convert_to;
84 using ConvertibleTo<Dense<ValueType>>::move_to;
85 using ConvertibleTo<Csr<ValueType, IndexType>>::convert_to;
86 using ConvertibleTo<Csr<ValueType, IndexType>>::move_to;
89 using value_type = ValueType;
90 using index_type = IndexType;
91 using mat_data = matrix_data<ValueType, IndexType>;
92 using device_mat_data = device_matrix_data<ValueType, IndexType>;
93 using absolute_type = remove_complex<Ell>;
94 using device_view = matrix::view::ell<value_type, index_type>;
95 using const_device_view =
96 matrix::view::ell<const value_type, const index_type>;
99 Ell<next_precision<ValueType>, IndexType>* result)
const override;
101 void move_to(
Ell<next_precision<ValueType>, IndexType>* result)
override;
103 #if GINKGO_ENABLE_HALF || GINKGO_ENABLE_BFLOAT16
106 Ell<next_precision<ValueType, 2>, IndexType>>::convert_to;
107 using ConvertibleTo<Ell<next_precision<ValueType, 2>, IndexType>>::move_to;
110 Ell<next_precision<ValueType, 2>, IndexType>* result)
const override;
112 void move_to(
Ell<next_precision<ValueType, 2>, IndexType>* result)
override;
115 #if GINKGO_ENABLE_HALF && GINKGO_ENABLE_BFLOAT16
118 Ell<next_precision<ValueType, 3>, IndexType>>::convert_to;
119 using ConvertibleTo<Ell<next_precision<ValueType, 3>, IndexType>>::move_to;
122 Ell<next_precision<ValueType, 3>, IndexType>* result)
const override;
124 void move_to(
Ell<next_precision<ValueType, 3>, IndexType>* result)
override;
127 void convert_to(Dense<ValueType>* other)
const override;
129 void move_to(Dense<ValueType>* other)
override;
131 void convert_to(Csr<ValueType, IndexType>* other)
const override;
133 void move_to(Csr<ValueType, IndexType>* other)
override;
135 void read(
const mat_data& data)
override;
137 void read(
const device_mat_data& data)
override;
139 void read(device_mat_data&& data)
override;
141 void write(mat_data& data)
const override;
194 return num_stored_elements_per_row_;
226 return values_.
get_data()[this->linearize_index(row, idx)];
249 return this->
get_col_idxs()[this->linearize_index(row, idx)];
277 static std::unique_ptr<Ell>
create(
278 std::shared_ptr<const Executor> exec,
const dim<2>& size = {},
300 static std::unique_ptr<Ell>
create(std::shared_ptr<const Executor> exec,
312 template <
typename InputValueType,
typename InputColumnIndexType>
314 "explicitly construct the gko::array argument instead of passing "
317 std::shared_ptr<const
Executor> exec, const
dim<2>& size,
318 std::initializer_list<InputValueType> values,
319 std::initializer_list<InputColumnIndexType> col_idxs,
324 num_stored_elements_per_row, stride);
341 std::shared_ptr<const Executor> exec,
const dim<2>& size,
342 gko::detail::const_array_view<ValueType>&& values,
343 gko::detail::const_array_view<IndexType>&& col_idxs,
373 Ell(std::shared_ptr<const Executor> exec,
const dim<2>& size = {},
376 Ell(std::shared_ptr<const Executor> exec,
const dim<2>& size,
391 void apply_impl(
const LinOp* b,
LinOp* x)
const override;
394 LinOp* x)
const override;
398 return row + stride_ * col;
404 array<value_type> values_;
405 array<index_type> col_idxs_;
413 #endif // GKO_PUBLIC_CORE_MATRIX_ELL_HPP_