static void copyAToB(final PyMultiarray a, final PyMultiarray b) {
        if (a.dimensions.length != b.dimensions.length) { throw Py
                .ValueError("copied matrices must have the same number of dimensions"); }
        for (int i = 0; i < a.dimensions.length; i++) {
            if (a.dimensions[i] != b.dimensions[i]) { throw Py
                    .ValueError("matrices not aligned for copy"); }
        }
        if (a._typecode == b._typecode && a.isContiguous && b.isContiguous) {
            System.arraycopy(
                    a.data,
                    a.start,
                    b.data,
                    b.start,
                    PyMultiarray.typeToNElements(a._typecode)
                            * PyMultiarray.shapeToNItems(a.dimensions));
        } else if (a.dimensions.length == 0) {
            b.__setitem__(Py.Ellipsis, a.__getitem__(Py.Ellipsis));
        } else if (a._typecode == b._typecode && a._typecode != 'F'
                && a._typecode != 'D') {
            PyMultiarray.copyAxToBx(
                    a.data,
                    a.start,
                    a.strides,
                    b.data,
                    b.start,
                    b.strides,
                    b.dimensions,
                    0);
        } else if (a._typecode == 'O') {
            PyMultiarray.copyAOToB(
                    a.data,
                    a.start,
                    a.strides,
                    b.data,
                    b.start,
                    b.strides,
                    b._typecode,
                    b.dimensions,
                    0);
        } else {
            switch (b._typecode) {
            case '1':
                PyMultiarray.copyAToBb(
                        a.data,
                        a.start,
                        a.strides,
                        b.data,
                        b.start,
                        b.strides,
                        b.dimensions,
                        0);
                break;
            case 's':
                PyMultiarray.copyAToBs(
                        a.data,
                        a.start,
                        a.strides,
                        b.data,
                        b.start,
                        b.strides,
                        b.dimensions,
                        0);
                break;
            case 'i':
                PyMultiarray.copyAToBi(
                        a.data,
                        a.start,
                        a.strides,
                        b.data,
                        b.start,
                        b.strides,
                        b.dimensions,
                        0);
                break;
            case 'l':
                PyMultiarray.copyAToBl(
                        a.data,
                        a.start,
                        a.strides,
                        b.data,
                        b.start,
                        b.strides,
                        b.dimensions,
                        0);
                break;
            case 'f':
                PyMultiarray.copyAToBf(
                        a.data,
                        a.start,
                        a.strides,
                        b.data,
                        b.start,
                        b.strides,
                        b.dimensions,
                        0);
                break;
            case 'd':
                PyMultiarray.copyAToBd(
                        a.data,
                        a.start,
                        a.strides,
                        b.data,
                        b.start,
                        b.strides,
                        b.dimensions,
                        0);
                break;
            case 'F':
                if (a._typecode == 'F' || a._typecode == 'D') {
                    PyMultiarray.copyAToBF(
                            a.data,
                            a.start,
                            a.strides,
                            b.data,
                            b.start,
                            b.strides,
                            b.dimensions,
                            0);
                } else {
                    PyMultiarray.copyAToBf(
                            a.data,
                            a.start,
                            a.strides,
                            b.data,
                            b.start,
                            b.strides,
                            b.dimensions,
                            0);
                }
                break;
            case 'D':
                if (a._typecode == 'F' || a._typecode == 'D') {
                    PyMultiarray.copyAToBD(
                            a.data,
                            a.start,
                            a.strides,
                            b.data,
                            b.start,
                            b.strides,
                            b.dimensions,
                            0);
                } else {
                    PyMultiarray.copyAToBd(
                            a.data,
                            a.start,
                            a.strides,
                            b.data,
                            b.start,
                            b.strides,
                            b.dimensions,
                            0);
                }
                break;
            case 'O':
                PyMultiarray.copyAToBO(
                        a.data,
                        a.start,
                        a.strides,
                        b.data,
                        b.start,
                        b.strides,
                        b.dimensions,
                        0);
                break;
            default:
                throw Py.ValueError("typecode must be in [1silfFdDO]");
            }
        }
    }