Indexing an n-dimensional array stored as a 1d array

28 views Asked by At

Consider we have an n-dimensional array. (In many cases, N is greater than 3)

Assume the array is stored as a single contiguous block of memory in a 1-dimensional array.

How would one index the array such that the values along a specific dimension can be compared.

Using a library one could simply just do ndarray.topk(3, dim=1) or ndarray.argmin(dim=1).

Without using a tool like PyTorch or numpy, I want to understand how to index the 1-d array in such a way that I can work with the values along a specific dimension to calculate the maximum value or maybe the top k values.

0

There are 0 answers