Open
Description
I need a function that, given an index in the underlying array, returns the ndarray index: [i,j,...]
;
I implemented it in my code (without the compilation logic of ndarray
), and thought it might be useful within this project, since index
is already there.
function unindex(ndarr, n)
{
const result = new Array( ndarr.shape.length );
n = n - ndarr.offset;
ndarr.stride.forEach( (stride, i)=>{
result[i] = Math.floor( n / stride );
n %= stride;
});
return result;
};
Metadata
Metadata
Assignees
Labels
No labels