+
    .åûj  ã                   óÄ   € R t ^ RIHtHt ^ RIHt ^ RIHtHtH	t	H
t
HtHtHtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	It] ! R
 R]]]4      4       t]! 4       tR	# )z.Implementation of :class:`IntegerRing` class. )ÚMPZÚGROUND_TYPES)Ú
int_valued)ÚSymPyIntegerÚ	factorialÚgcdexÚgcdÚlcmÚsqrtÚ	is_squareÚsqrtrem)ÚCharacteristicZero)ÚRing)ÚSimpleDomain)ÚCoercionFailed)ÚpublicNc                   ó(  a € ] tR t^t o RtRtRt]t]! ^ 4      t	]! ^4      t
]! ]
4      tR;ttRtRtRtRtR tR tR tR tR tR	 tR
R/R l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  t-R! t.R"t/V t0R# )#ÚIntegerRinga¨  The domain ``ZZ`` representing the integers `\mathbb{Z}`.

The :py:class:`IntegerRing` class represents the ring of integers as a
:py:class:`~.Domain` in the domain system. :py:class:`IntegerRing` is a
super class of :py:class:`PythonIntegerRing` and
:py:class:`GMPYIntegerRing` one of which will be the implementation for
:ref:`ZZ` depending on whether or not ``gmpy`` or ``gmpy2`` is installed.

See also
========

Domain
ÚZZTc                ó   € R# )z$Allow instantiation of this domain. N© ©Úselfs   &Ú[C:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\sympy\polys\domains\integerring.pyÚ__init__ÚIntegerRing.__init__3   s   ‚ ó    c                ó>   € \        V\        4      '       d   R# \        # )z0Returns ``True`` if two domains are equivalent. T)Ú
isinstancer   ÚNotImplemented)r   Úothers   &&r   Ú__eq__ÚIntegerRing.__eq__6   s   € ä�eœ[×)Ò)Ùä!Ð!r   c                ó   € \        R4      # )z&Compute a hash value for this domain. r   )Úhashr   s   &r   Ú__hash__ÚIntegerRing.__hash__=   s   € ä�D‹zÐr   c                ó*   € \        \        V4      4      # )z!Convert ``a`` to a SymPy object. )r   Úint©r   Úas   &&r   Úto_sympyÚIntegerRing.to_sympyA   s   € äœC ›FÓ#Ð#r   c                ó¾   € VP                   '       d   \        VP                  4      # \        V4      '       d   \        \	        V4      4      # \        RV,          4      h)z&Convert SymPy's Integer to ``dtype``. zexpected an integer, got %s)Ú
is_Integerr   Úpr   r(   r   r)   s   &&r   Ú
from_sympyÚIntegerRing.from_sympyE   s@   € à�<�<ˆ<Ü�q—s‘s“8ˆOÜ˜�]Š]Ü”s˜1“v“;Ðä Ð!>ÀÕ!BÓCÐCr   c                ó   € ^ RI Hp V# )a  Return the associated field of fractions :ref:`QQ`

Returns
=======

:ref:`QQ`:
    The associated field of fractions :ref:`QQ`, a
    :py:class:`~.Domain` representing the rational numbers
    `\mathbb{Q}`.

Examples
========

>>> from sympy import ZZ
>>> ZZ.get_field()
QQ
)ÚQQ)Úsympy.polys.domainsr3   )r   r3   s   & r   Ú	get_fieldÚIntegerRing.get_fieldN   s   € õ$ 	+Øˆ	r   ÚaliasNc               óB   € V P                  4       P                  ! VRV/ # )a…  Returns an algebraic field, i.e. `\mathbb{Q}(\alpha, \ldots)`.

Parameters
==========

*extension : One or more :py:class:`~.Expr`.
    Generators of the extension. These should be expressions that are
    algebraic over `\mathbb{Q}`.

alias : str, :py:class:`~.Symbol`, None, optional (default=None)
    If provided, this will be used as the alias symbol for the
    primitive element of the returned :py:class:`~.AlgebraicField`.

Returns
=======

:py:class:`~.AlgebraicField`
    A :py:class:`~.Domain` representing the algebraic field extension.

Examples
========

>>> from sympy import ZZ, sqrt
>>> ZZ.algebraic_field(sqrt(2))
QQ<sqrt(2)>
r7   )r5   Úalgebraic_field)r   r7   Ú	extensions   &$*r   r9   ÚIntegerRing.algebraic_fieldc   s!   € ð6 �~‰~Ó×/Ò/°ÐHÀ%ÑHÐHr   c                ó~   € VP                   '       d+   V P                  VP                  4       VP                  4      # R# )zSConvert a :py:class:`~.ANP` object to :ref:`ZZ`.

See :py:meth:`~.Domain.convert`.
N)Ú	is_groundÚconvertÚLCÚdom©ÚK1r*   ÚK0s   &&&r   Úfrom_AlgebraicFieldÚIntegerRing.from_AlgebraicField€   s-   € ð
 �;�;ˆ;Ø—:‘:˜aŸd™d›f b§f¡fÓ-Ð-ñ r   c           	     ór   € V P                  \        \        P                  ! \        V4      V4      4      4      # )aŠ  Logarithm of *a* to the base *b*.

Parameters
==========

a: number
b: number

Returns
=======

$\\lfloor\log(a, b)\\rfloor$:
    Floor of the logarithm of *a* to the base *b*

Examples
========

>>> from sympy import ZZ
>>> ZZ.log(ZZ(8), ZZ(2))
3
>>> ZZ.log(ZZ(9), ZZ(2))
3

Notes
=====

This function uses ``math.log`` which is based on ``float`` so it will
fail for large integer arguments.
)Údtyper(   ÚmathÚlog©r   r*   Úbs   &&&r   rI   ÚIntegerRing.logˆ   s'   € ð< �z‰zœ#œdŸhšh¤s¨1£v¨qÓ1Ó2Ó3Ð3r   c                ó6   € \        VP                  V4      4      # ©z3Convert ``ModularInteger(int)`` to GMPY's ``mpz``. ©r   Úto_intrA   s   &&&r   Úfrom_FFÚIntegerRing.from_FF¨   ó   € ä�2—9‘9˜Q“<Ó Ð r   c                ó6   € \        VP                  V4      4      # rN   rO   rA   s   &&&r   Úfrom_FF_pythonÚIntegerRing.from_FF_python¬   rS   r   c                ó   € \        V4      # ©z,Convert Python's ``int`` to GMPY's ``mpz``. ©r   rA   s   &&&r   Úfrom_ZZÚIntegerRing.from_ZZ°   ó   € ä�1‹vˆr   c                ó   € \        V4      # rX   rY   rA   s   &&&r   Úfrom_ZZ_pythonÚIntegerRing.from_ZZ_python´   r\   r   c                óR   € VP                   ^8X  d   \        VP                  4      # R# ©z1Convert Python's ``Fraction`` to GMPY's ``mpz``. N©Údenominatorr   Ú	numeratorrA   s   &&&r   Úfrom_QQÚIntegerRing.from_QQ¸   ó"   € à�=‰=˜AÔÜ�q—{‘{Ó#Ð#ñ r   c                óR   € VP                   ^8X  d   \        VP                  4      # R# ra   rb   rA   s   &&&r   Úfrom_QQ_pythonÚIntegerRing.from_QQ_python½   rg   r   c                ó6   € \        VP                  V4      4      # )z3Convert ``ModularInteger(mpz)`` to GMPY's ``mpz``. rO   rA   s   &&&r   Úfrom_FF_gmpyÚIntegerRing.from_FF_gmpyÂ   rS   r   c                ó   € V# )z*Convert GMPY's ``mpz`` to GMPY's ``mpz``. r   rA   s   &&&r   Úfrom_ZZ_gmpyÚIntegerRing.from_ZZ_gmpyÆ   s   € àˆr   c                ó@   € VP                   ^8X  d   VP                  # R# )z(Convert GMPY ``mpq`` to GMPY's ``mpz``. N)rc   rd   rA   s   &&&r   Úfrom_QQ_gmpyÚIntegerRing.from_QQ_gmpyÊ   s   € à�=‰=˜AÔØ—;‘;Ðñ r   c                ób   € VP                  V4      w  r4V^8X  d   \        \        V4      4      # R# )z,Convert mpmath's ``mpf`` to GMPY's ``mpz``. N)Úto_rationalr   r(   )rB   r*   rC   r/   Úqs   &&&  r   Úfrom_RealFieldÚIntegerRing.from_RealFieldÏ   s.   € à�~‰~˜aÓ ‰ˆà�Œ6ô ”s˜1“v“;Ðñ	 r   c                ó@   € VP                   ^ 8X  d   VP                  # R# )é    N)ÚyÚxrA   s   &&&r   Úfrom_GaussianIntegerRingÚ$IntegerRing.from_GaussianIntegerRingÙ   s   € Ø�3‰3�!Œ8Ø—3‘3ˆJñ r   c                óL   € VP                   '       d   V P                  V4      # R# )z*Convert ``Expression`` to GMPY's ``mpz``. N)r.   r0   rA   s   &&&r   Úfrom_EXÚIntegerRing.from_EXÝ   s   € à�<�<ˆ<Ø—=‘= Ó#Ð#ñ r   c                óD   € \        W4      w  r4p\        R8X  d   WEV3# W4V3# )z)Compute extended GCD of ``a`` and ``b``. Úgmpy)r   r   )r   r*   rK   ÚhÚsÚts   &&&   r   r   ÚIntegerRing.gcdexâ   s)   € ä˜“+‰ˆˆaä˜6Ô!Ø˜�7ˆNà˜�7ˆNr   c                ó   € \        W4      # )z Compute GCD of ``a`` and ``b``. )r   rJ   s   &&&r   r   ÚIntegerRing.gcdë   ó   € ä�1‹yÐr   c                ó   € \        W4      # )z Compute LCM of ``a`` and ``b``. )r	   rJ   s   &&&r   r	   ÚIntegerRing.lcmï   rŠ   r   c                ó   € \        V4      # )zCompute square root of ``a``. )r
   r)   s   &&r   r
   ÚIntegerRing.sqrtó   s   € ä�A‹wˆr   c                ó   € \        V4      # )z�Return ``True`` if ``a`` is a square.

Explanation
===========
An integer is a square if and only if there exists an integer
``b`` such that ``b * b == a``.
)r   r)   s   &&r   r   ÚIntegerRing.is_square÷   s   € ô ˜‹|Ðr   c                óD   € V^ 8  d   R# \        V4      w  r#V^ 8w  d   R# V# )zUNon-negative square root of ``a`` if ``a`` is a square.

See also
========
is_square
N)r   )r   r*   ÚrootÚrems   &&  r   ÚexsqrtÚIntegerRing.exsqrt  s(   € ð ˆqŒ5ÙÜ˜A“J‰	ˆØ�!Œ8ÙØˆr   c                ó   € \        V4      # )zCompute factorial of ``a``. )r   r)   s   &&r   r   ÚIntegerRing.factorial  s   € ä˜‹|Ðr   r   )1Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úrepr7   r   rG   ÚzeroÚoneÚtypeÚtpÚis_IntegerRingÚis_ZZÚis_NumericalÚis_PIDÚhas_assoc_RingÚhas_assoc_Fieldr   r!   r%   r+   r0   r5   r9   rD   rI   rQ   rU   rZ   r^   re   ri   rl   ro   rr   rw   r}   r€   r   r   r	   r
   r   r”   r   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r   r      sò   ø‡ € ñð €CØ€EØ€EÙ�‹8€DÙ
�‹(€CÙ	ˆc‹€Bð "Ð!€N�UØ€LØ€Fà€NØ€Oò3ò"òò$òDòð*I°ô Iò:.ò4ò@!ò!òòò$ò
$ò
!òòò
òò$ò
òòòòò÷ð r   r   )rœ   Úsympy.external.gmpyr   r   Úsympy.core.numbersr   Úsympy.polys.domains.groundtypesr   r   r   r   r	   r
   r   r   Ú&sympy.polys.domains.characteristiczeror   Úsympy.polys.domains.ringr   Ú sympy.polys.domains.simpledomainr   Úsympy.polys.polyerrorsr   Úsympy.utilitiesr   rH   r   r   r   r   r   Ú<module>r³      s]   ðÙ 4ç 1å )÷÷ ó õ FÝ )Ý 9Ý 1Ý "ã àô|�$Ð*¨Ló |ó ð|ñ~ ƒ]‚r   