Ginkgo  Generated from pipelines/1330831941 branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
gko::accessor::row_major< ValueType, Dimensionality > Class Template Reference

A row_major accessor is a bridge between a range and the row-major memory layout. More...

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

Collaboration diagram for gko::accessor::row_major< ValueType, Dimensionality >:
[legend]

Public Types

using value_type = ValueType
 Type of values returned by the accessor.
 
using data_type = value_type *
 Type of underlying data storage.
 

Public Member Functions

constexpr value_typeoperator() (size_type row, size_type col) const
 Returns the data element at position (row, col) More...
 
constexpr range< row_majoroperator() (const span &rows, const span &cols) const
 Returns the sub-range spanning the range (rows, cols) More...
 
constexpr size_type length (size_type dimension) const
 Returns the length in dimension dimension. More...
 
template<typename OtherAccessor >
void copy_from (const OtherAccessor &other) const
 Copies data from another accessor. More...
 

Public Attributes

const data_type data
 Reference to the underlying data.
 
const std::array< const size_type, dimensionalitylengths
 An array of dimension sizes.
 
const size_type stride
 Distance between consecutive rows.
 

Static Public Attributes

static constexpr size_type dimensionality = 2
 Number of dimensions of the accessor.
 

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 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.


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