row_major< ValueType, Dimensionality > Class Template Reference#
|
Reference API
|
#include <ginkgo/core/base/range_accessors.hpp>
Public Types | |
| using | value_type = ValueType |
| using | data_type = value_type * |
Public Member Functions | |
| constexpr value_type & | operator() (size_type row, size_type col) const |
| constexpr range< row_major > | operator() (const span &rows, const span &cols) const |
| constexpr size_type | length (size_type dimension) const |
| template<typename OtherAccessor > | |
| void | copy_from (const OtherAccessor &other) const |
Public Attributes | |
| const data_type | data |
| const std::array< const size_type, dimensionality > | lengths |
| const size_type | stride |
Static Public Attributes | |
| static constexpr size_type | dimensionality = 2 |
Protected Member Functions | |
| constexpr | row_major (data_type data, size_type num_rows, size_type num_cols, size_type stride) |
Friends | |
| class | range< row_major > |
Detailed Description
class gko::accessor::row_major< ValueType, Dimensionality >
A row_major accessor is a bridge between a range and the row-major memory layout.
You should never try to explicitly create an instance of this accessor. Instead, supply it as a template parameter to a range, and pass the constructor parameters for this class to the range (it will forward it to this class).
- Warning
- The current implementation is incomplete, and only allows for 2-dimensional ranges.
- Template Parameters
-
ValueType type of values this accessor returns Dimensionality number of dimensions of this accessor (has to be 2)
Member Typedef Documentation
◆ data_type
| using gko::accessor::row_major< ValueType, Dimensionality >::data_type = value_type* |
Type of underlying data storage.
◆ value_type
| using gko::accessor::row_major< ValueType, Dimensionality >::value_type = ValueType |
Type of values returned by the accessor.
Constructor & Destructor Documentation
◆ row_major()
|
inlineexplicitconstexprprotected |
Creates a row_major accessor.
- Parameters
-
data pointer to the block of memory containing the data num_row number of rows of the accessor num_cols number of columns of the accessor stride distance (in elements) between starting positions of consecutive rows (i.e. data + i * stridepoints to thei-th row)
Member Function Documentation
◆ copy_from()
|
inline |
Copies data from another accessor
- Warning
- Do not use this function since it is not optimized for a specific executor. It will always be performed sequentially. Please write an optimized version (adjusted to the architecture) by iterating through the values yourself.
- Template Parameters
-
OtherAccessor type of the other accessor
- Parameters
-
other other accessor
References gko::accessor::row_major< ValueType, Dimensionality >::lengths.
◆ length()
|
inlineconstexpr |
Returns the length in dimension dimension.
- Parameters
-
dimension a dimension index
- Returns
- length in dimension
dimension
References gko::accessor::row_major< ValueType, Dimensionality >::lengths.
◆ operator()() [1/2]
|
inlineconstexpr |
Returns the sub-range spanning the range (rows, cols)
- Parameters
-
rows row span cols column span
- Returns
- sub-range spanning the range (rows, cols)
References gko::span::begin, gko::accessor::row_major< ValueType, Dimensionality >::data, gko::span::end, gko::span::is_valid(), gko::accessor::row_major< ValueType, Dimensionality >::lengths, and gko::accessor::row_major< ValueType, Dimensionality >::stride.
◆ operator()() [2/2]
|
inlineconstexpr |
Returns the data element at position (row, col)
- Parameters
-
row row index col column index
- Returns
- data element at (row, col)
References gko::accessor::row_major< ValueType, Dimensionality >::data, gko::accessor::row_major< ValueType, Dimensionality >::lengths, and gko::accessor::row_major< ValueType, Dimensionality >::stride.
Member Data Documentation
◆ data
| const data_type gko::accessor::row_major< ValueType, Dimensionality >::data |
Reference to the underlying data.
Referenced by gko::accessor::row_major< ValueType, Dimensionality >::operator()(), and gko::accessor::row_major< ValueType, Dimensionality >::operator()().
◆ dimensionality
|
staticconstexpr |
Number of dimensions of the accessor.
◆ lengths
| const std::array<const size_type, dimensionality> gko::accessor::row_major< ValueType, Dimensionality >::lengths |
An array of dimension sizes.
Referenced by gko::accessor::row_major< ValueType, Dimensionality >::copy_from(), gko::accessor::row_major< ValueType, Dimensionality >::length(), gko::accessor::row_major< ValueType, Dimensionality >::operator()(), and gko::accessor::row_major< ValueType, Dimensionality >::operator()().
◆ stride
| const size_type gko::accessor::row_major< ValueType, Dimensionality >::stride |
Distance between consecutive rows.
Referenced by gko::accessor::row_major< ValueType, Dimensionality >::operator()(), and gko::accessor::row_major< ValueType, Dimensionality >::operator()().
The documentation for this class was generated from the following file:
- ginkgo/core/base/range_accessors.hpp
Generated by