Exemple #1
0
    def _repr_(self):
        r"""
        Return a representation string of this imaginary element.

        TESTS::

            sage: from sage.groups.misc_gps.imaginary_groups import ImaginaryGroup
            sage: J = ImaginaryGroup(ZZ)
            sage: J(imag=0)  # indirect doctest
            0
            sage: J(imag=1)  # indirect doctest
            I
            sage: J(imag=-1)  # indirect doctest
            -I
            sage: J(imag=42)  # indirect doctest
            42*I
            sage: J(imag=-42)  # indirect doctest
            -42*I
        """
        from sage.rings.asymptotic.misc import repr_op
        if self._imag_ == 0:
            return '0'
        if self._imag_ == 1:
            return 'I'
        if self._imag_ == -1:
            return '-I'
        return repr_op(self._imag_, '*', 'I')
Exemple #2
0
    def _repr_short_(self):
        r"""
        Return a short representation string of this imaginary group.

        TESTS::

            sage: from sage.groups.misc_gps.imaginary_groups import ImaginaryGroup
            sage: J = ImaginaryGroup(ZZ)
            sage: J._repr_short_()
            'ZZ*I'
        """
        from sage.rings.asymptotic.misc import parent_to_repr_short, repr_op
        return repr_op(parent_to_repr_short(self.base()), '*', 'I')