Template Numerical Library version\ main:4e58ea6
|
Holds static and dynamic sizes of an N-dimensional array. More...
#include <TNL/Containers/ndarray/SizesHolder.h>
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 |
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.
Index | Integral type used for storing dynamic sizes. |
sizes | Sequence 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. |
|
inlinestaticnodiscardconstexprprotected |
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.
|
inlinenodiscard |
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.
|
inlinenodiscard |
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.