docs: public static long sub2Ind(int[] shape, int[] indices) {
          long index = 0;
          int shift = 1;
          for (int i = 0; i < shape.length; i++) {
              index += shift * indices[i];
              shift *= shape[i];
          }
          return index;
      }