|
Stratax
Scientific computing containers and operations
|
#include <Tensor.hpp>
Public Types | |
| using | value_type = T |
| template<typename U> | |
| using | rebind = Tensor<U> |
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 & | at (std::size_t index) |
| Returns an element by rank-1 flat index with bounds checking. | |
| const T & | at (std::size_t index) const |
| Returns an element by rank-1 flat index with bounds checking. | |
| template<typename... Rest> | |
| T & | at (std::size_t first, std::size_t second, Rest... rest) |
| Returns an element by multi-index with bounds checking. | |
| template<typename... Rest> | |
| const T & | at (std::size_t first, std::size_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. | |
| auto | begin () noexcept |
| Returns an iterator to the first element. | |
| auto | begin () const noexcept |
| Returns a const iterator to the first element. | |
| auto | cbegin () const noexcept |
| Returns a const iterator to the first element. | |
| auto | end () noexcept |
| Returns an iterator one past the last element. | |
| auto | end () const noexcept |
| Returns a const iterator one past the last element. | |
| auto | cend () const noexcept |
| Returns a const iterator one past the last element. | |
| auto | rbegin () noexcept |
| Returns a reverse iterator to the last element. | |
| auto | rbegin () const noexcept |
| Returns a const reverse iterator to the last element. | |
| auto | crbegin () const noexcept |
| Returns a const reverse iterator to the last element. | |
| auto | rend () noexcept |
| Returns a reverse iterator before the first element. | |
| auto | rend () const noexcept |
| Returns a const reverse iterator before the first element. | |
| auto | 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. | |
Definition at line 29 of file Tensor.hpp.
Definition at line 40 of file Tensor.hpp.
| using stratax::container::Tensor< T >::value_type = T |
Definition at line 37 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 58 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 72 of file Tensor.hpp.
|
default |
Creates a copy of another tensor.
|
defaultnoexcept |
Transfers ownership from another tensor.
|
default |
Destroys the tensor.
|
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 300 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 334 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 268 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 282 of file Tensor.hpp.
|
inline |
Returns the last element.
| Exceptions::IndexError | If the tensor is empty. |
Definition at line 384 of file Tensor.hpp.
|
inline |
Returns the last element as a const reference.
| Exceptions::IndexError | If the tensor is empty. |
Definition at line 395 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator to the first element.
Definition at line 435 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator to the first element.
Definition at line 425 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator to the first element.
Definition at line 445 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator one past the last element.
Definition at line 475 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator to the last element.
Definition at line 505 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator before the first element.
Definition at line 535 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns the raw data pointer as a const pointer.
Definition at line 415 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns the raw data pointer.
Definition at line 405 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns whether the tensor contains no elements.
Definition at line 124 of file Tensor.hpp.
Referenced by slice().
|
inlinenodiscardnoexcept |
Returns a const iterator one past the last element.
Definition at line 465 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator one past the last element.
Definition at line 455 of file Tensor.hpp.
|
inline |
Fills every element with the same value.
| value | Value to assign to each element. |
Definition at line 545 of file Tensor.hpp.
|
inline |
Returns the first element.
| Exceptions::IndexError | If the tensor is empty. |
Definition at line 362 of file Tensor.hpp.
|
inline |
Returns the first element as a const reference.
| Exceptions::IndexError | If the tensor is empty. |
Definition at line 373 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 226 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 249 of file Tensor.hpp.
|
inlinenoexcept |
Returns a flat element without bounds checking.
| index | Flat element index. |
Definition at line 180 of file Tensor.hpp.
|
inlinenoexcept |
Returns a flat element without bounds checking.
| index | Flat element index. |
Definition at line 167 of file Tensor.hpp.
|
default |
Replaces this tensor with a copy of another tensor.
|
defaultnoexcept |
Replaces this tensor by taking ownership from another tensor.
|
inlinenoexcept |
Returns a flat element without bounds checking.
| index | Flat element index. |
Definition at line 206 of file Tensor.hpp.
|
inlinenoexcept |
Returns a flat element without bounds checking.
| index | Flat element index. |
Definition at line 193 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns the tensor rank.
Definition at line 134 of file Tensor.hpp.
Referenced by slice().
|
inlinenodiscardnoexcept |
Returns a const reverse iterator to the last element.
Definition at line 495 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a reverse iterator to the last element.
Definition at line 485 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator before the first element.
Definition at line 525 of file Tensor.hpp.
|
inlinenodiscardnoexcept |
Returns a reverse iterator before the first element.
Definition at line 515 of file Tensor.hpp.
|
inlinenoexcept |
Returns the tensor shape.
Definition at line 144 of file Tensor.hpp.
Referenced by astype(), stratax::container::operator<<(), stratax::container::detail::print_tensor_recursive(), and slice().
|
inlinenodiscardnoexcept |
Returns the total number of elements in the tensor.
Definition at line 114 of file Tensor.hpp.
Referenced by astype(), stratax::container::Tensor< U >::at(), stratax::container::Tensor< U >::at(), reshape(), and slice().
|
inlinenoexcept |
Returns the tensor strides.
Definition at line 154 of file Tensor.hpp.
Referenced by stratax::container::detail::print_tensor_recursive(), and slice().
|
inlinenoexcept |
Swaps the contents of two tensors.
| other | Tensor to exchange state with. |
Definition at line 555 of file Tensor.hpp.