Template Numerical Library version\ main:4e58ea6
Loading...
Searching...
No Matches
TNL::Containers::NDArrayIndexer< SizesHolder, Permutation, Base, StridesHolder, Overlaps > Class Template Reference

Indexer for N-dimensional arrays. It does not store any data, only the sizes of each dimension. More...

#include <TNL/Containers/NDArrayIndexer.h>

Inheritance diagram for TNL::Containers::NDArrayIndexer< SizesHolder, Permutation, Base, StridesHolder, Overlaps >:
Collaboration diagram for TNL::Containers::NDArrayIndexer< SizesHolder, Permutation, Base, StridesHolder, Overlaps >:

Public Types

using IndexType = typename SizesHolder::IndexType
 Type of indices used for addressing the array elements.
 
using OverlapsType = Overlaps
 Sequence of integers representing the overlaps in each dimension of a distributed N-dimensional array.
 
using PermutationType = Permutation
 Permutation that is applied to indices when accessing the array elements.
 
using SizesHolderType = SizesHolder
 Type of the underlying object which represents the sizes of the N-dimensional array.
 
using StridesHolderType = StridesHolder
 Type of the base class which represents the strides of the N-dimensional array.
 
- Public Types inherited from TNL::Containers::ConstStaticSizesHolder< typename SizesHolder::IndexType, SizesHolder::getDimension(), 0 >
using IndexType
 

Public Member Functions

__cuda_callable__ NDArrayIndexer ()=default
 Constructs an empty indexer with zero sizes and strides.
 
__cuda_callable__ NDArrayIndexer (SizesHolderType sizes, StridesHolderType strides, OverlapsType overlaps)
 Creates the indexer with given sizes and strides.
 
template<std::size_t level>
__cuda_callable__ IndexType getOverlap () const
 Returns the overlap of a distributed N-dimensional array along the specified axis.
 
__cuda_callable__ OverlapsTypegetOverlaps ()
 Returns the N-dimensional overlaps holder instance.
 
__cuda_callable__ const OverlapsTypegetOverlaps () const
 Returns the N-dimensional overlaps holder instance.
 
template<std::size_t level>
__cuda_callable__ IndexType getSize () const
 Returns a specific component of the N-dimensional sizes.
 
__cuda_callable__ const SizesHolderTypegetSizes () const
 Returns the N-dimensional array sizes held by the indexer.
 
template<typename... IndexTypes>
__cuda_callable__ IndexType getStorageIndex (IndexTypes &&... indices) const
 Computes the one-dimensional storage index for a specific element of the N-dimensional array.
 
__cuda_callable__ IndexType getStorageSize () const
 Returns the size (number of elements) needed to store the N-dimensional array.
 
__cuda_callable__ const StridesHolderTypegetStrides () const
 Returns the N-dimensional strides holder instance.
 
template<typename BeginsHolder , typename EndsHolder >
__cuda_callable__ bool isContiguousBlock (const BeginsHolder &begins, const EndsHolder &ends)
 
- Public Member Functions inherited from TNL::Containers::ConstStaticSizesHolder< typename SizesHolder::IndexType, SizesHolder::getDimension(), 0 >
__cuda_callable__ typename SizesHolder::IndexType getSize () const
 
__cuda_callable__ typename SizesHolder::IndexType operator[] (typename SizesHolder::IndexType level) const
 Returns the dynamic size along a specific axis. It is always equal to the static size.
 

Static Public Member Functions

static constexpr std::size_t getDimension ()
 Returns the dimension of the N-dimensional array, i.e. N.
 
- Static Public Member Functions inherited from TNL::Containers::ConstStaticSizesHolder< typename SizesHolder::IndexType, SizesHolder::getDimension(), 0 >
static constexpr std::size_t getDimension ()
 
static constexpr std::size_t getStaticSize ()
 
static constexpr typename SizesHolder::IndexType getStaticSize (typename SizesHolder::IndexType level)
 Returns the static size of a specific dimension identified by a runtime parameter level.
 

Protected Types

using NDBaseType = Base
 

Protected Member Functions

__cuda_callable__ SizesHolderTypegetSizes ()
 Returns a non-constant reference to the underlying sizes.
 

Protected Attributes

SizesHolderType sizes
 Underlying object which represents the sizes of the N-dimensional array.
 

Detailed Description

template<typename SizesHolder, typename Permutation, typename Base, typename StridesHolder = detail::DummyStrideBase< typename SizesHolder::IndexType, SizesHolder::getDimension() >, typename Overlaps = ConstStaticSizesHolder< typename SizesHolder::IndexType, SizesHolder::getDimension(), 0 >>
class TNL::Containers::NDArrayIndexer< SizesHolder, Permutation, Base, StridesHolder, Overlaps >

Indexer for N-dimensional arrays. It does not store any data, only the sizes of each dimension.

Template Parameters
SizesHolderInstance of SizesHolder that will represent the array sizes.
PermutationPermutation that will be applied to indices when accessing the array elements. The identity permutation is used by default.
BaseEither detail::NDArrayBase or detail::SlicedNDArrayBase.
StridesHolderType of the base class which represents the strides of the N-dimensional array.
OverlapsSequence of integers representing the overlaps in each dimension a distributed N-dimensional array.

Member Function Documentation

◆ getOverlap()

template<typename SizesHolder , typename Permutation , typename Base , typename StridesHolder = detail::DummyStrideBase< typename SizesHolder::IndexType, SizesHolder::getDimension() >, typename Overlaps = ConstStaticSizesHolder< typename SizesHolder::IndexType, SizesHolder::getDimension(), 0 >>
template<std::size_t level>
__cuda_callable__ IndexType TNL::Containers::NDArrayIndexer< SizesHolder, Permutation, Base, StridesHolder, Overlaps >::getOverlap ( ) const
inlinenodiscard

Returns the overlap of a distributed N-dimensional array along the specified axis.

Template Parameters
levelInteger specifying the axis of the array.

◆ getSize()

template<typename SizesHolder , typename Permutation , typename Base , typename StridesHolder = detail::DummyStrideBase< typename SizesHolder::IndexType, SizesHolder::getDimension() >, typename Overlaps = ConstStaticSizesHolder< typename SizesHolder::IndexType, SizesHolder::getDimension(), 0 >>
template<std::size_t level>
__cuda_callable__ IndexType TNL::Containers::NDArrayIndexer< SizesHolder, Permutation, Base, StridesHolder, Overlaps >::getSize ( ) const
inlinenodiscard

Returns a specific component of the N-dimensional sizes.

Template Parameters
levelInteger specifying the component of the sizes to be returned.

◆ getSizes()

template<typename SizesHolder , typename Permutation , typename Base , typename StridesHolder = detail::DummyStrideBase< typename SizesHolder::IndexType, SizesHolder::getDimension() >, typename Overlaps = ConstStaticSizesHolder< typename SizesHolder::IndexType, SizesHolder::getDimension(), 0 >>
__cuda_callable__ SizesHolderType & TNL::Containers::NDArrayIndexer< SizesHolder, Permutation, Base, StridesHolder, Overlaps >::getSizes ( )
inlinenodiscardprotected

Returns a non-constant reference to the underlying sizes.

The function is not public – only subclasses like NDArrayStorage may modify the sizes.

◆ getStorageIndex()

template<typename SizesHolder , typename Permutation , typename Base , typename StridesHolder = detail::DummyStrideBase< typename SizesHolder::IndexType, SizesHolder::getDimension() >, typename Overlaps = ConstStaticSizesHolder< typename SizesHolder::IndexType, SizesHolder::getDimension(), 0 >>
template<typename... IndexTypes>
__cuda_callable__ IndexType TNL::Containers::NDArrayIndexer< SizesHolder, Permutation, Base, StridesHolder, Overlaps >::getStorageIndex ( IndexTypes &&... indices) const
inlinenodiscard

Computes the one-dimensional storage index for a specific element of the N-dimensional array.

Parameters
indicesIndices of the element in the N-dimensional array. The number of indices supplied must be equal to N, i.e. getDimension().
Returns
An index that can be used to address the element in a one-dimensional array.

◆ getStorageSize()

template<typename SizesHolder , typename Permutation , typename Base , typename StridesHolder = detail::DummyStrideBase< typename SizesHolder::IndexType, SizesHolder::getDimension() >, typename Overlaps = ConstStaticSizesHolder< typename SizesHolder::IndexType, SizesHolder::getDimension(), 0 >>
__cuda_callable__ IndexType TNL::Containers::NDArrayIndexer< SizesHolder, Permutation, Base, StridesHolder, Overlaps >::getStorageSize ( ) const
inlinenodiscard

Returns the size (number of elements) needed to store the N-dimensional array.

Returns
The product of the aligned sizes.

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