|
Stratax 0.3.1
|
Arbitrary-rank owning array of numeric values. More...
#include <Tensor.hpp>


Public Types | |
| using | value_type = typename core::ArrayBase< T >::value_type |
| Stored element type inherited from ArrayBase. | |
| using | size_type = typename core::ArrayBase< T >::size_type |
| Unsigned type used for element counts and normalized indices. | |
| using | difference_type = typename core::ArrayBase< T >::difference_type |
| Signed type used for checked indices and iterator distances. | |
| using | reference = typename core::ArrayBase< T >::reference |
| Mutable element reference type. | |
| using | const_reference = typename core::ArrayBase< T >::const_reference |
| Read-only element reference type. | |
| using | pointer = typename core::ArrayBase< T >::pointer |
| Mutable element pointer type. | |
| using | const_pointer = typename core::ArrayBase< T >::const_pointer |
| Read-only element pointer type. | |
| using | iterator = typename core::ArrayBase< T >::iterator |
| Mutable contiguous random-access iterator type. | |
| using | const_iterator = typename core::ArrayBase< T >::const_iterator |
| Read-only contiguous random-access iterator type. | |
| using | reverse_iterator = typename core::ArrayBase< T >::reverse_iterator |
| Mutable reverse iterator type. | |
| using | const_reverse_iterator = typename core::ArrayBase< T >::const_reverse_iterator |
| Read-only reverse iterator type. | |
Public Types inherited from stratax::core::ArrayBase< T > | |
| using | value_type = typename Buffer< T >::value_type |
| Stored element type. | |
| using | size_type = typename Buffer< value_type >::size_type |
| Unsigned type used for element counts and indices. | |
| using | difference_type = typename Buffer< value_type >::difference_type |
| Signed type used for checked indices and iterator distances. | |
| using | reference = typename Buffer< value_type >::reference |
| Mutable element reference type. | |
| using | const_reference = typename Buffer< value_type >::const_reference |
| Read-only element reference type. | |
| using | pointer = typename Buffer< value_type >::pointer |
| Mutable element pointer type. | |
| using | const_pointer = typename Buffer< value_type >::const_pointer |
| Read-only element pointer type. | |
| using | iterator = typename Buffer< value_type >::iterator |
| Mutable contiguous random-access iterator type. | |
| using | const_iterator = typename Buffer< value_type >::const_iterator |
| Read-only contiguous random-access iterator type. | |
| using | reverse_iterator = typename Buffer< value_type >::reverse_iterator |
| Mutable reverse iterator type. | |
| using | const_reverse_iterator = typename Buffer< value_type >::const_reverse_iterator |
| Read-only reverse iterator type. | |
Public Member Functions | |
| Tensor () | |
Constructs an empty rank-one tensor with shape {0}. | |
| Tensor (const core::Shape &shape) | |
| Constructs value-initialized storage for an arbitrary shape. | |
| Tensor (const core::Shape &shape, const_reference value) | |
Constructs a tensor filled with copies of value. | |
| template<typename... Rest> requires ((std::is_integral_v<Rest>) && ...) | |
| reference | operator() (size_type first, Rest... rest) |
| Returns an element using unchecked variadic indices. | |
| template<typename... Rest> requires ((std::is_integral_v<Rest>) && ...) | |
| const_reference | operator() (size_type first, Rest... rest) const |
| Returns an element using unchecked variadic indices. | |
| reference | operator() (const std::vector< size_type > &indices) |
| Returns an element using unchecked vector-based indices. | |
| const_reference | operator() (const std::vector< size_type > &indices) const |
| Returns an element using unchecked vector-based indices. | |
| template<typename... Rest> requires ((std::is_integral_v<Rest>) && ...) | |
| reference | at (difference_type first, Rest... rest) |
| Returns an element using checked variadic indices. | |
| template<typename... Rest> requires ((std::is_integral_v<Rest>) && ...) | |
| const_reference | at (difference_type first, Rest... rest) const |
| Returns an element using checked variadic indices. | |
| reference | at (const std::vector< difference_type > &raw_indices) |
| Returns an element using checked vector-based indices. | |
| const_reference | at (const std::vector< difference_type > &raw_indices) const |
| Returns an element using checked vector-based indices. | |
| void | swap (Tensor &other) noexcept |
Exchanges storage and layout metadata with other. | |
Public Member Functions inherited from stratax::core::ArrayBase< T > | |
| size_type | size () const noexcept |
| Returns the number of stored elements. | |
| bool | empty () const noexcept |
| Reports whether no elements are stored. | |
| size_type | rank () const noexcept |
| Returns the number of logical dimensions. | |
| const Shape & | shape () const noexcept |
| Returns the logical shape metadata. | |
| const Shape & | strides () const noexcept |
| Returns the row-major stride metadata. | |
| pointer | data () noexcept |
| Returns a pointer to contiguous mutable element storage. | |
| const_pointer | data () const noexcept |
| Returns a pointer to contiguous read-only element storage. | |
| reference | front () |
| Returns the first element. | |
| const_reference | front () const |
| Returns the first element. | |
| reference | back () |
| Returns the final element. | |
| const_reference | back () const |
| Returns the final element. | |
| reference | operator[] (size_type index) noexcept |
| Returns an element without bounds checking. | |
| const_reference | operator[] (size_type index) const noexcept |
| Returns an element without bounds checking. | |
| reference | at (difference_type index) |
| Returns an element using checked, Python-style flat indexing. | |
| const_reference | at (difference_type index) const |
| Returns an element using checked, Python-style flat indexing. | |
| iterator | begin () noexcept |
| Returns a mutable 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 a mutable iterator past the final element. | |
| const_iterator | end () const noexcept |
| Returns a const iterator past the final element. | |
| const_iterator | cend () const noexcept |
| Returns a const iterator past the final element. | |
| reverse_iterator | rbegin () noexcept |
| Returns a mutable reverse iterator to the final element. | |
| const_reverse_iterator | rbegin () const noexcept |
| Returns a const reverse iterator to the final element. | |
| const_reverse_iterator | crbegin () const noexcept |
| Returns a const reverse iterator to the final element. | |
| reverse_iterator | rend () noexcept |
| Returns the past-the-end mutable reverse iterator. | |
| const_reverse_iterator | rend () const noexcept |
| Returns the past-the-end const reverse iterator. | |
| const_reverse_iterator | crend () const noexcept |
| Returns the past-the-end const reverse iterator. | |
| void | fill (const_reference value) |
Assigns value to every stored element. | |
| void | swap (ArrayBase &other) noexcept |
Exchanges storage and layout metadata with other. | |
Friends | |
| void | swap (Tensor &lhs, Tensor &rhs) noexcept |
| Exchanges two tensors using argument-dependent lookup. | |
Additional Inherited Members | |
Static Public Member Functions inherited from stratax::core::ArrayBase< T > | |
| static constexpr std::string_view | dtype () noexcept |
| Returns the canonical name of the stored element dtype. | |
Protected Member Functions inherited from stratax::core::ArrayBase< T > | |
| ArrayBase (const Shape &shape) | |
Constructs value-initialized storage for shape. | |
| ArrayBase (const Shape &shape, const_reference value) | |
Constructs storage filled with value for shape. | |
| ArrayBase (const Shape &shape, Buffer< value_type > &&buffer) | |
Adopts an existing buffer for shape. | |
| template<typename IndexContainer > | |
| size_type | normalized_flat_offset (const IndexContainer &raw_indices) const |
| Converts checked signed multidimensional indices to a flat offset. | |
Arbitrary-rank owning array of numeric values.
Forward declaration of the arbitrary-rank dtype array container.
Tensor combines contiguous element storage with a logical Shape and its canonical row-major stride metadata. It supports unchecked multidimensional access with already-normalized unsigned indices and checked multidimensional access with signed, Python-style indices. The flat container interface is inherited from core::ArrayBase.
| T | Element type satisfying the DType concept. |
Definition at line 49 of file Tensor.hpp.
| using stratax::container::Tensor< T >::const_iterator = typename core::ArrayBase<T>::const_iterator |
Read-only contiguous random-access iterator type.
Definition at line 69 of file Tensor.hpp.
| using stratax::container::Tensor< T >::const_pointer = typename core::ArrayBase<T>::const_pointer |
Read-only element pointer type.
Definition at line 65 of file Tensor.hpp.
| using stratax::container::Tensor< T >::const_reference = typename core::ArrayBase<T>::const_reference |
Read-only element reference type.
Definition at line 61 of file Tensor.hpp.
| using stratax::container::Tensor< T >::const_reverse_iterator = typename core::ArrayBase<T>::const_reverse_iterator |
Read-only reverse iterator type.
Definition at line 73 of file Tensor.hpp.
| using stratax::container::Tensor< T >::difference_type = typename core::ArrayBase<T>::difference_type |
Signed type used for checked indices and iterator distances.
Definition at line 57 of file Tensor.hpp.
| using stratax::container::Tensor< T >::iterator = typename core::ArrayBase<T>::iterator |
Mutable contiguous random-access iterator type.
Definition at line 67 of file Tensor.hpp.
| using stratax::container::Tensor< T >::pointer = typename core::ArrayBase<T>::pointer |
Mutable element pointer type.
Definition at line 63 of file Tensor.hpp.
| using stratax::container::Tensor< T >::reference = typename core::ArrayBase<T>::reference |
Mutable element reference type.
Definition at line 59 of file Tensor.hpp.
| using stratax::container::Tensor< T >::reverse_iterator = typename core::ArrayBase<T>::reverse_iterator |
Mutable reverse iterator type.
Definition at line 71 of file Tensor.hpp.
| using stratax::container::Tensor< T >::size_type = typename core::ArrayBase<T>::size_type |
Unsigned type used for element counts and normalized indices.
Definition at line 55 of file Tensor.hpp.
| using stratax::container::Tensor< T >::value_type = typename core::ArrayBase<T>::value_type |
Stored element type inherited from ArrayBase.
Definition at line 53 of file Tensor.hpp.
|
inline |
Constructs an empty rank-one tensor with shape {0}.
Definition at line 87 of file Tensor.hpp.
|
inlineexplicit |
Constructs value-initialized storage for an arbitrary shape.
| shape | Logical dimensions in outermost-to-innermost order. |
| Exceptions::DimensionError | If the element or stride count overflows. |
| std::bad_alloc | If storage allocation fails. |
| Any | exception thrown while value-initializing a value_type. |
Definition at line 97 of file Tensor.hpp.
|
inline |
Constructs a tensor filled with copies of value.
| shape | Logical dimensions in outermost-to-innermost order. |
| value | Value copied into every element. |
| Exceptions::DimensionError | If the element or stride count overflows. |
| std::bad_alloc | If storage allocation fails. |
| Any | exception thrown by value_type's copy constructor. |
Definition at line 110 of file Tensor.hpp.
|
inline |
Returns an element using checked vector-based indices.
| raw_indices | One signed index per tensor dimension. |
| Exceptions::IndexError | If the number of indices differs from rank() or any component is out of bounds. |
Definition at line 233 of file Tensor.hpp.
|
inline |
Returns an element using checked vector-based indices.
| raw_indices | One signed index per tensor dimension. |
| Exceptions::IndexError | If the number of indices differs from rank() or any component is out of bounds. |
Definition at line 245 of file Tensor.hpp.
|
inline |
Returns an element using checked variadic indices.
Each signed component is normalized independently. Negative values count backward from the end of their corresponding dimensions.
| Rest | Integral types of the remaining index components. |
| first | First signed index component. |
| rest | Remaining signed index components. |
| Exceptions::IndexError | If the number of components differs from rank() or any component is out of bounds. |
Definition at line 191 of file Tensor.hpp.
|
inline |
Returns an element using checked variadic indices.
Each signed component is normalized independently. Negative values count backward from the end of their corresponding dimensions.
| Rest | Integral types of the remaining index components. |
| first | First signed index component. |
| rest | Remaining signed index components. |
| Exceptions::IndexError | If the number of components differs from rank() or any component is out of bounds. |
Definition at line 216 of file Tensor.hpp.
|
inline |
Returns an element using unchecked vector-based indices.
| indices | One normalized index per tensor dimension. |
indices.size() == rank() and every component is within its corresponding dimension. Definition at line 165 of file Tensor.hpp.
|
inline |
Returns an element using unchecked vector-based indices.
| indices | One normalized index per tensor dimension. |
indices.size() == rank() and every component is within its corresponding dimension. Definition at line 174 of file Tensor.hpp.
|
inline |
Returns an element using unchecked variadic indices.
| Rest | Integral types of the remaining index components. |
| first | First normalized index component. |
| rest | Remaining normalized index components. |
rank() components are supplied and every component is non-negative and within its corresponding dimension. Definition at line 126 of file Tensor.hpp.
|
inline |
Returns an element using unchecked variadic indices.
| Rest | Integral types of the remaining index components. |
| first | First normalized index component. |
| rest | Remaining normalized index components. |
rank() components are supplied and every component is non-negative and within its corresponding dimension. Definition at line 148 of file Tensor.hpp.
|
inlinenoexcept |
Exchanges storage and layout metadata with other.
| other | Tensor to exchange with this tensor. |
Definition at line 255 of file Tensor.hpp.
Exchanges two tensors using argument-dependent lookup.
| lhs | First tensor. |
| rhs | Second tensor. |
Definition at line 263 of file Tensor.hpp.