-
#include "tensorstore/index_space/dim_expression.h"
-
template <typename TargetDimensions>
auto tensorstore::DimExpression<Op...>::Transpose(
const TargetDimensions& target_dimensions) const; Transposes the input dimensions such that the selected dimensions have the specified indices. Dimensions not in the selection retain their relative order and fill in the dimension indices not in
target_dimensions
.The new dimension selection is equal to
target_dimensions
after normalization.For example,
Dims(2, 0).Transpose({1, 2})
has the following effects:Before
After
Dimension selection
{2, 0}
{1, 2}
Input domain
[1*, 3], [2, 5*], [3, 4]
[2, 5*], [3, 4], [1*, 3]
Labels
{"x", "y", "z"}
{"y", "z", "x"}
Equivalent input indices
{2, 3, 4}
{3, 4, 2}
Equivalent input indices
{x, y, z}
{y, z, x}
where
x
is any index in[1, 3]
,y
is any index in[2, 5]
, andz
is any index in[3, 4]
.- Requires:¶
TargetDimensions
isspan
-compatible with aspan::value_type
ofDimensionIndex
and a static extent compatible with the static rank of the dimension selection.- Parameters:¶
- const TargetDimensions &target_dimensions¶
The new dimension indices corresponding to each selected dimension. May be a braced list, e.g.
Transpose({1, 2})
. A negative value of-n
is equivalent toinput_rank - n
, whereinput_rank
is the input rank of the transform to which this operation is applied.
- Error absl::StatusCode::kInvalidArgument:¶
if the rank of the dimension selection is not equal to the length of
target_dimensions
, or if the indices intarget_dimensions
are not unique or outside the valid range.