code: public static int[] ind2subC(int[] shape, long index, long numIndices) {
          long denom = numIndices;
          int[] ret = new int[shape.length];
          for (int i = 0; i < shape.length; i++) {
              denom /= shape[i];
              if (index / denom >= Integer.MAX_VALUE)
                  throw new IllegalArgumentException("Dimension can not be >= Integer.MAX_VALUE");
              ret[i] = (int) (index / denom);
              index %= denom;
  
          }
          return ret;
      }
docs: Convert a linear index to
  the equivalent nd index
  @param shape the shape of the dimensions
  @param index the index to map
  @param numIndices the number of total indices (typically prod of shape(
  @return the mapped indexes along each dimension