7#include <stratax/containers/Matrix.hpp>
8#include <stratax/containers/Tensor.hpp>
9#include <stratax/containers/Vector.hpp>
10#include <stratax/core/ArrayTraits.hpp>
11#include <stratax/core/dtypes/Concepts.hpp>
12#include <stratax/core/Shape.hpp>
13#include <stratax/exceptions/Exceptions.hpp>
15namespace stratax::conversion {
33 if (shape.
rank() == 1)
38 std::size_t non_singleton = 0;
40 for (std::size_t dim : shape)
48 return non_singleton == 1;
65 if (shape.
rank() == 2)
70 std::size_t non_singleton = 0;
72 for (std::size_t dim : shape)
80 return non_singleton == 2;
99 if (shape.
rank() == 2)
104 std::vector<std::size_t> dims;
107 for (std::size_t dim : shape)
137to_vector(
const A& arr)
139 if (!detail::is_vector_shape(arr.shape()))
142 "Array shape cannot be converted to a Vector.");
174to_matrix(
const A& arr)
176 if (!detail::is_matrix_shape(arr.shape()))
179 "Array shape cannot be converted to a Matrix.");
183 detail::matrix_shape(arr.shape());
211to_tensor(
const A& arr)
242template<DType To, Array A>
244stratax::core::rebind_array_t<A, To>
248 stratax::core::rebind_array_t<A, To>;
250 result_type result(arr.shape());
256 [](
const auto& value)
258 return static_cast<To>(value);
Two-dimensional owning array of numeric values.
Arbitrary-rank owning array of numeric values.
One-dimensional owning array of numeric values.
Stores the dimensions of a multidimensional array.
size_type rank() const noexcept
Returns the number of dimensions.