 |
Ginkgo
Generated from pipelines/2779843039 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>
108 IndexType* row_ptrs, IndexType* col_idxs)
110 num_stored_elements{num_stored_elements},
120 size, num_stored_elements, values, row_ptrs, col_idxs};
133 template <
typename ValueType,
typename IndexType>
143 size_type stride, ValueType* values, IndexType* col_idxs)
145 num_stored_elements_per_row{num_stored_elements_per_row},
150 assert(stride >= size[0]);
157 size, num_stored_elements_per_row, stride, values, col_idxs};
163 return values[this->linearize_index(row, idx)];
169 return col_idxs[this->linearize_index(row, idx)];
177 assert(idx < num_stored_elements_per_row && row < size[0]);
178 return row + stride * idx;
191 template <
typename ValueType,
typename IndexType>
199 static_assert(std::is_const_v<ValueType> == std::is_const_v<IndexType>,
200 "ValueType and IndexType must share the same constness");
201 using adapt_size_type = std::conditional_t<std::is_const_v<ValueType>,
203 adapt_size_type* slice_lengths;
204 adapt_size_type* slice_sets;
209 IndexType* col_idxs, adapt_size_type* slice_lengths,
210 adapt_size_type* slice_sets)
212 slice_size{slice_size},
213 stride_factor{stride_factor},
214 total_cols{total_cols},
217 slice_lengths{slice_lengths},
218 slice_sets{slice_sets}
225 size, slice_size, stride_factor, total_cols,
226 values, col_idxs, slice_lengths, slice_sets};
233 return values[this->linearize_index(row, slice_set, idx)];
240 return col_idxs[this->linearize_index(row, slice_set, idx)];
248 assert(row < slice_size);
250 assert(idx < total_cols);
251 return (slice_set + idx) * slice_size + row;
264 template <
typename ValueType,
typename IndexType>
266 static_assert(std::is_const_v<ValueType> == std::is_const_v<IndexType>,
267 "ValueType and IndexType must share the same constness");
275 : size(ell_.size), ell_part(ell_), coo_part(coo_)
277 assert(ell_part.size == coo_part.size);
293 #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:154
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:167
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:142
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:101
Non-owning view of a matrix::Ell to be used inside device kernels.
Definition: device_views.hpp:134
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:230
constexpr hybrid< const ValueType, const IndexType > as_const() const
Returns a const view of the same values.
Definition: device_views.hpp:281
constexpr sellp< const ValueType, const IndexType > as_const() const
Returns a const view of the same values.
Definition: device_views.hpp:222
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:161
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:237
constexpr csr(dim< 2 > size, size_type num_stored_elements, ValueType *values, IndexType *row_ptrs, IndexType *col_idxs)
Constructs a coo view from size, nnz, values, row pointers, and column indices.
Definition: device_views.hpp:107
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:207
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
constexpr csr< const ValueType, const IndexType > as_const() const
Returns a const view of the same data.
Definition: device_views.hpp:117
Non-owning view of a matrix::Hybrid to be used inside device kernels.
Definition: device_views.hpp:265
Non-owning view of a matrix::Sellp to be used inside device kernels.
Definition: device_views.hpp:192
Non-owning view of a matrix::Csr to be used inside device kernels.
Definition: device_views.hpp:98
constexpr hybrid(ell< ValueType, IndexType > ell_, coo< ValueType, IndexType > coo_)
Constructs a hybrid view.
Definition: device_views.hpp:273