*   (e.g., (10,) for a 10-element vector, [2, 5] for a 2 by 5 matrix))
     * @return The resized multiarray
     */
    public static PyMultiarray resize(final PyObject o, final int[] shape) {
        final PyMultiarray a = PyMultiarray.ascontiguous(PyMultiarray.reshape(
                PyMultiarray.asarray(o),
                new int[] { -1 }));
        final int nItems = PyMultiarray.shapeToNItems(shape);
        final int nCopies = nItems / a.dimensions[0];
        final int extra = nItems % a.dimensions[0];
        final int nElements = PyMultiarray.typeToNElements(a._typecode);
        final PyMultiarray result = PyMultiarray.zeros(shape, a._typecode);
        for (int i = 0; i < nCopies; i++) {
            System.arraycopy(a.data, a.start, result.data, i * a.dimensions[0]
                    * nElements, a.dimensions[0] * nElements);
        }
        System.arraycopy(a.data, a.start, result.data, nCopies
                * a.dimensions[0] * nElements, extra * nElements);
        return result;
    }