|
Stratax 0.2.0
|
Stores an N-dimensional Stratax array in contiguous memory. More...
#include <Tensor.hpp>
Public Types | |
| using | value_type = T |
| Element type stored by the tensor. | |
| using | iterator = typename core::Buffer<T>::iterator |
| Mutable iterator over tensor elements. | |
| using | const_iterator = typename core::Buffer<T>::const_iterator |
| Const iterator over tensor elements. | |
| using | reverse_iterator = typename core::Buffer<T>::reverse_iterator |
| Mutable reverse iterator over tensor elements. | |
| using | const_reverse_iterator = typename core::Buffer<T>::const_reverse_iterator |
| Const reverse iterator over tensor elements. | |
| template<typename U> | |
| using | rebind = Tensor<U> |
| Rebinds the tensor container to another element type. | |
Public Member Functions | |
| Tensor () noexcept=default | |
| Creates an empty tensor with rank 0. | |
| Tensor (const core::Shape &shape) | |
| Creates a tensor with default-initialized storage for a shape. | |
| Tensor (const core::Shape &shape, const T &value) | |
| Creates a tensor from a shape and fills it with a value. | |
| Tensor (const Tensor &)=default | |
| Creates a copy of another tensor. | |
| Tensor (Tensor &&) noexcept=default | |
| Transfers ownership from another tensor. | |
| Tensor & | operator= (const Tensor &)=default |
| Replaces this tensor with a copy of another tensor. | |
| Tensor & | operator= (Tensor &&) noexcept=default |
| Replaces this tensor by taking ownership from another tensor. | |
| ~Tensor ()=default | |
| Destroys the tensor. | |
| std::size_t | size () const noexcept |
| Returns the total number of elements in the tensor. | |
| bool | empty () const noexcept |
| Returns whether the tensor contains no elements. | |
| std::size_t | rank () const noexcept |
| Returns the tensor rank. | |
| const core::Shape & | shape () const noexcept |
| Returns the tensor shape. | |
| const core::Strides & | strides () const noexcept |
| Returns the tensor strides. | |
| T & | operator() (std::size_t index) noexcept |
| Returns a flat element without bounds checking. | |
| const T & | operator() (std::size_t index) const noexcept |
| Returns a flat element without bounds checking. | |
| T & | operator[] (std::size_t index) noexcept |
| Returns a flat element without bounds checking. | |
| const T & | operator[] (std::size_t index) const noexcept |
| Returns a flat element without bounds checking. | |
| template<typename... Rest> | |
| T & | operator() (std::size_t first, std::size_t second, Rest... rest) |
| Returns an element by multidimensional index with bounds checking. | |
| template<typename... Rest> | |
| const T & | operator() (std::size_t first, std::size_t second, Rest... rest) const |
| Returns an element by multidimensional index with bounds checking. | |
| T & | operator() (const std::vector< std::size_t > &indices) |
| Returns an element by multidimensional index from a vector with bounds checking. | |
| const T & | operator() (const std::vector< std::size_t > &indices) const |
| Returns an element by multidimensional index from a vector with bounds checking. | |
| T & | at (std::ptrdiff_t index) |
| Returns an element by rank-1 flat index with bounds checking. | |
| const T & | at (std::ptrdiff_t index) const |
| Returns an element by rank-1 flat index with bounds checking. | |
| template<typename... Rest> requires ((std::is_integral_v<Rest>) && ...) | |
| T & | at (std::ptrdiff_t first, std::ptrdiff_t second, Rest... rest) |
| Returns an element by multi-index with bounds checking. | |
| template<typename... Rest> requires ((std::is_integral_v<Rest>) && ...) | |
| const T & | at (std::ptrdiff_t first, std::ptrdiff_t second, Rest... rest) const |
| Returns an element by multi-index with bounds checking. | |
| T & | front () |
| Returns the first element. | |
| const T & | front () const |
| Returns the first element as a const reference. | |
| T & | back () |
| Returns the last element. | |
| const T & | back () const |
| Returns the last element as a const reference. | |
| T * | data () noexcept |
| Returns the raw data pointer. | |
| const T * | data () const noexcept |
| Returns the raw data pointer as a const pointer. | |
| iterator | begin () noexcept |
| Returns an iterator to the first element. | |
| const_iterator | begin () const noexcept |
| Returns a const iterator to the first element. | |
| const_iterator | cbegin () const noexcept |
| Returns a const iterator to the first element. | |
| iterator | end () noexcept |
| Returns an iterator one past the last element. | |
| const_iterator | end () const noexcept |
| Returns a const iterator one past the last element. | |
| const_iterator | cend () const noexcept |
| Returns a const iterator one past the last element. | |
| reverse_iterator | rbegin () noexcept |
| Returns a reverse iterator to the last element. | |
| const_reverse_iterator | rbegin () const noexcept |
| Returns a const reverse iterator to the last element. | |
| const_reverse_iterator | crbegin () const noexcept |
| Returns a const reverse iterator to the last element. | |
| reverse_iterator | rend () noexcept |
| Returns a reverse iterator before the first element. | |
| const_reverse_iterator | rend () const noexcept |
| Returns a const reverse iterator before the first element. | |
| const_reverse_iterator | crend () const noexcept |
| Returns a const reverse iterator before the first element. | |
| void | fill (const T &value) |
| Fills every element with the same value. | |
| void | swap (Tensor &other) noexcept |
| Swaps the contents of two tensors. | |
Stores an N-dimensional Stratax array in contiguous memory.
Tensor owns element storage and shape metadata for generic multi-dimensional array operations.
| T | Numeric element type. |
Definition at line 30 of file Tensor.hpp.
| using stratax::container::Tensor< T >::const_iterator = typename core::Buffer<T>::const_iterator |
Const iterator over tensor elements.
Definition at line 45 of file Tensor.hpp.
| using stratax::container::Tensor< T >::const_reverse_iterator = typename core::Buffer<T>::const_reverse_iterator |
Const reverse iterator over tensor elements.
Definition at line 51 of file Tensor.hpp.
| using stratax::container::Tensor< T >::iterator = typename core::Buffer<T>::iterator |
Mutable iterator over tensor elements.
Definition at line 42 of file Tensor.hpp.
Rebinds the tensor container to another element type.
Definition at line 55 of file Tensor.hpp.
| using stratax::container::Tensor< T >::reverse_iterator = typename core::Buffer<T>::reverse_iterator |
Mutable reverse iterator over tensor elements.
Definition at line 48 of file Tensor.hpp.
| using stratax::container::Tensor< T >::value_type = T |
Element type stored by the tensor.
Definition at line 39 of file Tensor.hpp.
|
defaultnoexcept |
Creates an empty tensor with rank 0.
The tensor has no dimensions, no strides, and owns no elements.
|
inlineexplicit |
Creates a tensor with default-initialized storage for a shape.
The tensor rank and strides are derived directly from shape.
| shape | Source shape. |
Definition at line 73 of file Tensor.hpp.
|
inline |
Creates a tensor from a shape and fills it with a value.
| shape | Source shape. |
| value | Value copied into every element. |
Definition at line 87 of file Tensor.hpp.
|
inline |
Returns an element by multi-index with bounds checking.
| first | First index component. |
| second | Second index component. |
| rest | Remaining index components. |
| Exceptions::IndexError | If the index rank or bounds are invalid. |
Definition at line 346 of file Tensor.hpp.
|
inline |
Returns an element by multi-index with bounds checking.
| first | First index component. |
| second | Second index component. |
| rest | Remaining index components. |
| Exceptions::IndexError | If the index rank or bounds are invalid. |
Definition at line 395 of file Tensor.hpp.
|
inline |
Returns an element by rank-1 flat index with bounds checking.
| index | Flat element index. |
| Exceptions::IndexError | If the index is out of bounds. |
Definition at line 311 of file Tensor.hpp.
|
inline |
Returns an element by rank-1 flat index with bounds checking.
| index | Flat element index. |
| Exceptions::IndexError | If the index is out of bounds. |
Definition at line 326 of file Tensor.hpp.
|
inline |
Returns the last element.
| Exceptions::IndexError | If the tensor is empty. |
Definition at line 459 of file Tensor.hpp.
|
inline |
Returns the last element as a const reference.
| Exceptions::IndexError | If the tensor is empty. |
Definition at line 470 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator to the first element.
Definition at line 510 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator to the first element.
Definition at line 500 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator to the first element.
Definition at line 520 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator one past the last element.
Definition at line 550 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator to the last element.
Definition at line 580 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator before the first element.
Definition at line 610 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns the raw data pointer as a const pointer.
Definition at line 490 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns the raw data pointer.
Definition at line 480 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns whether the tensor contains no elements.
Definition at line 139 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator one past the last element.
Definition at line 540 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator one past the last element.
Definition at line 530 of file Tensor.hpp.
|
inline |
Fills every element with the same value.
| value | Value to assign to each element. |
Definition at line 620 of file Tensor.hpp.
|
inline |
Returns the first element.
| Exceptions::IndexError | If the tensor is empty. |
Definition at line 437 of file Tensor.hpp.
|
inline |
Returns the first element as a const reference.
| Exceptions::IndexError | If the tensor is empty. |
Definition at line 448 of file Tensor.hpp.
|
inline |
Returns an element by multidimensional index from a vector with bounds checking.
| indices | Vector of index components, one per dimension. |
| Exceptions::DimensionError | If the vector size does not match the tensor rank. |
| Exceptions::IndexError | If any index component is out of bounds or the offset overflows. |
Definition at line 284 of file Tensor.hpp.
|
inline |
Returns an element by multidimensional index from a vector with bounds checking.
| indices | Vector of index components, one per dimension. |
| Exceptions::DimensionError | If the vector size does not match the tensor rank. |
| Exceptions::IndexError | If any index component is out of bounds or the offset overflows. |
Definition at line 298 of file Tensor.hpp.
|
inline |
Returns an element by multidimensional index with bounds checking.
At least two index components are required; use the flat overload for rank-1 or flat storage access.
| first | First index component. |
| second | Second index component. |
| rest | Remaining index components. |
| Exceptions::DimensionError | If the number of indices does not match the tensor rank. |
| Exceptions::IndexError | If any index component is out of bounds or the offset overflows. |
Definition at line 241 of file Tensor.hpp.
|
inline |
Returns an element by multidimensional index with bounds checking.
| first | First index component. |
| second | Second index component. |
| rest | Remaining index components. |
| Exceptions::DimensionError | If the number of indices does not match the tensor rank. |
| Exceptions::IndexError | If any index component is out of bounds or the offset overflows. |
Definition at line 264 of file Tensor.hpp.
|
inlinenoexcept |
Returns a flat element without bounds checking.
| index | Flat element index. |
Definition at line 195 of file Tensor.hpp.
|
inlinenoexcept |
Returns a flat element without bounds checking.
| index | Flat element index. |
Definition at line 182 of file Tensor.hpp.
|
inlinenoexcept |
Returns a flat element without bounds checking.
| index | Flat element index. |
Definition at line 221 of file Tensor.hpp.
|
inlinenoexcept |
Returns a flat element without bounds checking.
| index | Flat element index. |
Definition at line 208 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns the tensor rank.
Definition at line 149 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator to the last element.
Definition at line 570 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a reverse iterator to the last element.
Definition at line 560 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator before the first element.
Definition at line 600 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a reverse iterator before the first element.
Definition at line 590 of file Tensor.hpp.
|
inlinenoexcept |
Returns the tensor shape.
Definition at line 159 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns the total number of elements in the tensor.
Definition at line 129 of file Tensor.hpp.
|
inlinenoexcept |
Returns the tensor strides.
Definition at line 169 of file Tensor.hpp.
|
inlinenoexcept |
Swaps the contents of two tensors.
| other | Tensor to exchange state with. |
Definition at line 630 of file Tensor.hpp.