Template Numerical Library version\ main:f17d0c8
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
TNL::Containers::SizesHolder< Index, sizes > Class Template Reference

Holds static and dynamic sizes of an N-dimensional array. More...

#include <TNL/Containers/ndarray/SizesHolder.h>

Inheritance diagram for TNL::Containers::SizesHolder< Index, sizes >:
Inheritance graph
[legend]
Collaboration diagram for TNL::Containers::SizesHolder< Index, sizes >:
Collaboration graph
[legend]

Public Types

using IndexType = Index
 

Public Member Functions

__cuda_callable__ constexpr SizesHolder ()
 Default constructor.
 
template<typename... Indices, std::enable_if_t< sizeof...(Indices)==sizeof...(sizes), bool > = true>
 SizesHolder (Indices... _sizes)
 Constructs the holder from given pack of sizes.
 
template<std::size_t level>
__cuda_callable__ Index getSize () const
 Returns the dynamic size along a specific axis.
 
__cuda_callable__ bool operator!= (const SizesHolder &other) const
 Compares the sizes with another instance of the holder.
 
__cuda_callable__ bool operator== (const SizesHolder &other) const
 Compares the sizes with another instance of the holder.
 
__cuda_callable__ Index & operator[] (Index level)
 Dynamic non-const accessor for the dynamic size along a specific axis.
 
__cuda_callable__ const Index & operator[] (Index level) const
 Dynamic accessor for the dynamic size along a specific axis.
 
template<std::size_t level>
__cuda_callable__ void setSize (Index size)
 Sets the dynamic size along a specific axis.
 

Static Public Member Functions

static constexpr std::size_t getDimension ()
 Returns the dimension of the array, i.e. number of sizes specified in the template parameters.
 
template<std::size_t level>
static constexpr std::size_t getStaticSize ()
 Returns the static size of a specific dimension.
 
static constexpr Index getStaticSize (Index level)
 Returns the static size of a specific dimension identified by a runtime parameter level.
 

Static Protected Member Functions

static constexpr std::size_t countDynamicSizes ()
 Returns the number of dynamic sizes that need to be stored at runtime.
 
static constexpr std::size_t getDynamicSizeIndex (std::size_t level)
 Returns the index of given level in the array of dynamic sizes.
 
template<std::size_t level>
static constexpr bool isStaticSize ()
 Checks if given level corresponds to a static size.
 

Protected Attributes

StaticArray< countDynamicSizes(), Index > dynamicSizes
 

Detailed Description

template<typename Index, std::size_t... sizes>
class TNL::Containers::SizesHolder< Index, sizes >

Holds static and dynamic sizes of an N-dimensional array.

The dimension of the array and static sizes are specified as std::size_t, the type of dynamic sizes is configurable with Index.

Template Parameters
IndexIntegral type used for storing dynamic sizes.
sizesSequence of integers specifying static and dynamic sizes. The number of integers in the sequence specifies the dimension of the array. Positive values specify static sizes, zeros specify dynamic sizes that must be set at run-time via setSize.

Member Function Documentation

◆ getDynamicSizeIndex()

template<typename Index , std::size_t... sizes>
static constexpr std::size_t TNL::Containers::SizesHolder< Index, sizes >::getDynamicSizeIndex ( std::size_t level)
inlinestaticconstexprprotected

Returns the index of given level in the array of dynamic sizes.

WARNING: level must correspond to a dynamic size, otherwise the level should not be used for indexing the array of dynamic sizes. This must be ensured before calling this method - it can't be checked by a static_assert here, because we want to be able to specify the level it at runtime as well.

◆ operator[]() [1/2]

template<typename Index , std::size_t... sizes>
__cuda_callable__ Index & TNL::Containers::SizesHolder< Index, sizes >::operator[] ( Index level)
inline

Dynamic non-const accessor for the dynamic size along a specific axis.

Warning: The static size of given level must be equal to zero.

Note: The access is less efficient compared to the getSize and setSize methods, since the mapping from level to the dynamic storage must be computed at runtime rather than compile-time.

◆ operator[]() [2/2]

template<typename Index , std::size_t... sizes>
__cuda_callable__ const Index & TNL::Containers::SizesHolder< Index, sizes >::operator[] ( Index level) const
inline

Dynamic accessor for the dynamic size along a specific axis.

Warning: The static size of given level must be equal to zero.

Note: The access is less efficient compared to the getSize and setSize methods, since the mapping from level to the dynamic storage must be computed at runtime rather than compile-time.


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