static PyMultiarray rotateAxes(final PyMultiarray a, int n) {
        final PyMultiarray result = new PyMultiarray(
                a.data,
                a._typecode,
                a.start,
                a.dimensions.clone(),
                a.strides.clone());
        while (n < 0) {
            n += a.dimensions.length;
        }
        for (int i = 0; i < a.dimensions.length; i++) {
            result.dimensions[(i + n) % a.dimensions.length] = a.dimensions[i];
            result.strides[(i + n) % a.dimensions.length] = a.strides[i];
        }
        result.setIsContiguous();
        return result;
    }