|
Stratax
Scientific computing containers and operations
|
Stores a list of dimension lengths for an array shape. More...
#include <Shape.hpp>
Classes | |
| struct | allow_zero_t |
Public Member Functions | |
| Shape () noexcept=default | |
| Creates an empty shape. | |
| template<Integral... Dims> requires (sizeof...(Dims) > 0) | |
| Shape (Dims... dims) | |
| Creates a shape from non-negative integer dimension lengths. | |
| Shape (std::initializer_list< std::size_t > list, allow_zero_t allow_zero) | |
| Creates a shape from dimension lengths using the explicit zero-dimension tag. | |
| Shape (const Buffer< std::size_t > &dims) | |
| Creates a shape by copying dimension lengths from a buffer. | |
| Shape (const Buffer< std::size_t > &dims, allow_zero_t allow_zero) | |
| Creates a shape by copying dimension lengths using the explicit zero-dimension tag. | |
| Shape (Buffer< std::size_t > &&dims) | |
| Creates a shape by taking ownership of dimension lengths from a buffer. | |
| Shape (Buffer< std::size_t > &&dims, allow_zero_t allow_zero) | |
| Creates a shape by taking ownership of dimensions using the explicit zero-dimension tag. | |
| ~Shape ()=default | |
| Destroys the shape. | |
| std::size_t | elements () const |
| Returns the total number of elements described by the shape. | |
| std::size_t | rank () const |
| Returns the number of stored dimensions. | |
| const std::size_t & | operator() (std::size_t index) const |
| Returns the length of a specific dimension. | |
| bool | empty () const noexcept |
| Returns whether the shape has no dimensions. | |
| bool | operator== (const Shape &other) const noexcept |
| Compares two shapes for exact rank and dimension equality. | |
| bool | operator!= (const Shape &other) const noexcept |
| Returns whether two shapes differ in rank or dimension values. | |
| auto | begin () noexcept |
| Returns an iterator to the first stored dimension. | |
| auto | end () noexcept |
| Returns an iterator one past the last stored dimension. | |
| auto | begin () const noexcept |
| Returns a const iterator to the first stored dimension. | |
| auto | end () const noexcept |
| Returns a const iterator one past the last stored dimension. | |
| void | swap (Shape &other) noexcept |
| Swaps the stored dimensions with another shape. | |
Static Public Attributes | |
| static constexpr allow_zero_t | allow_zero {} |
Stores a list of dimension lengths for an array shape.
Shape tracks rank, dimension sizes, and derived element counts for Stratax containers. It provides lightweight metadata only and does not own any element storage.
|
defaultnoexcept |
Creates an empty shape.
An empty shape has rank 0 and stores no axis lengths.
Referenced by operator!=(), operator==(), Shape(), and swap().
|
inline |
Creates a shape from non-negative integer dimension lengths.
The dimensions are stored in order, from outermost axis to innermost axis. Boolean and character-like types are rejected by the Integral concept.
| dims | Dimension lengths. |
Definition at line 56 of file Shape.hpp.
References Shape().
|
inline |
Creates a shape from dimension lengths using the explicit zero-dimension tag.
This overload documents zero-preserving construction for call sites that want to make that intent visible.
| list | Dimension lengths. |
| allow_zero | Tag documenting that zero-valued dimensions are intentional. |
Definition at line 71 of file Shape.hpp.
References allow_zero.
|
inline |
|
inline |
Creates a shape by copying dimension lengths using the explicit zero-dimension tag.
| dims | Source buffer containing one dimension length per entry. |
| allow_zero | Tag documenting that zero-valued dimensions are intentional. |
Definition at line 93 of file Shape.hpp.
References allow_zero.
|
inline |
|
inline |
Creates a shape by taking ownership of dimensions using the explicit zero-dimension tag.
| dims | Source buffer containing one dimension length per entry. |
| allow_zero | Tag documenting that zero-valued dimensions are intentional. |
Definition at line 116 of file Shape.hpp.
References allow_zero.
|
default |
Destroys the shape.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenodiscard |
Returns the total number of elements described by the shape.
The result is the product of all stored dimensions. An empty shape reports zero elements.
| Exceptions::DimensionError | If the product of dimensions would overflow std::size_t. |
Definition at line 138 of file Shape.hpp.
References stratax::core::validation::checked_multiply(), and empty().
Referenced by stratax::container::operator<<(), and reshape().
|
inlinenodiscardnoexcept |
Returns whether the shape has no dimensions.
Definition at line 182 of file Shape.hpp.
Referenced by elements().
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenodiscardnoexcept |
|
inline |
Returns the length of a specific dimension.
| index | Zero-based dimension index. |
| Exceptions::IndexError | If index is greater than or equal to the shape rank. |
Definition at line 171 of file Shape.hpp.
References rank(), and stratax::core::validation::require_index().
|
inlinenodiscardnoexcept |
|
inlinenodiscard |
Returns the number of stored dimensions.
Definition at line 157 of file Shape.hpp.
Referenced by offset(), operator()(), stratax::core::operator<<(), and operator==().
|
inlinenoexcept |
|
staticconstexpr |