+
    .åûjŽL  ã                  óL  € R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt  ! R R]4      t ! R R]4      t ! R R]4      t ! R R4      t ! R R]]4      t]! 4       ;t]n         ! R R]]4      t]! 4       ;t]n        R# )zDomains of Gaussian type.)Úannotations)ÚI)ÚDMP)ÚCoercionFailed)ÚZZ)ÚQQ)ÚAlgebraicField)ÚDomain)ÚDomainElement)ÚField)ÚRingc                  óð   a € ] tR t^t$ RtR]R&   R]R&   RtRR lt]V 3R l4       t	R t
R tR	 tR
 tR tR tR tR t]R 4       tR t]tR tR tR t]tR tR tR tR tR tR tR tR t R t!Rt"V ;t## ) ÚGaussianElementz1Base class for elements of Gaussian type domains.r	   ÚbaseÚ_parentc                	ój   € V P                   P                  pV P                  V! V4      V! V4      4      # ©N)r   ÚconvertÚnew)ÚclsÚxÚyÚconvs   &&& Ú_C:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\sympy\polys\domains\gaussiandomains.pyÚ__new__ÚGaussianElement.__new__   s*   € Ø�x‰x×ÑˆØ�w‰w‘t˜A“w¡ Q£Ó(Ð(ó    c                ó>   <€ \         SV `  V 4      pWn        W#n        V# )z0Create a new GaussianElement of the same domain.)Úsuperr   r   r   )r   r   r   ÚobjÚ	__class__s   &&& €r   r   ÚGaussianElement.new   s"   ø€ ô ‰g‰o˜cÓ"ˆØŒØŒØˆ
r   c                ó   € V P                   # )z4The domain that this is an element of (ZZ_I or QQ_I))r   ©Úselfs   &r   ÚparentÚGaussianElement.parent#   s   € à�|‰|Ðr   c                	óD   € \        V P                  V P                  34      # r   )Úhashr   r   r#   s   &r   Ú__hash__ÚGaussianElement.__hash__'   s   € Ü�T—V‘V˜TŸV™VÐ$Ó%Ð%r   c                	ó¸   € \        WP                  4      '       d;   V P                  VP                  8H  ;'       d    V P                  VP                  8H  # \        # r   )Ú
isinstancer    r   r   ÚNotImplemented©r$   Úothers   &&r   Ú__eq__ÚGaussianElement.__eq__*   s?   € Ü�eŸ^™^×,Ò,Ø—6‘6˜UŸW™WÑ$×:Ð:¨¯©°5·7±7Ñ):Ð:ä!Ð!r   c                	óœ   € \        V\        4      '       g   \        # V P                  V P                  .VP                  VP                  .8  # r   )r,   r   r-   r   r   r.   s   &&r   Ú__lt__ÚGaussianElement.__lt__0   s:   € Ü˜%¤×1Ò1Ü!Ð!Ø—‘˜Ÿ™Ð 5§7¡7¨E¯G©GÐ"4Ñ4Ð4r   c                	ó   € V # r   © r#   s   &r   Ú__pos__ÚGaussianElement.__pos__5   s   € Øˆr   c                	óR   € V P                  V P                  ) V P                  ) 4      # r   ©r   r   r   r#   s   &r   Ú__neg__ÚGaussianElement.__neg__8   s   € Ø�x‰x˜Ÿ™˜ $§&¡& Ó)Ð)r   c                	ón   € V P                   P                  : R V P                  : RV P                  : R2# )Ú(z, Ú))r   Úrepr   r   r#   s   &r   Ú__repr__ÚGaussianElement.__repr__;   s!   € Ø#Ÿ|™|×/Ô/°·´¸¿¼Ð@Ð@r   c                	óJ   € \        V P                  P                  V 4      4      # r   )Ústrr   Úto_sympyr#   s   &r   Ú__str__ÚGaussianElement.__str__>   s   € Ü�4—<‘<×(Ñ(¨Ó.Ó/Ð/r   c                	ó²   € \        W4      '       g    V P                  P                  V4      pVP                  VP
                  3#   \         d    Ru # i ; i)N)NN)r,   r   r   r   r   r   )r   r/   s   &&r   Ú_get_xyÚGaussianElement._get_xyA   sR   € ä˜%×%Ò%ð"ØŸ™×+Ñ+¨EÓ2�ð �w‰w˜Ÿ™ÐÐøô "ô "Ø!Ò!ð"ús   “A ÁAÁAc                	ó¤   € V P                  V4      w  r#Ve5   V P                  V P                  V,           V P                  V,           4      # \        # r   ©rI   r   r   r   r-   ©r$   r/   r   r   s   &&  r   Ú__add__ÚGaussianElement.__add__J   ó>   € Ø�|‰|˜EÓ"‰ˆØŠ=Ø—8‘8˜DŸF™F Q�J¨¯©°­
Ó3Ð3ä!Ð!r   c                	ó¤   € V P                  V4      w  r#Ve5   V P                  V P                  V,
          V P                  V,
          4      # \        # r   rL   rM   s   &&  r   Ú__sub__ÚGaussianElement.__sub__S   rP   r   c                	ó    € V P                  V4      w  r#Ve3   V P                  W P                  ,
          W0P                  ,
          4      # \        # r   rL   rM   s   &&  r   Ú__rsub__ÚGaussianElement.__rsub__Z   s:   € Ø�|‰|˜EÓ"‰ˆØŠ=Ø—8‘8˜A§¡�J¨¯F©F­
Ó3Ð3ä!Ð!r   c                	ó  € V P                  V4      w  r#Vee   V P                  V P                  V,          V P                  V,          ,
          V P                  V,          V P                  V,          ,           4      # \        # r   rL   rM   s   &&  r   Ú__mul__ÚGaussianElement.__mul__a   sX   € Ø�|‰|˜EÓ"‰ˆØŠ=Ø—8‘8˜DŸF™F 1�H t§v¡v¨a¥xÕ/°·±¸µ¸D¿F¹FÀ1½HÕ1DÓEÐEä!Ð!r   c                	ó6  € V^ 8X  d   V P                  ^^ 4      # V^ 8  d   ^V ,          V) rV^8X  d   V # T pV^,          '       d   T MV P                  P                  pV^,          pV'       d+   W",          pV^,          '       d	   W2,          pV^,          pK2  V# ©é    )r   r   Úone)r$   ÚexpÚpow2Úprods   &&  r   Ú__pow__ÚGaussianElement.__pow__j   sˆ   € Ø�!Œ8Ø—8‘8˜A˜q“>Ð!Ø�Œ7Ø˜$�  �#Ø�!Œ8ØˆKØˆØ˜Q—w”w‰t D§L¡L×$4Ñ$4ˆØ��	ˆßØ�LˆDØ�Q�wŒwØ•�Ø�A�IŠCØˆr   c                	óf   € \        V P                  4      ;'       g    \        V P                  4      # r   )Úboolr   r   r#   s   &r   Ú__bool__ÚGaussianElement.__bool__{   s    € Ü�D—F‘F‹|×+Ð+œt D§F¡F›|Ð+r   c                óÄ   € V P                   ^ 8”  d   V P                  ^ 8”  d   ^ # ^# V P                   ^ 8  d   V P                  ^ 8  d   ^# ^# V P                  ^ 8¼  d   ^ # ^# )z9Return quadrant index 0-3.

0 is included in quadrant 0.
)r   r   r#   s   &r   ÚquadrantÚGaussianElement.quadrant~   sY   € ð
 �6‰6�AŒ:ØŸ™ œ
�1Ð)¨Ð)Ø�V‰V�aŒZØŸ™ œ
�1Ð)¨Ð)àŸ™ !œ�1Ð*¨Ð*r   c                	óŠ   €  V P                   P                  V4      pVP                  V 4      #   \         d
    \        u # i ; ir   )r   r   Ú
__divmod__r   r-   r.   s   &&r   Ú__rdivmod__ÚGaussianElement.__rdivmod__Š   sE   € ð	*Ø—L‘L×(Ñ(¨Ó/ˆEð ×#Ñ# DÓ)Ð)øô ô 	"Ü!Ò!ð	"ús   ‚. ®AÁAc                	ó~   €  \         P                  V4      pVP                  V 4      #   \         d
    \        u # i ; ir   )ÚQQ_Ir   Ú__truediv__r   r-   r.   s   &&r   Ú__rtruediv__ÚGaussianElement.__rtruediv__’   s?   € ð	+Ü—L‘L Ó'ˆEð ×$Ñ$ TÓ*Ð*øô ô 	"Ü!Ò!ð	"ús   ‚( ¨<»<c                	óN   € V P                  V4      pV\        J d   V# V^ ,          # r[   ©rk   r-   ©r$   r/   Úqrs   && r   Ú__floordiv__ÚGaussianElement.__floordiv__š   ó&   € Ø�_‰_˜UÓ#ˆØœ>Ó)ˆrÐ4¨r°!­uÐ4r   c                	óN   € V P                  V4      pV\        J d   V# V^ ,          # r[   ©rl   r-   ru   s   && r   Ú__rfloordiv__ÚGaussianElement.__rfloordiv__ž   ó(   € Ø×Ñ˜eÓ$ˆØœ>Ó)ˆrÐ4¨r°!­uÐ4r   c                	óN   € V P                  V4      pV\        J d   V# V^,          # ©é   rt   ru   s   && r   Ú__mod__ÚGaussianElement.__mod__¢   ry   r   c                	óN   € V P                  V4      pV\        J d   V# V^,          # r€   r{   ru   s   && r   Ú__rmod__ÚGaussianElement.__rmod__¦   r~   r   r6   )r   r   r[   )$Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__Ú	__slots__r   Úclassmethodr   r%   r)   r0   r3   r7   r;   rA   rF   rI   rN   Ú__radd__rR   rU   rX   Ú__rmul__ra   re   rh   rl   rq   rw   r|   r‚   r…   Ú__static_attributes__Ú__classcell__)r    s   @r   r   r      s¿   ø‡ Ù;Ø
ƒLØƒOà€Iô)ð ôó ðòò&ò"ò5ò
ò*òAò0ð ñ ó ð ò"ð €Hò"ò"ò"ð €Hòò",ò
+ò*ò+ò5ò5ò5÷5ð 5r   r   c                  ó*   € ] tR t^«tRt]tR tR tRt	R# )Ú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                ó:   € \         P                  V 4      V,          # )úReturn a Gaussian rational.)ro   r   r.   s   &&r   rp   ÚGaussianInteger.__truediv__·   s   € ä�|‰|˜DÓ! %Õ'Ð'r   c                	ó  € V'       g   \        R P                  V 4      4      hV P                  V4      w  r#Vf   \        # V P                  V,          V P
                  V,          ,           V P                  ) V,          V P
                  V,          ,           rTW",          W3,          ,           p^V,          V,           ^V,          ,          p^V,          V,           ^V,          ,          p\        Wx4      p	W�W‘,          ,
          3# )zdivmod({}, 0))ÚZeroDivisionErrorÚformatrI   r-   r   r   r”   )
r$   r/   r   r   ÚaÚbÚcÚqxÚqyÚqs
   &&        r   rk   ÚGaussianInteger.__divmod__»   sÁ   € ßÜ# O×$:Ñ$:¸4Ó$@ÓAÐAØ�|‰|˜EÓ"‰ˆØŠ9Ü!Ð!ð �v‰v�a�x˜$Ÿ&™& �(Õ" T§V¡V G¨A¥I°·±°qµÕ$8ˆ1Ø�C�!•#�Iˆð ��c�A�g˜1˜Q�3ÕˆØ��c�A�g˜1˜Q�3Õˆä˜BÓ#ˆð ˜�•.Ð Ð r   r6   N)
r‡   rˆ   r‰   rŠ   r‹   r   r   rp   rk   r‘   r6   r   r   r”   r”   «   s   † ñð €Dò(ö!r   r”   c                  ó*   € ] tR t^ÓtRt]tR tR tRt	R# )ÚGaussianRationalzÒ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                ó„  € V'       g   \        RP                  V 4      4      hV P                  V4      w  r#Vf   \        # W",          W3,          ,           p\	        V P
                  V,          V P                  V,          ,           V,          V P
                  ) V,          V P                  V,          ,           V,          4      # )r–   z{} / 0)r™   rš   rI   r-   r£   r   r   )r$   r/   r   r   r�   s   &&   r   rp   ÚGaussianRational.__truediv__ß   s‰   € çÜ# H§O¡O°DÓ$9Ó:Ð:Ø�|‰|˜EÓ"‰ˆØŠ9Ü!Ð!Ø�C�!•#�Iˆä §¡¨¥¨D¯F©F°1­HÕ!4°aÕ 7Ø"&§&¡& ¨¥¨T¯V©V°A­XÕ!5°qÕ 8ó:ð 	:r   c                	óÜ   €  V P                   P                  V4      pT'       g   \	        R P                  T 4      4      hY,          \        P                  3#   \         d
    \        u # i ; i)z{} % 0)r   r   r   r-   r™   rš   ro   Úzeror.   s   &&r   rk   ÚGaussianRational.__divmod__ë   s\   € ð	"Ø—L‘L×(Ñ(¨Ó/ˆE÷ Ü# H§O¡O°DÓ$9Ó:Ð:à•:œtŸy™yÐ(Ð(øô ô 	"Ü!Ò!ð	"ús   ‚A ÁA+Á*A+r6   N)
r‡   rˆ   r‰   rŠ   r‹   r   r   rp   rk   r‘   r6   r   r   r£   r£   Ó   s   † ñð €Dò
:ö)r   r£   c                  ó�   € ] tR t^öt$ RtR]R&   RtRtRtRt	R t
R tR tR tR	 tR
 tR tR tR tR tR tR tR tR tR tRtR# )ÚGaussianDomainz Base class for Gaussian domains.r	   ÚdomTc                ó–   € V P                   P                  pV! VP                  4      \        V! VP                  4      ,          ,           # )z!Convert ``a`` to a SymPy object. )r«   rE   r   r   r   )r$   r›   r   s   && r   rE   ÚGaussianDomain.to_sympy   s0   € à�x‰x× Ñ ˆÙ�A—C‘C‹yœ1™T !§#¡#›Y�;Õ&Ð&r   c                óT  € VP                  4       w  r#V P                  P                  V4      pV'       g   V P                  V^ 4      # VP	                  4       w  r#V P                  P                  V4      pV\
        J d   V P                  WE4      # \        RP                  V4      4      h)z)Convert a SymPy object to ``self.dtype``.z{} is not Gaussian)Úas_coeff_Addr«   Ú
from_sympyr   Úas_coeff_Mulr   r   rš   )r$   r›   Úrrœ   r   r   s   &&    r   r°   ÚGaussianDomain.from_sympy  s…   € à�~‰~Ó‰ˆØ�H‰H×Ñ Ó"ˆßØ—8‘8˜A˜q“>Ð!Ø�~‰~Ó‰ˆØ�H‰H×Ñ Ó"ˆØ”‹6Ø—8‘8˜A“>Ð!ä Ð!5×!<Ñ!<¸QÓ!?Ó@Ð@r   c                ó"   € V P                   ! V!  # )z$Inject generators into this domain. )Ú	poly_ring)r$   Úgenss   &*r   ÚinjectÚGaussianDomain.inject  s   € à�~Š~˜tÑ$Ð$r   c                	óJ   € V P                   VP                  4       ) ,          pV# r   )Úunitsrh   )r$   ÚdÚunits   && r   Úcanonical_unitÚGaussianDomain.canonical_unit  s   € Ø�z‰z˜1Ÿ:™:›<˜-Õ(ˆØˆr   c                ó   € R# ©z/Returns ``False`` for any ``GaussianElement``. Fr6   ©r$   Úelements   &&r   Úis_negativeÚGaussianDomain.is_negative  ó   € ár   c                ó   € R# rÀ   r6   rÁ   s   &&r   Úis_positiveÚGaussianDomain.is_positive  rÅ   r   c                ó   € R# rÀ   r6   rÁ   s   &&r   Úis_nonnegativeÚGaussianDomain.is_nonnegative"  rÅ   r   c                ó   € R# rÀ   r6   rÁ   s   &&r   Úis_nonpositiveÚGaussianDomain.is_nonpositive&  rÅ   r   c                ó   € V ! V4      # )z%Convert a GMPY mpz to ``self.dtype``.r6   ©ÚK1r›   ÚK0s   &&&r   Úfrom_ZZ_gmpyÚGaussianDomain.from_ZZ_gmpy*  ó   € á�!‹uˆr   c                ó   € V ! V4      # ©z.Convert a ZZ_python element to ``self.dtype``.r6   rÐ   s   &&&r   Úfrom_ZZÚGaussianDomain.from_ZZ.  rÕ   r   c                ó   € V ! V4      # r×   r6   rÐ   s   &&&r   Úfrom_ZZ_pythonÚGaussianDomain.from_ZZ_python2  rÕ   r   c                ó   € V ! V4      # ©z%Convert a GMPY mpq to ``self.dtype``.r6   rÐ   s   &&&r   Úfrom_QQÚGaussianDomain.from_QQ6  rÕ   r   c                ó   € V ! V4      # rÞ   r6   rÐ   s   &&&r   Úfrom_QQ_gmpyÚGaussianDomain.from_QQ_gmpy:  rÕ   r   c                ó   € V ! V4      # )z.Convert a QQ_python element to ``self.dtype``.r6   rÐ   s   &&&r   Úfrom_QQ_pythonÚGaussianDomain.from_QQ_python>  rÕ   r   c                ó’   € VP                   P                  ^ ,          \        8X  d!   V P                  VP	                  V4      4      # R# )z9Convert an element from ZZ<I> or QQ<I> to ``self.dtype``.N)ÚextÚargsr   r°   rE   rÐ   s   &&&r   Úfrom_AlgebraicFieldÚ"GaussianDomain.from_AlgebraicFieldB  s2   € à�6‰6�;‰;�q�>œQÔØ—=‘= §¡¨Q£Ó0Ð0ñ r   r6   N)r‡   rˆ   r‰   rŠ   r‹   rŒ   Úis_NumericalÚis_ExactÚhas_assoc_RingÚhas_assoc_FieldrE   r°   r·   r½   rÃ   rÇ   rÊ   rÍ   rÓ   rØ   rÛ   rß   râ   rå   rê   r‘   r6   r   r   rª   rª   ö   sj   ‡ Ù*Ø	ƒKà€LØ€Hà€NØ€Oò'ò
Aò%òòòòòòòòòòòö1r   rª   c                  ól  € ] tR tRtRt]t]! ]P                  ]P                  ]P                  .]4      t
]t]! ]! ^ 4      ]! ^ 4      4      t	]! ]! ^4      ]! ^ 4      4      t]! ]! ^ 4      ]! ^4      4      t]]]) ]) 3tRtRtRtRtR tR tR t]R 4       tR	 tR
 tR tR tR tR tR tR tR t Rt!R# )ÚGaussianIntegerRingiH  a?	  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

ÚZZ_ITc                ó   € R# )zFor constructing ZZ_I.Nr6   r#   s   &r   Ú__init__ÚGaussianIntegerRing.__init__º  ó   ‚ r   c                ó>   € \        V\        4      '       d   R# \        # ©z0Returns ``True`` if two domains are equivalent. T)r,   rñ   r-   r.   s   &&r   r0   ÚGaussianIntegerRing.__eq__½  s   € ä�eÔ0×1Ò1Ùä!Ð!r   c                ó   € \        R4      # )úCompute hash code of ``self``. rò   ©r(   r#   s   &r   r)   ÚGaussianIntegerRing.__hash__Ä  ó   € ä�F‹|Ðr   c                	ó   € R # ©Tr6   r#   s   &r   Úhas_CharacteristicZeroÚ*GaussianIntegerRing.has_CharacteristicZeroÈ  ó   € ár   c                	ó   € ^ # r[   r6   r#   s   &r   ÚcharacteristicÚ"GaussianIntegerRing.characteristicÌ  ó   € Ùr   c                ó   € V # ©z)Returns a ring associated with ``self``. r6   r#   s   &r   Úget_ringÚGaussianIntegerRing.get_ringÏ  ó   € àˆr   c                ó   € \         # ©z*Returns a field associated with ``self``. )ro   r#   s   &r   Ú	get_fieldÚGaussianIntegerRing.get_fieldÓ  ó   € äˆr   c                óÄ   a€ V P                  V4      oVS,          p\        ;QJ d    . V3R lV 4       F  NK  	  5M! V3R lV 4       4      pV'       d   V3V,           # T# )zpReturn first quadrant element associated with ``d``.

Also multiply the other arguments by the same power of i.
c              3  ó4   <"  € T F  qS,          x € K  	  R # 5ir   r6   )Ú.0r›   r¼   s   & €r   Ú	<genexpr>Ú0GaussianIntegerRing.normalize.<locals>.<genexpr>Þ  s   øé € Ð*¡T �t—V’V£Tùs   ƒ)r½   Útuple)r$   r»   ré   r¼   s   &&*@r   Ú	normalizeÚGaussianIntegerRing.normalize×  sO   ø€ ð
 ×"Ñ" 1Ó%ˆØ	ˆT�	ˆßŒuÔ*¡TÓ*�u‰uÔ*¡TÓ*Ó*ˆß"�ˆt�d�{Ð)¨Ð)r   c                óJ   € V'       d   Y!V,          r!K  V P                  V4      # )z-Greatest common divisor of a and b over ZZ_I.)r  ©r$   r›   rœ   s   &&&r   ÚgcdÚGaussianIntegerRing.gcdá  s   € çØ˜!•eŠqØ�~‰~˜aÓ Ð r   c                ó  € V P                   pV P                  pV P                  pV P                   pV'       d8   W,          pY!Wr,          ,
          r!YCWt,          ,
          rCYeWv,          ,
          reK?  V P                  WV4      w  rpW5V3# )z6Return x, y, g such that x * a + y * b = g = gcd(a, b))r]   r§   r  )r$   r›   rœ   Úx_aÚx_bÚy_aÚy_br    s   &&&     r   ÚgcdexÚGaussianIntegerRing.gcdexç  so   € à�h‰hˆØ�i‰iˆØ�i‰iˆØ�h‰hˆßØ•ˆAØ˜!�%•iˆqØ !¥'�M�Ø !¥'�M’à—n‘n Q¨SÓ1‰ˆ�Ø˜ˆ{Ðr   c                ó>   € W,          V P                  W4      ,          # )z+Least common multiple of a and b over ZZ_I.)r  r  s   &&&r   ÚlcmÚGaussianIntegerRing.lcmö  s   € à•˜$Ÿ(™( 1›.Õ(Ð(r   c                ó   € V# )zConvert a ZZ_I element to ZZ_I.r6   rÐ   s   &&&r   Úfrom_GaussianIntegerRingÚ,GaussianIntegerRing.from_GaussianIntegerRingú  ó   € àˆr   c                óž   € V P                  \        P                  ! VP                  4      \        P                  ! VP                  4      4      # )zConvert a QQ_I element to ZZ_I.)r   r   r   r   r   rÐ   s   &&&r   Úfrom_GaussianRationalFieldÚ.GaussianIntegerRing.from_GaussianRationalFieldþ  s+   € à�v‰v”b—j’j §¡“o¤r§z¢z°!·#±#£Ó7Ð7r   r6   N)"r‡   rˆ   r‰   rŠ   r‹   r   r«   r   r]   r§   Úmodr”   ÚdtypeÚ	imag_unitrº   r@   Úis_GaussianRingÚis_ZZ_IÚis_PIDrô   r0   r)   Úpropertyr  r  r
  r  r  r  r#  r&  r)  r-  r‘   r6   r   r   rñ   rñ   H  sæ   † ñbðF €CÙ
ˆr�v‰v�r—w‘w §¡Ð'¨Ó
,€CØ€EÙ‘�A“™˜1›Ó€DÙ
‘�1“‘r˜!“uÓ
€CÙ‘b˜“e™R ›UÓ#€IØ�)˜c˜T I :Ð.€Eà
€Cà€OØ€GØ€Fò%ò"òð ñó ðòòòò*ò!òò)òö8r   rñ   c                  óh  € ] tR tRtRt]t]! ]P                  ]P                  ]P                  .]4      t
]t]! ]! ^ 4      ]! ^ 4      4      t	]! ]! ^4      ]! ^ 4      4      t]! ]! ^ 4      ]! ^4      4      t]]]) ]) 3tRtRtRtR tR tR t]R 4       tR	 tR
 tR tR tR tR tR tR tR tRt R# )ÚGaussianRationalFieldi  a  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
ro   Tc                ó   € R# )zFor constructing QQ_I.Nr6   r#   s   &r   rô   ÚGaussianRationalField.__init__‡  rö   r   c                ó>   € \        V\        4      '       d   R# \        # rø   )r,   r7  r-   r.   s   &&r   r0   ÚGaussianRationalField.__eq__Š  s   € ä�eÔ2×3Ò3Ùä!Ð!r   c                ó   € \        R4      # )rû   ro   rü   r#   s   &r   r)   ÚGaussianRationalField.__hash__‘  rþ   r   c                	ó   € R # r   r6   r#   s   &r   r  Ú,GaussianRationalField.has_CharacteristicZero•  r  r   c                	ó   € ^ # r[   r6   r#   s   &r   r  Ú$GaussianRationalField.characteristic™  r  r   c                ó   € \         # r	  )rò   r#   s   &r   r
  ÚGaussianRationalField.get_ringœ  r  r   c                ó   € V # r  r6   r#   s   &r   r  ÚGaussianRationalField.get_field   r  r   c                ó6   € \        V P                  \        4      # )z0Get equivalent domain as an ``AlgebraicField``. )r   r«   r   r#   s   &r   Úas_AlgebraicFieldÚ'GaussianRationalField.as_AlgebraicField¤  s   € ä˜dŸh™h¬Ó*Ð*r   c                ón   € V P                  4       pVP                  WP                  V4      ,          4      # )zGet the numerator of ``a``.)r
  r   Údenom)r$   r›   rò   s   && r   ÚnumerÚGaussianRationalField.numer¨  s'   € à�}‰}‹ˆØ�|‰|˜A§
¡
¨1£Õ-Ó.Ð.r   c                ó   € V P                   P                  4       pV P                   pV P                  4       pVP                  ! VP                  ! VP                  4      VP                  ! VP
                  4      4      pV! WRP                  4      # )zGet the denominator of ``a``.)r«   r
  r&  rJ  r   r   r§   )r$   r›   r   r   rò   Údenom_ZZs   &&    r   rJ  ÚGaussianRationalField.denom­  s_   € à�X‰X×ÑÓ ˆØ�X‰XˆØ�}‰}‹ˆØ—6’6˜"Ÿ(š( 1§3¡3›-¨¯ª°!·#±#«Ó7ˆÙ�HŸg™gÓ&Ð&r   c                óN   € V P                  VP                  VP                  4      # )zConvert a ZZ_I element to QQ_I.r:   rÐ   s   &&&r   r)  Ú.GaussianRationalField.from_GaussianIntegerRingµ  s   € à�v‰v�a—c‘c˜1Ÿ3™3ÓÐr   c                ó   € V# )zConvert a QQ_I element to QQ_I.r6   rÐ   s   &&&r   r-  Ú0GaussianRationalField.from_GaussianRationalField¹  r+  r   c                óž   € V P                  \        P                  ! VP                  4      \        P                  ! VP                  4      4      # )z'Convert a ComplexField element to QQ_I.)r   r   r   ÚrealÚimagrÐ   s   &&&r   Úfrom_ComplexFieldÚ'GaussianRationalField.from_ComplexField½  s-   € à�v‰v”b—j’j §¡Ó(¬"¯*ª*°Q·V±VÓ*<Ó=Ð=r   r6   N)!r‡   rˆ   r‰   rŠ   r‹   r   r«   r   r]   r§   r/  r£   r0  r1  rº   r@   Úis_GaussianFieldÚis_QQ_Irô   r0   r)   r5  r  r  r
  r  rG  rK  rJ  r)  r-  rW  r‘   r6   r   r   r7  r7    sâ   † ñsðh €CÙ
ˆr�v‰v�r—w‘w §¡Ð'¨Ó
,€CØ€EÙ‘�A“™˜1›Ó€DÙ
‘�1“‘r˜!“uÓ
€CÙ‘b˜“e™R ›UÓ#€IØ�)˜c˜T I :Ð.€Eà
€CàÐØ€Gò%ò"òð ñó ðòòòò+ò/ò
'ò òö>r   r7  N) r‹   Ú
__future__r   Úsympy.core.numbersr   Úsympy.polys.polyclassesr   Úsympy.polys.polyerrorsr   Úsympy.polys.domains.integerringr   Ú!sympy.polys.domains.rationalfieldr   Ú"sympy.polys.domains.algebraicfieldr   Úsympy.polys.domains.domainr	   Ú!sympy.polys.domains.domainelementr
   Úsympy.polys.domains.fieldr   Úsympy.polys.domains.ringr   r   r”   r£   rª   rñ   rò   r   r7  ro   r6   r   r   Ú<module>rf     s¦   ðÙ å "Ý  Ý 'Ý 1Ý .Ý 0Ý =Ý -Ý ;Ý +Ý )ôX5�mô X5ôv%!�oô %!ôP )�ô  )÷FO1ñ O1ôdx8˜.¨$ô x8ñt "5Ó!6Ð 6€€Ôôz>˜N¨Eô z>ñz #8Ó"9Ð 9€ÐÖr   