-
#include "tensorstore/contiguous_layout.h" -
template <DimensionIndex Rank = dynamic_rank>
struct tensorstore::ContiguousLayoutPermutation
: public span<const DimensionIndex, Rank>; Specifies a contiguous layout order as a permutation.
The first element specifies the outermost dimension and the last element specifies the innermost dimension.
ContiguousLayoutOrder::ccorresponds to{0, 1, 2, ...}whileContiguousLayoutOrder::fortrancorresponds to{..., 2, 1, 0}.Constructors¶
- ContiguousLayoutPermutation();
Constructs a rank-0 (empty) permutation.
- ContiguousLayoutPermutation(ContiguousLayoutPermutation<R> other);
Converts from another
ContiguousLayoutPermutationwith compatible rank.
-
explicit ContiguousLayoutPermutation(
span<const DimensionIndex, Rank> permutation); Constructs from a span.
Related Functions¶
-
void tensorstore::SetPermutation(ContiguousLayoutOrder order,
span<DimensionIndex> permutation); Sets
permutationto ascending or descending order.
-
bool tensorstore::IsValidPermutation(
span<const DimensionIndex> permutation); Returns
trueifpermutationis a valid permutation of{0, 1, ..., permutation.size()-1}.
-
bool tensorstore::PermutationMatchesOrder(
span<const DimensionIndex> permutation,
ContiguousLayoutOrder order); Returns
trueifpermutationis{0, 1, ..., permutation.size()-1}iforder == c_order, or{permutation.size() - 1, ..., 1, 0}iforder == fortran_order.
-
void tensorstore::InvertPermutation(DimensionIndex rank,
const DimensionIndex* perm,
DimensionIndex* inverse_perm); Sets
inverse_permto the inverse permutation ofperm.
-
void tensorstore::ConvertToContiguousLayoutPermutation(
LayoutOrder source,
span<DimensionIndex, Rank> target); Normalizes
sourceto a permutation if it is not already a permutation.
-
void tensorstore::SetPermutationFromStrides(
span<const Index> strides,
span<DimensionIndex> permutation); Sets
permutationto a permutation that matches the dimension order ofstrides.