Stratax
Scientific computing containers and operations
Loading...
Searching...
No Matches
Reshape.hpp File Reference

Go to the source code of this file.

Functions

template<Array A>
stratax::container::Tensor< typename A::value_type > reshape (const A &arr, const stratax::core::Shape &shape)
 Reshapes an array-like object into a tensor with the requested shape.
template<Array A>
stratax::container::Vector< typename A::value_type > flatten (const A &arr)
 Flattens an array-like object into a vector.

Function Documentation

◆ flatten()

template<Array A>
stratax::container::Vector< typename A::value_type > flatten ( const A & arr)

Flattens an array-like object into a vector.

The values are copied in storage order.

Parameters
arrSource array.
Returns
Vector containing the flattened values.

Definition at line 55 of file Reshape.hpp.

◆ reshape()

template<Array A>
stratax::container::Tensor< typename A::value_type > reshape ( const A & arr,
const stratax::core::Shape & shape )

Reshapes an array-like object into a tensor with the requested shape.

The element order is preserved while the logical shape changes.

Parameters
arrSource array.
shapeTarget shape.
Returns
Tensor containing the same values in the new shape.
Exceptions
Exceptions::ShapeErrorIf the shape does not match the number of elements.

Definition at line 27 of file Reshape.hpp.

References stratax::core::Shape::elements(), stratax::core::validation::require_equal_size(), and stratax::container::Tensor< T >::size().