 |
Ginkgo
Generated from pipelines/2567305205 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
|
5 #ifndef GKO_PUBLIC_CORE_MATRIX_DEVICE_DENSE_HPP_
6 #define GKO_PUBLIC_CORE_MATRIX_DEVICE_DENSE_HPP_
10 #include <ginkgo/core/base/dim.hpp>
26 template <
typename ValueType>
34 : size{size}, stride{stride}, values{values}
36 assert(stride >= size[1]);
48 assert(row < size[0] && col < size[1]);
49 return values[row * stride + col];
62 template <
typename ValueType,
typename IndexType>
72 IndexType* row_idxs, IndexType* col_idxs)
74 num_stored_elements{num_stored_elements},
84 size, num_stored_elements, values, row_idxs, col_idxs};
97 template <
typename ValueType,
typename IndexType>
107 size_type stride, ValueType* values, IndexType* col_idxs)
109 num_stored_elements_per_row{num_stored_elements_per_row},
114 assert(stride >= size[0]);
121 size, num_stored_elements_per_row, stride, values, col_idxs};
127 return values[this->linearize_index(row, idx)];
133 return col_idxs[this->linearize_index(row, idx)];
141 assert(idx < num_stored_elements_per_row && row < size[0]);
142 return row + stride * idx;
155 template <
typename ValueType,
typename IndexType>
163 static_assert(std::is_const_v<ValueType> == std::is_const_v<IndexType>,
164 "ValueType and IndexType must share the same constness");
165 using adapt_size_type = std::conditional_t<std::is_const_v<ValueType>,
167 adapt_size_type* slice_lengths;
168 adapt_size_type* slice_sets;
173 IndexType* col_idxs, adapt_size_type* slice_lengths,
174 adapt_size_type* slice_sets)
176 slice_size{slice_size},
177 stride_factor{stride_factor},
178 total_cols{total_cols},
181 slice_lengths{slice_lengths},
182 slice_sets{slice_sets}
189 size, slice_size, stride_factor, total_cols,
190 values, col_idxs, slice_lengths, slice_sets};
197 return values[this->linearize_index(row, slice_set, idx)];
204 return col_idxs[this->linearize_index(row, slice_set, idx)];
212 assert(row < slice_size);
214 assert(idx < total_cols);
215 return (slice_set + idx) * slice_size + row;
228 template <
typename ValueType,
typename IndexType>
230 static_assert(std::is_const_v<ValueType> == std::is_const_v<IndexType>,
231 "ValueType and IndexType must share the same constness");
239 : size(ell_.size), ell_part(ell_), coo_part(coo_)
241 assert(ell_part.size == coo_part.size);
257 #endif // GKO_PUBLIC_CORE_MATRIX_DEVICE_DENSE_HPP_
Non-owning view of a matrix::Dense to be used inside device kernels.
Definition: device_views.hpp:27
constexpr ell< const ValueType, const IndexType > as_const() const
Returns a const view of the same values.
Definition: device_views.hpp:118
Non-owning view of a matrix::Coo to be used inside device kernels.
Definition: device_views.hpp:63
constexpr IndexType & col_at(size_type row, size_type idx) const
accessing the column index of the idx-th element within the given row
Definition: device_views.hpp:131
constexpr ell(dim< 2 > size, size_type num_stored_elements_per_row, size_type stride, ValueType *values, IndexType *col_idxs)
Constructs a ell view.
Definition: device_views.hpp:106
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:90
Non-owning view of a matrix::Ell to be used inside device kernels.
Definition: device_views.hpp:98
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
constexpr ValueType & val_at(size_type row, size_type slice_set, size_type idx) const
accessing the value of the idx-th element within the given row
Definition: device_views.hpp:194
constexpr hybrid< const ValueType, const IndexType > as_const() const
Returns a const view of the same values.
Definition: device_views.hpp:245
constexpr sellp< const ValueType, const IndexType > as_const() const
Returns a const view of the same values.
Definition: device_views.hpp:186
constexpr coo< const ValueType, const IndexType > as_const() const
Returns a const view of the same data.
Definition: device_views.hpp:81
constexpr dense(dim< 2 > size, size_type stride, ValueType *values)
Constructs a dense view from size, stride and values.
Definition: device_views.hpp:33
constexpr ValueType & val_at(size_type row, size_type idx) const
accessing the value of the idx-th element within the given row
Definition: device_views.hpp:125
constexpr ValueType & operator()(size_type row, size_type col) const
Subscript operator accessing the given row and column.
Definition: device_views.hpp:46
constexpr dense< const ValueType > as_const() const
Returns a const view of the same values.
Definition: device_views.hpp:40
constexpr IndexType & col_at(size_type row, size_type slice_set, size_type idx) const
accessing the column index of the idx-th element within the given row
Definition: device_views.hpp:201
constexpr sellp(dim< 2 > size, size_type slice_size, size_type stride_factor, size_type total_cols, ValueType *values, IndexType *col_idxs, adapt_size_type *slice_lengths, adapt_size_type *slice_sets)
Constructs a sellp view.
Definition: device_views.hpp:171
constexpr coo(dim< 2 > size, size_type num_stored_elements, ValueType *values, IndexType *row_idxs, IndexType *col_idxs)
Constructs a coo view from size, nnz, values, row and column indices.
Definition: device_views.hpp:71
Non-owning view of a matrix::Hybrid to be used inside device kernels.
Definition: device_views.hpp:229
Non-owning view of a matrix::Sellp to be used inside device kernels.
Definition: device_views.hpp:156
constexpr hybrid(ell< ValueType, IndexType > ell_, coo< ValueType, IndexType > coo_)
Constructs a hybrid view.
Definition: device_views.hpp:237