Ginkgo  Generated from remotes/origin/develop branch based on develop. Ginkgo version 1.12.0
A numerical linear algebra library targeting many-core architectures
device_views.hpp
1 // SPDX-FileCopyrightText: 2026 The Ginkgo authors
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef GKO_PUBLIC_CORE_MATRIX_DEVICE_DENSE_HPP_
6 #define GKO_PUBLIC_CORE_MATRIX_DEVICE_DENSE_HPP_
7 
8 #include <ginkgo/core/base/dim.hpp>
9 
10 
11 namespace gko {
12 namespace matrix {
13 namespace view {
14 
15 
23 template <typename ValueType>
24 struct dense {
25  dim<2> size;
26  size_type stride;
27  ValueType* data;
28 
30  constexpr dense(dim<2> size, size_type stride, ValueType* data)
31  : size{size}, stride{stride}, data{data}
32  {}
33 
35  constexpr dense<const ValueType> as_const() const
36  {
37  return dense<const ValueType>{size, stride, data};
38  }
39 
41  constexpr ValueType& operator()(size_type row, size_type col) const
42  {
43  return data[row * stride + col];
44  }
45 };
46 
47 
48 } // namespace view
49 } // namespace matrix
50 } // namespace gko
51 
52 
53 #endif // GKO_PUBLIC_CORE_MATRIX_DEVICE_DENSE_HPP_
gko::matrix::view::dense
Non-owning view of a matrix::Dense to be used inside device kernels.
Definition: device_views.hpp:24
gko::size_type
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:90
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
gko::dim< 2 >
gko::matrix::view::dense::operator()
constexpr ValueType & operator()(size_type row, size_type col) const
Subscript operator accessing the given row and column.
Definition: device_views.hpp:41
gko::matrix::view::dense::as_const
constexpr dense< const ValueType > as_const() const
Returns a const view of the same data.
Definition: device_views.hpp:35
gko::matrix::view::dense::dense
constexpr dense(dim< 2 > size, size_type stride, ValueType *data)
Constructs a dense view from size, stride and data.
Definition: device_views.hpp:30