row_major< ValueType, Dimensionality > Class Template Reference

row_major&lt; ValueType, Dimensionality &gt; Class Template Reference#

Reference API: gko::accessor::row_major< ValueType, Dimensionality > Class Template Reference
Reference API
gko::accessor::row_major< ValueType, Dimensionality > Class Template Reference

#include <ginkgo/core/base/range_accessors.hpp>

Public Types

using value_type = ValueType
 
using data_type = value_type *
 

Public Member Functions

constexpr value_typeoperator() (size_type row, size_type col) const
 
constexpr range< row_majoroperator() (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, dimensionalitylengths
 
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

template<typename ValueType, size_type Dimensionality>
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
ValueTypetype of values this accessor returns
Dimensionalitynumber of dimensions of this accessor (has to be 2)

Member Typedef Documentation

◆ data_type

template<typename ValueType , size_type Dimensionality>
using gko::accessor::row_major< ValueType, Dimensionality >::data_type = value_type*

Type of underlying data storage.

◆ value_type

template<typename ValueType , size_type Dimensionality>
using gko::accessor::row_major< ValueType, Dimensionality >::value_type = ValueType

Type of values returned by the accessor.

Constructor & Destructor Documentation

◆ row_major()

template<typename ValueType , size_type Dimensionality>
constexpr gko::accessor::row_major< ValueType, Dimensionality >::row_major ( data_type  data,
size_type  num_rows,
size_type  num_cols,
size_type  stride 
)
inlineexplicitconstexprprotected

Creates a row_major accessor.

Parameters
datapointer to the block of memory containing the data
num_rownumber of rows of the accessor
num_colsnumber of columns of the accessor
stridedistance (in elements) between starting positions of consecutive rows (i.e. data + i * stride points to the i-th row)

Member Function Documentation

◆ copy_from()

template<typename ValueType , size_type Dimensionality>
template<typename OtherAccessor >
void gko::accessor::row_major< ValueType, Dimensionality >::copy_from ( const OtherAccessor &  other) const
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
OtherAccessortype of the other accessor
Parameters
otherother accessor

References gko::accessor::row_major< ValueType, Dimensionality >::lengths.

◆ length()

template<typename ValueType , size_type Dimensionality>
constexpr size_type gko::accessor::row_major< ValueType, Dimensionality >::length ( size_type  dimension) const
inlineconstexpr

Returns the length in dimension dimension.

Parameters
dimensiona dimension index
Returns
length in dimension dimension

References gko::accessor::row_major< ValueType, Dimensionality >::lengths.

◆ operator()() [1/2]

template<typename ValueType , size_type Dimensionality>
constexpr range< row_major > gko::accessor::row_major< ValueType, Dimensionality >::operator() ( const span rows,
const span cols 
) const
inlineconstexpr

Returns the sub-range spanning the range (rows, cols)

Parameters
rowsrow span
colscolumn 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]

template<typename ValueType , size_type Dimensionality>
constexpr value_type & gko::accessor::row_major< ValueType, Dimensionality >::operator() ( size_type  row,
size_type  col 
) const
inlineconstexpr

Returns the data element at position (row, col)

Parameters
rowrow index
colcolumn 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

template<typename ValueType , size_type Dimensionality>
const data_type gko::accessor::row_major< ValueType, Dimensionality >::data

◆ dimensionality

template<typename ValueType , size_type Dimensionality>
constexpr size_type gko::accessor::row_major< ValueType, Dimensionality >::dimensionality = 2
staticconstexpr

Number of dimensions of the accessor.

◆ lengths

◆ stride

template<typename ValueType , size_type Dimensionality>
const size_type gko::accessor::row_major< ValueType, Dimensionality >::stride

The documentation for this class was generated from the following file: