N-dimension data slicing help

How to slice multi-dimensional numeric data, and each slice is self-descriptive and can be used independently.

For N-dimensional data with N > 1 the elements of an arbitrary slice would not build a consecutive block of memory, so I strongly assume this is not possible.

If a 3 x 4 x 128 array is defined,and the linear order of array elements is
A1,1,1, A2,1,1, A3,1,1, A1,2,1, A2,2,1, ..., A3,4,1, A1,1,2, A2,1,2, ..., A3,4,128. Is it possible to solve?

ndarray has ArrayView - you could write your own indexing function if you want to avoid external crates...

2 Likes

I think the slicing documentation of ndarray should explain what you need: ArrayBase in ndarray - Rust

The s! macro is quite expressive.

1 Like

thank you. I'll give it a try