index_order

Function index_order 

Source
pub fn index_order(strides: &[isize]) -> Vec<usize>
Expand description

Compute the relative order of strides.

Returns a vector where result[i] is the rank of strides[i] among all non-zero strides. Zero strides have order 1.

ยงJulia equivalent

function indexorder(strides::NTuple{N,Int}) where {N}
    return ntuple(Val(N)) do i
        si = abs(strides[i])
        si == 0 && return 1
        k = 1
        for s in strides
            if s != 0 && abs(s) < si
                k += 1
            end
        end
        return k
    end
end