static PyMultiarray swapAxes(final PyMultiarray a, int n0, int n1) {
        final PyMultiarray result = new PyMultiarray(
                a.data,
                a._typecode,
                a.start,
                a.dimensions.clone(),
                a.strides.clone());
        if (n0 < 0) {
            n0 += a.dimensions.length;
        }
        if (n1 < 0) {
            n1 += a.dimensions.length;
        }
        if (n0 < 0 || n0 >= a.dimensions.length || n1 < 0
                || n1 >= a.dimensions.length) { throw Py
                .ValueError("illegal axis"); }
        result.dimensions[n0] = a.dimensions[n1];
        result.strides[n0] = a.strides[n1];
        result.dimensions[n1] = a.dimensions[n0];
        result.strides[n1] = a.strides[n0];
        result.setIsContiguous();
        return result;
    }