|
Stratax 0.3.1
|
Version: v0.2.0
Status: Complete
Header: include/stratax/algorithms/Conversion.hpp
Conversions.hpp provides shape conversion and value-type casting helpers for Stratax array containers.
Helpers preserve flat storage order and return new owning containers.
The conversions module is responsible for:
The conversions module is not responsible for:
static_castDepends on:
include/stratax/core/dtypes/Concepts.hppinclude/stratax/exceptions/Exceptions.hppinclude/stratax/containers/Vector.hppinclude/stratax/containers/Matrix.hppinclude/stratax/containers/Tensor.hppThe following conditions are always true:
to_vector accepts shapes that are rank-1 or have exactly one non-singleton dimension.to_matrix accepts shapes that are rank-2 or have exactly two non-singleton dimensions.to_tensor preserves original shape exactly.astype preserves shape and element count.Throws
Exceptions::ShapeError for unsupported source shape in to_vector/to_matrixBehavior
static_cast<To> per element| Operation | Complexity |
|---|---|
is_vector_shape / is_matrix_shape | O(r) |
matrix_shape | O(r) |
to_vector / to_matrix / to_tensor | O(n + r) |
astype overloads | O(n) |
n is element count and r is rank.
Vector/matrix conversion is intentionally permissive for singleton dimensions, which simplifies interoperability with tensor-shaped data that carries redundant axes.