private final static int[] shapeToStrides(final int[] shape, final int nElements) {
        final int[] strides = new int[shape.length];
        int stride = nElements;
        for (int i = shape.length - 1; i >= 0; i--) {
            strides[i] = stride;
            stride *= shape[i];
        }
        return strides;
    }