code: public static long offset(long[] strides, long[] offsets) {
          int ret = 0;
  
          if (ArrayUtil.prod(offsets) == 1) {
              for (int i = 0; i < offsets.length; i++) {
                  ret += offsets[i] * strides[i];
              }
          } else {
              for (int i = 0; i < offsets.length; i++) {
                  ret += offsets[i] * strides[i];
              }
  
          }
  
          return ret;
      }
docs: Compute the offset given an array of offsets.
  The offset is computed(for both fortran an d c ordering) as:
  sum from i to n - 1 o[i] * s[i]
  where i is the index o is the offset and s is the stride
  Notice the -1 at the end.
  @param strides the strides to compute the offset for
  @param offsets the offsets for each dimension
  @return the offset that should be used for indexing