|
Stratax 0.4.0rc1
|
Copying reshape and flatten operations. More...
#include <algorithm>#include <stratax/core/dtypes/Concepts.hpp>#include <stratax/core/Shape.hpp>#include <stratax/exceptions/Exceptions.hpp>#include <stratax/containers/Tensor.hpp>#include <stratax/containers/Vector.hpp>

Go to the source code of this file.
Functions | |
| template<Array A> | |
| stratax::container::Tensor< typename A::value_type > | stratax::manipulation::reshape (const A &arr, const stratax::core::Shape &shape) |
| Copies a Stratax array or view into a tensor with a new shape. | |
| template<Array A> | |
| stratax::container::Vector< typename A::value_type > | stratax::manipulation::flatten (const A &arr) |
| Copies a Stratax array or view into a rank-one vector. | |
Copying reshape and flatten operations.
Definition in file Reshape.hpp.
| stratax::container::Vector< typename A::value_type > stratax::manipulation::flatten | ( | const A & | arr | ) |
Copies a Stratax array or view into a rank-one vector.
Values retain the source array's flat row-major iterator order. The returned vector has shape {arr.size()} and owns storage independent of arr.
| A | Array or view type satisfying Array. |
| arr | Source array to flatten. |
A::value_type and copied values. | std::bad_alloc | If output allocation fails. |
Definition at line 69 of file Reshape.hpp.
| stratax::container::Tensor< typename A::value_type > stratax::manipulation::reshape | ( | const A & | arr, |
| const stratax::core::Shape & | shape | ||
| ) |
Copies a Stratax array or view into a tensor with a new shape.
The target shape must describe exactly the same number of elements as the source. Values are copied in flat iterator order, so only the logical shape and row-major strides change. The returned tensor owns independent storage.
| A | Array or view type satisfying Array. |
| arr | Source array whose flat element order is preserved. |
| shape | Requested shape of the returned tensor. |
A::value_type, shape, and copied values. | Exceptions::DimensionError | If shape.elements() or a target stride cannot be represented. |
| Exceptions::ShapeError | If shape.elements() != arr.size(). |
| std::bad_alloc | If output storage or metadata allocation fails. |
Definition at line 39 of file Reshape.hpp.