o
    %ôjŽL  ã                   @  s  d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ G dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ dƒZG dd„ deeƒZeƒ  Ze_G dd„ deeƒZeƒ  Ze_dS )zDomains of Gaussian type.é    )Úannotations)ÚI)ÚDMP)ÚCoercionFailed)ÚZZ)ÚQQ)ÚAlgebraicField)ÚDomain)ÚDomainElement)ÚField)ÚRingc                      s   e Zd ZU dZded< ded< dZd7dd„Ze‡ fd	d
„ƒZdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zedd„ ƒZdd„ ZeZdd „ Zd!d"„ Zd#d$„ ZeZd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Z ‡  Z!S )8ÚGaussianElementz1Base class for elements of Gaussian type domains.r	   ÚbaseÚ_parent)ÚxÚyr   c                 C  s   | j j}|  ||ƒ||ƒ¡S ©N)r   ÚconvertÚnew)Úclsr   r   Úconv© r   út/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/sympy/polys/domains/gaussiandomains.pyÚ__new__   s   zGaussianElement.__new__c                   s   t ƒ  | ¡}||_||_|S )z0Create a new GaussianElement of the same domain.)Úsuperr   r   r   )r   r   r   Úobj©Ú	__class__r   r   r      s   zGaussianElement.newc                 C  s   | j S )z4The domain that this is an element of (ZZ_I or QQ_I))r   ©Úselfr   r   r   Úparent#   s   zGaussianElement.parentc                 C  s   t | j| jfƒS r   )Úhashr   r   r   r   r   r   Ú__hash__'   ó   zGaussianElement.__hash__c                 C  s(   t || jƒr| j|jko| j|jkS tS r   )Ú
isinstancer   r   r   ÚNotImplemented©r   Úotherr   r   r   Ú__eq__*   s   zGaussianElement.__eq__c                 C  s&   t |tƒstS | j| jg|j|jgk S r   )r$   r   r%   r   r   r&   r   r   r   Ú__lt__0   s   
zGaussianElement.__lt__c                 C  ó   | S r   r   r   r   r   r   Ú__pos__5   ó   zGaussianElement.__pos__c                 C  s   |   | j | j ¡S r   ©r   r   r   r   r   r   r   Ú__neg__8   ó   zGaussianElement.__neg__c                 C  s   d| j j| j| jf S )Nz
%s(%s, %s))r   Úrepr   r   r   r   r   r   Ú__repr__;   s   zGaussianElement.__repr__c                 C  s   t | j | ¡ƒS r   )Ústrr   Úto_sympyr   r   r   r   Ú__str__>   r#   zGaussianElement.__str__c                 C  s<   t || ƒsz| j |¡}W n
 ty   Y dS w |j|jfS )N)NN)r$   r   r   r   r   r   )r   r'   r   r   r   Ú_get_xyA   s   
ÿzGaussianElement._get_xyc                 C  s2   |   |¡\}}|d ur|  | j| | j| ¡S tS r   ©r5   r   r   r   r%   ©r   r'   r   r   r   r   r   Ú__add__J   ó   zGaussianElement.__add__c                 C  s2   |   |¡\}}|d ur|  | j| | j| ¡S tS r   r6   r7   r   r   r   Ú__sub__S   r9   zGaussianElement.__sub__c                 C  s2   |   |¡\}}|d ur|  || j || j ¡S tS r   r6   r7   r   r   r   Ú__rsub__Z   r9   zGaussianElement.__rsub__c                 C  sF   |   |¡\}}|d ur!|  | j| | j|  | j| | j|  ¡S tS r   r6   r7   r   r   r   Ú__mul__a   s   ,zGaussianElement.__mul__c                 C  s„   |dkr
|   dd¡S |dk rd|  | } }|dkr| S | }|d r$| n| jj}|d }|r@||9 }|d r:||9 }|d }|s.|S )Nr   é   é   )r   r   Úone)r   ÚexpZpow2Úprodr   r   r   Ú__pow__j   s    üzGaussianElement.__pow__c                 C  s   t | jƒp	t | jƒS r   )Úboolr   r   r   r   r   r   Ú__bool__{   r/   zGaussianElement.__bool__c                 C  sJ   | j dkr| jdkrdS dS | j dk r| jdk rdS dS | jdkr#dS dS )zIReturn quadrant index 0-3.

        0 is included in quadrant 0.
        r   r=   r>   é   )r   r   r   r   r   r   Úquadrant~   s
   

zGaussianElement.quadrantc                 C  s2   z| j  |¡}W n ty   t Y S w | | ¡S r   )r   r   r   r%   Ú
__divmod__r&   r   r   r   Ú__rdivmod__Š   s   ÿ
zGaussianElement.__rdivmod__c                 C  s0   zt  |¡}W n ty   t Y S w | | ¡S r   )ÚQQ_Ir   r   r%   Ú__truediv__r&   r   r   r   Ú__rtruediv__’   s   ÿ
zGaussianElement.__rtruediv__c                 C  ó   |   |¡}|tu r|S |d S ©Nr   ©rG   r%   ©r   r'   Úqrr   r   r   Ú__floordiv__š   ó   
zGaussianElement.__floordiv__c                 C  rL   rM   ©rH   r%   rO   r   r   r   Ú__rfloordiv__ž   rR   zGaussianElement.__rfloordiv__c                 C  rL   ©Nr=   rN   rO   r   r   r   Ú__mod__¢   rR   zGaussianElement.__mod__c                 C  rL   rU   rS   rO   r   r   r   Ú__rmod__¦   rR   zGaussianElement.__rmod__)r   )"Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__Ú	__slots__r   Úclassmethodr   r    r"   r(   r)   r+   r.   r1   r4   r5   r8   Ú__radd__r:   r;   r<   Ú__rmul__rB   rD   rF   rH   rK   rQ   rT   rV   rW   Ú__classcell__r   r   r   r   r      sB   
 

r   c                   @  ó$   e Zd ZdZeZdd„ Zdd„ ZdS )ÚGaussianIntegerzîGaussian integer: domain element for :ref:`ZZ_I`

        >>> from sympy import ZZ_I
        >>> z = ZZ_I(2, 3)
        >>> z
        (2 + 3*I)
        >>> type(z)
        <class 'sympy.polys.domains.gaussiandomains.GaussianInteger'>
    c                 C  s   t  | ¡| S )úReturn a Gaussian rational.)rI   r   r&   r   r   r   rJ   ·   s   zGaussianInteger.__truediv__c           
      C  sª   |s	t d | ¡ƒ‚|  |¡\}}|d u rtS | j| | j|  | j | | j|  }}|| ||  }d| | d|  }d| | d|  }t||ƒ}	|	| |	|  fS )Nzdivmod({}, 0)r>   )ÚZeroDivisionErrorÚformatr5   r%   r   r   rc   )
r   r'   r   r   ÚaÚbÚcZqxZqyÚqr   r   r   rG   »   s   ,
zGaussianInteger.__divmod__N)rX   rY   rZ   r[   r   r   rJ   rG   r   r   r   r   rc   «   s
    	rc   c                   @  rb   )ÚGaussianRationala  Gaussian rational: domain element for :ref:`QQ_I`

        >>> from sympy import QQ_I, QQ
        >>> z = QQ_I(QQ(2, 3), QQ(4, 5))
        >>> z
        (2/3 + 4/5*I)
        >>> type(z)
        <class 'sympy.polys.domains.gaussiandomains.GaussianRational'>
    c                 C  sp   |s	t d | ¡ƒ‚|  |¡\}}|du rtS || ||  }t| j| | j|  | | j | | j|  | ƒS )rd   z{} / 0N)re   rf   r5   r%   rk   r   r   )r   r'   r   r   ri   r   r   r   rJ   ß   s   ÿzGaussianRational.__truediv__c                 C  sH   z| j  |¡}W n ty   t Y S w |std | ¡ƒ‚| | tjfS )Nz{} % 0)r   r   r   r%   re   rf   rI   Úzeror&   r   r   r   rG   ë   s   ÿzGaussianRational.__divmod__N)rX   rY   rZ   r[   r   r   rJ   rG   r   r   r   r   rk   Ó   s
    	rk   c                   @  s¢   e Zd ZU dZded< dZdZdZdZdd„ Z	dd„ Z
d	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#S )$ÚGaussianDomainz Base class for Gaussian domains.r	   ÚdomTc                 C  s    | j j}||jƒt||jƒ  S )z!Convert ``a`` to a SymPy object. )rn   r3   r   r   r   )r   rg   r   r   r   r   r3      s   zGaussianDomain.to_sympyc                 C  sb   |  ¡ \}}| j |¡}|s|  |d¡S | ¡ \}}| j |¡}|tu r*|  ||¡S td |¡ƒ‚)z)Convert a SymPy object to ``self.dtype``.r   z{} is not Gaussian)Úas_coeff_Addrn   Ú
from_sympyr   Úas_coeff_Mulr   r   rf   )r   rg   Úrrh   r   r   r   r   r   rp     s   zGaussianDomain.from_sympyc                 G  s
   | j |Ž S )z$Inject generators into this domain. )Ú	poly_ring)r   Úgensr   r   r   Úinject  s   
zGaussianDomain.injectc                 C  s   | j | ¡   }|S r   )ÚunitsrF   )r   ÚdÚunitr   r   r   Úcanonical_unit  s   zGaussianDomain.canonical_unitc                 C  ó   dS ©z/Returns ``False`` for any ``GaussianElement``. Fr   ©r   Úelementr   r   r   Úis_negative  ó   zGaussianDomain.is_negativec                 C  rz   r{   r   r|   r   r   r   Úis_positive  r   zGaussianDomain.is_positivec                 C  rz   r{   r   r|   r   r   r   Úis_nonnegative"  r   zGaussianDomain.is_nonnegativec                 C  rz   r{   r   r|   r   r   r   Úis_nonpositive&  r   zGaussianDomain.is_nonpositivec                 C  ó   | |ƒS )z%Convert a GMPY mpz to ``self.dtype``.r   ©ÚK1rg   ÚK0r   r   r   Úfrom_ZZ_gmpy*  ó   zGaussianDomain.from_ZZ_gmpyc                 C  rƒ   ©z.Convert a ZZ_python element to ``self.dtype``.r   r„   r   r   r   Úfrom_ZZ.  rˆ   zGaussianDomain.from_ZZc                 C  rƒ   r‰   r   r„   r   r   r   Úfrom_ZZ_python2  rˆ   zGaussianDomain.from_ZZ_pythonc                 C  rƒ   ©z%Convert a GMPY mpq to ``self.dtype``.r   r„   r   r   r   Úfrom_QQ6  rˆ   zGaussianDomain.from_QQc                 C  rƒ   rŒ   r   r„   r   r   r   Úfrom_QQ_gmpy:  rˆ   zGaussianDomain.from_QQ_gmpyc                 C  rƒ   )z.Convert a QQ_python element to ``self.dtype``.r   r„   r   r   r   Úfrom_QQ_python>  rˆ   zGaussianDomain.from_QQ_pythonc                 C  s$   |j jd tkr|  | |¡¡S dS )z9Convert an element from ZZ<I> or QQ<I> to ``self.dtype``.r   N)ÚextÚargsr   rp   r3   r„   r   r   r   Úfrom_AlgebraicFieldB  s   ÿz"GaussianDomain.from_AlgebraicFieldN)rX   rY   rZ   r[   r\   Úis_NumericalÚis_ExactÚhas_assoc_RingÚhas_assoc_Fieldr3   rp   ru   ry   r~   r€   r�   r‚   r‡   rŠ   r‹   r�   rŽ   r�   r’   r   r   r   r   rm   ö   s,   
 rm   c                   @  sð   e Zd ZdZeZeejejejgeƒZ	e
ZeedƒedƒƒZeedƒedƒƒZeedƒedƒƒZeee e fZdZdZdZdZdd„ Zdd	„ Zd
d„ Zedd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd S )!ÚGaussianIntegerRinga{
  Ring of Gaussian integers ``ZZ_I``

    The :ref:`ZZ_I` domain represents the `Gaussian integers`_ `\mathbb{Z}[i]`
    as a :py:class:`~.Domain` in the domain system (see
    :ref:`polys-domainsintro`).

    By default a :py:class:`~.Poly` created from an expression with
    coefficients that are combinations of integers and ``I`` (`\sqrt{-1}`)
    will have the domain :ref:`ZZ_I`.

    >>> from sympy import Poly, Symbol, I
    >>> x = Symbol('x')
    >>> p = Poly(x**2 + I)
    >>> p
    Poly(x**2 + I, x, domain='ZZ_I')
    >>> p.domain
    ZZ_I

    The :ref:`ZZ_I` domain can be used to factorise polynomials that are
    reducible over the Gaussian integers.

    >>> from sympy import factor
    >>> factor(x**2 + 1)
    x**2 + 1
    >>> factor(x**2 + 1, domain='ZZ_I')
    (x - I)*(x + I)

    The corresponding `field of fractions`_ is the domain of the Gaussian
    rationals :ref:`QQ_I`. Conversely :ref:`ZZ_I` is the `ring of integers`_
    of :ref:`QQ_I`.

    >>> from sympy import ZZ_I, QQ_I
    >>> ZZ_I.get_field()
    QQ_I
    >>> QQ_I.get_ring()
    ZZ_I

    When using the domain directly :ref:`ZZ_I` can be used as a constructor.

    >>> ZZ_I(3, 4)
    (3 + 4*I)
    >>> ZZ_I(5)
    (5 + 0*I)

    The domain elements of :ref:`ZZ_I` are instances of
    :py:class:`~.GaussianInteger` which support the rings operations
    ``+,-,*,**``.

    >>> z1 = ZZ_I(5, 1)
    >>> z2 = ZZ_I(2, 3)
    >>> z1
    (5 + 1*I)
    >>> z2
    (2 + 3*I)
    >>> z1 + z2
    (7 + 4*I)
    >>> z1 * z2
    (7 + 17*I)
    >>> z1 ** 2
    (24 + 10*I)

    Both floor (``//``) and modulo (``%``) division work with
    :py:class:`~.GaussianInteger` (see the :py:meth:`~.Domain.div` method).

    >>> z3, z4 = ZZ_I(5), ZZ_I(1, 3)
    >>> z3 // z4  # floor division
    (1 + -1*I)
    >>> z3 % z4   # modulo division (remainder)
    (1 + -2*I)
    >>> (z3//z4)*z4 + z3%z4 == z3
    True

    True division (``/``) in :ref:`ZZ_I` gives an element of :ref:`QQ_I`. The
    :py:meth:`~.Domain.exquo` method can be used to divide in :ref:`ZZ_I` when
    exact division is possible.

    >>> z1 / z2
    (1 + -1*I)
    >>> ZZ_I.exquo(z1, z2)
    (1 + -1*I)
    >>> z3 / z4
    (1/2 + -3/2*I)
    >>> ZZ_I.exquo(z3, z4)
    Traceback (most recent call last):
        ...
    ExactQuotientFailed: (1 + 3*I) does not divide (5 + 0*I) in ZZ_I

    The :py:meth:`~.Domain.gcd` method can be used to compute the `gcd`_ of any
    two elements.

    >>> ZZ_I.gcd(ZZ_I(10), ZZ_I(2))
    (2 + 0*I)
    >>> ZZ_I.gcd(ZZ_I(5), ZZ_I(2, 1))
    (2 + 1*I)

    .. _Gaussian integers: https://en.wikipedia.org/wiki/Gaussian_integer
    .. _gcd: https://en.wikipedia.org/wiki/Greatest_common_divisor

    r   r=   ÚZZ_ITc                 C  rz   )zFor constructing ZZ_I.Nr   r   r   r   r   Ú__init__º  ó    zGaussianIntegerRing.__init__c                 C  ó   t |tƒrdS tS ©z0Returns ``True`` if two domains are equivalent. T)r$   r—   r%   r&   r   r   r   r(   ½  ó   
zGaussianIntegerRing.__eq__c                 C  ó   t dƒS )úCompute hash code of ``self``. r˜   ©r!   r   r   r   r   r"   Ä  rˆ   zGaussianIntegerRing.__hash__c                 C  rz   ©NTr   r   r   r   r   Úhas_CharacteristicZeroÈ  r   z*GaussianIntegerRing.has_CharacteristicZeroc                 C  rz   rM   r   r   r   r   r   ÚcharacteristicÌ  r,   z"GaussianIntegerRing.characteristicc                 C  r*   ©z)Returns a ring associated with ``self``. r   r   r   r   r   Úget_ringÏ  r   zGaussianIntegerRing.get_ringc                 C  ó   t S ©z*Returns a field associated with ``self``. )rI   r   r   r   r   Ú	get_fieldÓ  r   zGaussianIntegerRing.get_fieldc                   s:   |   |¡‰ |ˆ 9 }t‡ fdd„|D ƒƒ}|r|f| S |S )z€Return first quadrant element associated with ``d``.

        Also multiply the other arguments by the same power of i.
        c                 3  s   � | ]}|ˆ  V  qd S r   r   )Ú.0rg   ©rx   r   r   Ú	<genexpr>Þ  s   € z0GaussianIntegerRing.normalize.<locals>.<genexpr>)ry   Útuple)r   rw   r‘   r   rª   r   Ú	normalize×  s   
zGaussianIntegerRing.normalizec                 C  s    |r||| }}|s|   |¡S )z-Greatest common divisor of a and b over ZZ_I.)r­   ©r   rg   rh   r   r   r   Úgcdá  s   ÿ
zGaussianIntegerRing.gcdc                 C  s|   | j }| j}| j}| j }|r/|| }||||  }}||||  }}||||  }}|s|  |||¡\}}}|||fS )z6Return x, y, g such that x * a + y * b = g = gcd(a, b))r?   rl   r­   )r   rg   rh   Zx_aZx_bZy_aZy_brj   r   r   r   Úgcdexç  s   ü
zGaussianIntegerRing.gcdexc                 C  s   || |   ||¡ S )z+Least common multiple of a and b over ZZ_I.)r¯   r®   r   r   r   Úlcmö  s   zGaussianIntegerRing.lcmc                 C  ó   |S )zConvert a ZZ_I element to ZZ_I.r   r„   r   r   r   Úfrom_GaussianIntegerRingú  r   z,GaussianIntegerRing.from_GaussianIntegerRingc                 C  ó   |   t |j¡t |j¡¡S )zConvert a QQ_I element to ZZ_I.)r   r   r   r   r   r„   r   r   r   Úfrom_GaussianRationalFieldþ  ó   z.GaussianIntegerRing.from_GaussianRationalFieldN) rX   rY   rZ   r[   r   rn   r   r?   rl   Úmodrc   ÚdtypeÚ	imag_unitrv   r0   Úis_GaussianRingÚis_ZZ_IÚis_PIDr™   r(   r"   Úpropertyr¢   r£   r¥   r¨   r­   r¯   r°   r±   r³   rµ   r   r   r   r   r—   H  s6    c

r—   c                   @  sì   e Zd ZdZeZeejejejgeƒZ	e
ZeedƒedƒƒZeedƒedƒƒZeedƒedƒƒZeee e fZdZdZdZdd„ Zdd	„ Zd
d„ Zedd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd S )!ÚGaussianRationalFielda—  Field of Gaussian rationals ``QQ_I``

    The :ref:`QQ_I` domain represents the `Gaussian rationals`_ `\mathbb{Q}(i)`
    as a :py:class:`~.Domain` in the domain system (see
    :ref:`polys-domainsintro`).

    By default a :py:class:`~.Poly` created from an expression with
    coefficients that are combinations of rationals and ``I`` (`\sqrt{-1}`)
    will have the domain :ref:`QQ_I`.

    >>> from sympy import Poly, Symbol, I
    >>> x = Symbol('x')
    >>> p = Poly(x**2 + I/2)
    >>> p
    Poly(x**2 + I/2, x, domain='QQ_I')
    >>> p.domain
    QQ_I

    The polys option ``gaussian=True`` can be used to specify that the domain
    should be :ref:`QQ_I` even if the coefficients do not contain ``I`` or are
    all integers.

    >>> Poly(x**2)
    Poly(x**2, x, domain='ZZ')
    >>> Poly(x**2 + I)
    Poly(x**2 + I, x, domain='ZZ_I')
    >>> Poly(x**2/2)
    Poly(1/2*x**2, x, domain='QQ')
    >>> Poly(x**2, gaussian=True)
    Poly(x**2, x, domain='QQ_I')
    >>> Poly(x**2 + I, gaussian=True)
    Poly(x**2 + I, x, domain='QQ_I')
    >>> Poly(x**2/2, gaussian=True)
    Poly(1/2*x**2, x, domain='QQ_I')

    The :ref:`QQ_I` domain can be used to factorise polynomials that are
    reducible over the Gaussian rationals.

    >>> from sympy import factor, QQ_I
    >>> factor(x**2/4 + 1)
    (x**2 + 4)/4
    >>> factor(x**2/4 + 1, domain='QQ_I')
    (x - 2*I)*(x + 2*I)/4
    >>> factor(x**2/4 + 1, domain=QQ_I)
    (x - 2*I)*(x + 2*I)/4

    It is also possible to specify the :ref:`QQ_I` domain explicitly with
    polys functions like :py:func:`~.apart`.

    >>> from sympy import apart
    >>> apart(1/(1 + x**2))
    1/(x**2 + 1)
    >>> apart(1/(1 + x**2), domain=QQ_I)
    I/(2*(x + I)) - I/(2*(x - I))

    The corresponding `ring of integers`_ is the domain of the Gaussian
    integers :ref:`ZZ_I`. Conversely :ref:`QQ_I` is the `field of fractions`_
    of :ref:`ZZ_I`.

    >>> from sympy import ZZ_I, QQ_I, QQ
    >>> ZZ_I.get_field()
    QQ_I
    >>> QQ_I.get_ring()
    ZZ_I

    When using the domain directly :ref:`QQ_I` can be used as a constructor.

    >>> QQ_I(3, 4)
    (3 + 4*I)
    >>> QQ_I(5)
    (5 + 0*I)
    >>> QQ_I(QQ(2, 3), QQ(4, 5))
    (2/3 + 4/5*I)

    The domain elements of :ref:`QQ_I` are instances of
    :py:class:`~.GaussianRational` which support the field operations
    ``+,-,*,**,/``.

    >>> z1 = QQ_I(5, 1)
    >>> z2 = QQ_I(2, QQ(1, 2))
    >>> z1
    (5 + 1*I)
    >>> z2
    (2 + 1/2*I)
    >>> z1 + z2
    (7 + 3/2*I)
    >>> z1 * z2
    (19/2 + 9/2*I)
    >>> z2 ** 2
    (15/4 + 2*I)

    True division (``/``) in :ref:`QQ_I` gives an element of :ref:`QQ_I` and
    is always exact.

    >>> z1 / z2
    (42/17 + -2/17*I)
    >>> QQ_I.exquo(z1, z2)
    (42/17 + -2/17*I)
    >>> z1 == (z1/z2)*z2
    True

    Both floor (``//``) and modulo (``%``) division can be used with
    :py:class:`~.GaussianRational` (see :py:meth:`~.Domain.div`)
    but division is always exact so there is no remainder.

    >>> z1 // z2
    (42/17 + -2/17*I)
    >>> z1 % z2
    (0 + 0*I)
    >>> QQ_I.div(z1, z2)
    ((42/17 + -2/17*I), (0 + 0*I))
    >>> (z1//z2)*z2 + z1%z2 == z1
    True

    .. _Gaussian rationals: https://en.wikipedia.org/wiki/Gaussian_rational
    r   r=   rI   Tc                 C  rz   )zFor constructing QQ_I.Nr   r   r   r   r   r™   ‡  rš   zGaussianRationalField.__init__c                 C  r›   rœ   )r$   r¾   r%   r&   r   r   r   r(   Š  r�   zGaussianRationalField.__eq__c                 C  rž   )rŸ   rI   r    r   r   r   r   r"   ‘  rˆ   zGaussianRationalField.__hash__c                 C  rz   r¡   r   r   r   r   r   r¢   •  r   z,GaussianRationalField.has_CharacteristicZeroc                 C  rz   rM   r   r   r   r   r   r£   ™  r,   z$GaussianRationalField.characteristicc                 C  r¦   r¤   )r˜   r   r   r   r   r¥   œ  r   zGaussianRationalField.get_ringc                 C  r*   r§   r   r   r   r   r   r¨      r   zGaussianRationalField.get_fieldc                 C  s   t | jtƒS )z0Get equivalent domain as an ``AlgebraicField``. )r   rn   r   r   r   r   r   Úas_AlgebraicField¤  s   z'GaussianRationalField.as_AlgebraicFieldc                 C  s   |   ¡ }| ||  |¡ ¡S )zGet the numerator of ``a``.)r¥   r   Údenom)r   rg   r˜   r   r   r   Únumer¨  s   zGaussianRationalField.numerc                 C  s@   | j  ¡ }| j }|  ¡ }| | |j¡| |j¡¡}|||jƒS )zGet the denominator of ``a``.)rn   r¥   r±   rÀ   r   r   rl   )r   rg   r   r   r˜   Zdenom_ZZr   r   r   rÀ   ­  s
   
zGaussianRationalField.denomc                 C  s   |   |j|j¡S )zConvert a ZZ_I element to QQ_I.r-   r„   r   r   r   r³   µ  s   z.GaussianRationalField.from_GaussianIntegerRingc                 C  r²   )zConvert a QQ_I element to QQ_I.r   r„   r   r   r   rµ   ¹  r   z0GaussianRationalField.from_GaussianRationalFieldc                 C  r´   )z'Convert a ComplexField element to QQ_I.)r   r   r   ÚrealÚimagr„   r   r   r   Úfrom_ComplexField½  r¶   z'GaussianRationalField.from_ComplexFieldN)rX   rY   rZ   r[   r   rn   r   r?   rl   r·   rk   r¸   r¹   rv   r0   Úis_GaussianFieldÚis_QQ_Ir™   r(   r"   r½   r¢   r£   r¥   r¨   r¿   rÁ   rÀ   r³   rµ   rÄ   r   r   r   r   r¾     s4    t
r¾   N) r[   Ú
__future__r   Úsympy.core.numbersr   Úsympy.polys.polyclassesr   Úsympy.polys.polyerrorsr   Zsympy.polys.domains.integerringr   Z!sympy.polys.domains.rationalfieldr   Z"sympy.polys.domains.algebraicfieldr   Zsympy.polys.domains.domainr	   Ú!sympy.polys.domains.domainelementr
   Úsympy.polys.domains.fieldr   Úsympy.polys.domains.ringr   r   rc   rk   rm   r—   r˜   r   r¾   rI   r   r   r   r   Ú<module>   s.     (#R ; >