Ë
    7^(hÝ  ã                   ó|   — d Z ddlmZmZmZmZmZmZm	Z
 ddlmZ ddlmZ ddlmZ ddlmZ e G d„ de«      «       Zy	)
z2Implementation of :class:`GMPYIntegerRing` class. é    )ÚGMPYIntegerÚSymPyIntegerÚ	factorialÚ
gmpy_gcdexÚgmpy_gcdÚgmpy_lcmÚsqrt)Ú
int_valued)ÚIntegerRing)ÚCoercionFailed)Úpublicc                   ó®   — e Zd ZdZeZ ed«      Z ed«      Z ee«      Z	dZ
d„ Zd„ Zd„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚGMPYIntegerRingz³Integer ring based on GMPY's ``mpz`` type.

    This will be the implementation of :ref:`ZZ` if ``gmpy`` or ``gmpy2`` is
    installed. Elements will be of type ``gmpy.mpz``.
    r   é   ÚZZ_gmpyc                  ó   — y)z$Allow instantiation of this domain. N© )Úselfs    úa/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/polys/domains/gmpyintegerring.pyÚ__init__zGMPYIntegerRing.__init__   s   � ó    c                 ó*   — t        t        |«      «      S )z!Convert ``a`` to a SymPy object. )r   Úint©r   Úas     r   Úto_sympyzGMPYIntegerRing.to_sympy   s   € äœC ›FÓ#Ð#r   c                 óž   — |j                   rt        |j                  «      S t        |«      rt        t	        |«      «      S t        d|z  «      ‚)z&Convert SymPy's Integer to ``dtype``. zexpected an integer, got %s)Ú
is_Integerr   Úpr
   r   r   r   s     r   Ú
from_sympyzGMPYIntegerRing.from_sympy#   s?   € à�<Š<Ü˜qŸs™sÓ#Ð#Ü˜Œ]Üœs 1›vÓ&Ð&ä Ð!>ÀÑ!BÓCÐCr   c                 ó$   — |j                  |«      S )z3Convert ``ModularInteger(int)`` to GMPY's ``mpz``. ©Úto_int©ÚK1r   ÚK0s      r   Úfrom_FF_pythonzGMPYIntegerRing.from_FF_python,   ó   € à�y‰y˜‹|Ðr   c                 ó   — t        |«      S )z,Convert Python's ``int`` to GMPY's ``mpz``. )r   r$   s      r   Úfrom_ZZ_pythonzGMPYIntegerRing.from_ZZ_python0   s   € ä˜1‹~Ðr   c                 óL   — |j                   dk(  rt        |j                  «      S y©z1Convert Python's ``Fraction`` to GMPY's ``mpz``. r   N©Údenominatorr   Ú	numeratorr$   s      r   Úfrom_QQzGMPYIntegerRing.from_QQ4   ó"   € à�=‰=˜AÒÜ˜qŸ{™{Ó+Ð+ð r   c                 óL   — |j                   dk(  rt        |j                  «      S yr,   r-   r$   s      r   Úfrom_QQ_pythonzGMPYIntegerRing.from_QQ_python9   r1   r   c                 ó$   — |j                  |«      S )z3Convert ``ModularInteger(mpz)`` to GMPY's ``mpz``. r"   r$   s      r   Úfrom_FF_gmpyzGMPYIntegerRing.from_FF_gmpy>   r(   r   c                 ó   — |S )z*Convert GMPY's ``mpz`` to GMPY's ``mpz``. r   r$   s      r   Úfrom_ZZ_gmpyzGMPYIntegerRing.from_ZZ_gmpyB   s   € àˆr   c                 ó:   — |j                   dk(  r|j                  S y)z(Convert GMPY ``mpq`` to GMPY's ``mpz``. r   N)r.   r/   r$   s      r   Úfrom_QQ_gmpyzGMPYIntegerRing.from_QQ_gmpyF   s   € à�=‰=˜AÒØ—;‘;Ðð r   c                 óL   — |j                  |«      \  }}|dk(  rt        |«      S y)z,Convert mpmath's ``mpf`` to GMPY's ``mpz``. r   N)Úto_rationalr   )r%   r   r&   r   Úqs        r   Úfrom_RealFieldzGMPYIntegerRing.from_RealFieldK   s*   € à�~‰~˜aÓ ‰ˆˆ1à�Š6Ü˜q“>Ð!ð r   c                 ó:   — |j                   dk(  r|j                  S y )Nr   )ÚyÚxr$   s      r   Úfrom_GaussianIntegerRingz(GMPYIntegerRing.from_GaussianIntegerRingR   s   € Ø�3‰3�!Š8Ø—3‘3ˆJð r   c                 ó,   — t        ||«      \  }}}|||fS )z)Compute extended GCD of ``a`` and ``b``. )r   )r   r   ÚbÚhÚsÚts         r   ÚgcdexzGMPYIntegerRing.gcdexV   s   € ä˜Q Ó"‰ˆˆ1ˆaØ�!�Qˆwˆr   c                 ó   — t        ||«      S )z Compute GCD of ``a`` and ``b``. )r   ©r   r   rC   s      r   ÚgcdzGMPYIntegerRing.gcd[   ó   € ä˜˜1‹~Ðr   c                 ó   — t        ||«      S )z Compute LCM of ``a`` and ``b``. )r   rI   s      r   ÚlcmzGMPYIntegerRing.lcm_   rK   r   c                 ó   — t        |«      S )zCompute square root of ``a``. )Ú	gmpy_sqrtr   s     r   r	   zGMPYIntegerRing.sqrtc   s   € ä˜‹|Ðr   c                 ó   — t        |«      S )zCompute factorial of ``a``. )Úgmpy_factorialr   s     r   r   zGMPYIntegerRing.factorialg   s   € ä˜aÓ Ð r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚdtypeÚzeroÚoneÚtypeÚtpÚaliasr   r   r    r'   r*   r0   r3   r5   r7   r9   r=   rA   rG   rJ   rM   r	   r   r   r   r   r   r      s„   „ ñð €EÙ�‹8€DÙ
�‹(€CÙ	ˆc‹€BØ€Eò3ò$òDòòò,ò
,ò
òòò
"òòò
òòó!r   r   N)rU   Úsympy.polys.domains.groundtypesr   r   r   rQ   r   r   r   r	   rO   Úsympy.core.numbersr
   Úsympy.polys.domains.integerringr   Úsympy.polys.polyerrorsr   Úsympy.utilitiesr   r   r   r   r   ú<module>ra      sA   ðÙ 8÷÷ ñ õ
 *Ý 7Ý 1Ý "àôZ!�kó Z!ó ñZ!r   