public static int [ ] unravelIndexFromStrides ( int configIx , int ... strides ) { int offset = 0 ; int [ ] config = new int [ strides . length ] ; // fill things out from slowest to fastest for ( int i = 0 ; i < strides . length ; i ++ ) { // how many strides are we passed the offset int ix = ( configIx - offset ) / strides [ i ] ; config [ i ] = ix ; // move the offset offset += ix * strides [ i ] ; } return config ; }
strides are given in order from left to right slowest to fastest