-
#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::c
corresponds to{0, 1, 2, ...}
whileContiguousLayoutOrder::fortran
corresponds to{..., 2, 1, 0}
.Constructors¶
- ContiguousLayoutPermutation();
Constructs a rank-0 (empty) permutation.
- ContiguousLayoutPermutation(ContiguousLayoutPermutation<R> other);
Converts from another
ContiguousLayoutPermutation
with compatible rank.
-
explicit ContiguousLayoutPermutation(
span<const DimensionIndex, Rank> permutation); Constructs from a span.
Related Functions¶
-
void tensorstore::SetPermutation(ContiguousLayoutOrder order,
span<DimensionIndex> permutation); Sets
permutation
to ascending or descending order.
-
bool tensorstore::IsValidPermutation(
span<const DimensionIndex> permutation); Returns
true
ifpermutation
is a valid permutation of{0, 1, ..., permutation.size()-1}
.
-
bool tensorstore::PermutationMatchesOrder(
span<const DimensionIndex> permutation,
ContiguousLayoutOrder order); Returns
true
ifpermutation
is{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_perm
to the inverse permutation ofperm
.
-
void tensorstore::ConvertToContiguousLayoutPermutation(
LayoutOrder source,
span<DimensionIndex, Rank> target); Normalizes
source
to a permutation if it is not already a permuation.
-
void tensorstore::SetPermutationFromStrides(
span<const Index> strides,
span<DimensionIndex> permutation); Sets
permutation
to a permutation that matches the dimension order ofstrides
.