|
NumericAL
A header-only C++20 lexer built on REAL
|
A dense, row-major, N-dimensional tensor of T with value semantics.
More...
#include <tensor.hpp>
Public Member Functions | |
| tensor (std::vector< std::size_t > shape, buffer< T > elements) | |
| From a shape and a flat row-major buffer. | |
| tensor (std::vector< std::size_t > shape, const std::vector< T > &elements) | |
| From a shape and a flat row-major std::vector, copied into the storage (a buffer moves in instead). | |
| tensor (std::vector< std::size_t > shape, std::initializer_list< T > elements) | |
| From a shape and a braced list of the elements, row-major. | |
| tensor (const vector< T > &v) | |
| A rank-1 tensor from a vector. | |
| tensor (matrix< T > &&m) | |
| A rank-2 tensor taking over an expiring matrix's elements, without a copy. | |
| tensor (const matrix< T > &m) | |
| A rank-2 tensor from a matrix. | |
| std::size_t | rank () const noexcept |
| The number of axes (0 for a scalar). | |
| std::size_t | size () const noexcept |
| The total number of elements. | |
| const std::vector< std::size_t > & | shape () const noexcept |
| The size of each axis. | |
| const buffer< T > & | data () const noexcept |
| The elements, row-major. | |
| const T & | operator() (const std::vector< std::size_t > &index) const |
| The element at a multi-index. | |
| bool | operator== (const tensor &other) const |
| Exact equality (same shape and equal elements). | |
Private Member Functions | |
| void | finalize () |
| Computes row-major strides and checks the buffer against the shape. | |
Private Attributes | |
| std::vector< std::size_t > | shape_ |
| The size of each axis. | |
| std::vector< std::size_t > | strides_ |
| Row-major strides. | |
| buffer< T > | data_ |
| The elements, row-major. | |
A dense, row-major, N-dimensional tensor of T with value semantics.
| T | The scalar element type. |
Definition at line 62 of file tensor.hpp.
|
inline |
From a shape and a flat row-major buffer.
| [in] | shape | The size of each axis (empty ⇒ a rank-0 scalar). |
| [in] | elements | The prod(shape) elements, row-major (moved in). |
| dimension_error | If elements.size() is not prod(shape). |
Definition at line 72 of file tensor.hpp.
|
inline |
From a shape and a flat row-major std::vector, copied into the storage (a buffer moves in instead).
| [in] | shape | The size of each axis. |
| [in] | elements | The prod(shape) elements, row-major. |
| dimension_error | If elements.size() is not prod(shape). |
Definition at line 85 of file tensor.hpp.
|
inline |
From a shape and a braced list of the elements, row-major.
Definition at line 92 of file tensor.hpp.
A rank-1 tensor from a vector.
| [in] | v | The vector. |
Definition at line 99 of file tensor.hpp.
A rank-2 tensor taking over an expiring matrix's elements, without a copy.
| [in] | m | The matrix. |
Definition at line 110 of file tensor.hpp.
A rank-2 tensor from a matrix.
| [in] | m | The matrix. |
Definition at line 117 of file tensor.hpp.
The elements, row-major.
Definition at line 142 of file tensor.hpp.
|
inlineprivate |
Computes row-major strides and checks the buffer against the shape.
Definition at line 166 of file tensor.hpp.
|
inline |
The element at a multi-index.
Definition at line 148 of file tensor.hpp.
|
inline |
Exact equality (same shape and equal elements).
Definition at line 158 of file tensor.hpp.
|
inlinenoexcept |
The number of axes (0 for a scalar).
Definition at line 124 of file tensor.hpp.
|
inlinenoexcept |
The size of each axis.
Definition at line 136 of file tensor.hpp.
|
inlinenoexcept |
The total number of elements.
Definition at line 130 of file tensor.hpp.
The elements, row-major.
Definition at line 181 of file tensor.hpp.
|
private |
The size of each axis.
Definition at line 179 of file tensor.hpp.
|
private |
Row-major strides.
Definition at line 180 of file tensor.hpp.