|
Ginkgo
Generated from pipelines/1556235455 branch based on develop. Ginkgo version 1.9.0
A numerical linear algebra library targeting many-core architectures
|
5 #ifndef GKO_PUBLIC_CORE_BASE_RANGE_ACCESSORS_HPP_
6 #define GKO_PUBLIC_CORE_BASE_RANGE_ACCESSORS_HPP_
11 #include <ginkgo/core/base/range.hpp>
12 #include <ginkgo/core/base/types.hpp>
39 template <
typename ValueType,
size_type Dimensionality>
44 static_assert(Dimensionality == 2,
45 "This accessor is only implemented for matrices");
105 const span& cols)
const
107 return GKO_ASSERT(rows.is_valid()), GKO_ASSERT(cols.
is_valid()),
111 rows.end - rows.begin, cols.
end - cols.
begin,
124 return dimension < 2 ?
lengths[dimension] : 1;
139 template <
typename OtherAccessor>
140 GKO_ATTRIBUTES
void copy_from(
const OtherAccessor& other)
const
144 (*this)(i, j) = other(i, j);
157 const std::array<const size_type, dimensionality>
lengths;
170 #endif // GKO_PUBLIC_CORE_BASE_RANGE_ACCESSORS_HPP_
constexpr value_type & operator()(size_type row, size_type col) const
Returns the data element at position (row, col)
Definition: range_accessors.hpp:89
const size_type end
End of the span.
Definition: range.hpp:90
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:86
constexpr range< row_major > operator()(const span &rows, const span &cols) const
Returns the sub-range spanning the range (rows, cols)
Definition: range_accessors.hpp:104
A row_major accessor is a bridge between a range and the row-major memory layout.
Definition: range_accessors.hpp:40
constexpr bool is_valid() const
Checks if a span is valid.
Definition: range.hpp:73
const size_type begin
Beginning of the span.
Definition: range.hpp:85
const data_type data
Reference to the underlying data.
Definition: range_accessors.hpp:152
const std::array< const size_type, dimensionality > lengths
An array of dimension sizes.
Definition: range_accessors.hpp:157
A range is a multidimensional view of the memory.
Definition: range.hpp:297
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
A span is a lightweight structure used to create sub-ranges from other ranges.
Definition: range.hpp:46
const size_type stride
Distance between consecutive rows.
Definition: range_accessors.hpp:162
ValueType value_type
Type of values returned by the accessor.
Definition: range_accessors.hpp:50
void copy_from(const OtherAccessor &other) const
Copies data from another accessor.
Definition: range_accessors.hpp:140
static constexpr size_type dimensionality
Number of dimensions of the accessor.
Definition: range_accessors.hpp:60
constexpr size_type length(size_type dimension) const
Returns the length in dimension dimension.
Definition: range_accessors.hpp:122
value_type * data_type
Type of underlying data storage.
Definition: range_accessors.hpp:55