def mapRtoQ(ABCDr):
    """Map a real ABCD matrix to a quadrature one.

    **Parameters:**

    ABCDr : ndarray
        A real matrix describing a quadrature system.

    ``ABCDr`` has its states paired (real, imaginary).

    **Returns:**

    (ABCDq, ABCDp) : tuple

    Where:

    ABCDq : ndarray
        is the quadrature (complex) version of ABCDr.
    ABCDp : ndarray
        is the mirror-image system matrix.

    .. note:: ``ABCDp`` is zero if ``ABCDr`` has no quadrature errors.
    """
    ABCD11 = ABCDr[::2,   ::2]
    ABCD12 = ABCDr[::2,  1::2]
    ABCD21 = ABCDr[1::2,  ::2]
    ABCD22 = ABCDr[1::2, 1::2]

    ABCDq = 0.5*(ABCD11 + ABCD22) + 0.5j*(ABCD21 - ABCD12);
    ABCDp = 0.5*(ABCD11 - ABCD22) + 0.5j*(ABCD21 + ABCD12);

    return ABCDq, ABCDp