#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, ...} while ContiguousLayoutOrder::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.

void tensorstore::SetPermutation(ContiguousLayoutOrder order,
                                 
span<DimensionIndex> permutation);

Sets permutation to ascending or descending order.

bool tensorstore::IsValidPermutation(
    
span<const DimensionIndex> permutation);

Returns true if permutation is a valid permutation of {0, 1, ..., permutation.size()-1}.

bool tensorstore::PermutationMatchesOrder(
    
span<const DimensionIndex> permutation,
    
ContiguousLayoutOrder order);

Returns true if permutation is {0, 1, ..., permutation.size()-1} if order == c_order, or {permutation.size() - 1, ..., 1, 0} if order == fortran_order.

void tensorstore::InvertPermutation(DimensionIndex rank,
                                    
const DimensionIndexperm,
                                    
DimensionIndexinverse_perm);

Sets inverse_perm to the inverse permutation of perm.

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 of strides.