Ë
    7^(h’  ã                   ó|   — d Z ddlm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 e G d„ de«      «       Zy	)
z4Implementation of :class:`PythonIntegerRing` class. é    )Ú
int_valued)ÚPythonIntegerÚSymPyIntegerÚsqrtÚ	factorialÚpython_gcdexÚ
python_gcdÚ
python_lcm)ÚIntegerRing)ÚCoercionFailed)Úpublicc                   ó˜   — e Zd ZdZeZ ed«      Z e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)ÚPythonIntegerRingzÂInteger ring based on Python's ``int`` type.

    This will be used as :ref:`ZZ` if ``gmpy`` and ``gmpy2`` are not
    installed. Elements are instances of the standard Python ``int`` type.
    r   é   Ú	ZZ_pythonc                  ó   — y)z$Allow instantiation of this domain. N© )Úselfs    úc/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/polys/domains/pythonintegerring.pyÚ__init__zPythonIntegerRing.__init__   s   � ó    c                 ó   — t        |«      S )z!Convert ``a`` to a SymPy object. )r   ©r   Úas     r   Úto_sympyzPythonIntegerRing.to_sympy   s   € ä˜A‹Ð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   Úintr   r   s     r   Ú
from_sympyzPythonIntegerRing.from_sympy!   s?   € à�<Š<Ü  §¡Ó%Ð%Ü˜Œ]Ü ¤ Q£Ó(Ð(ä Ð!>ÀÑ!BÓCÐCr   c                 ó$   — |j                  |«      S )z5Convert ``ModularInteger(int)`` to Python's ``int``. )Úto_int©ÚK1r   ÚK0s      r   Úfrom_FF_pythonz PythonIntegerRing.from_FF_python*   s   € à�y‰y˜‹|Ðr   c                 ó   — |S )z.Convert Python's ``int`` to Python's ``int``. r   r#   s      r   Úfrom_ZZ_pythonz PythonIntegerRing.from_ZZ_python.   s   € àˆr   c                 ó:   — |j                   dk(  r|j                  S y©z3Convert Python's ``Fraction`` to Python's ``int``. r   N©ÚdenominatorÚ	numeratorr#   s      r   Úfrom_QQzPythonIntegerRing.from_QQ2   ó   € à�=‰=˜AÒØ—;‘;Ðð r   c                 ó:   — |j                   dk(  r|j                  S yr*   r+   r#   s      r   Úfrom_QQ_pythonz PythonIntegerRing.from_QQ_python7   r/   r   c                 ó6   — t        |j                  |«      «      S )z5Convert ``ModularInteger(mpz)`` to Python's ``int``. )r   r"   r#   s      r   Úfrom_FF_gmpyzPythonIntegerRing.from_FF_gmpy<   s   € ä˜RŸY™Y q›\Ó*Ð*r   c                 ó   — t        |«      S )z,Convert GMPY's ``mpz`` to Python's ``int``. )r   r#   s      r   Úfrom_ZZ_gmpyzPythonIntegerRing.from_ZZ_gmpy@   s   € ä˜QÓÐr   c                 ó\   — |j                  «       dk(  rt        |j                  «       «      S y)z,Convert GMPY's ``mpq`` to Python's ``int``. r   N)Údenomr   Únumerr#   s      r   Úfrom_QQ_gmpyzPythonIntegerRing.from_QQ_gmpyD   s%   € à�7‰7‹9˜Š>Ü  §¡£Ó+Ð+ð r   c                 óL   — |j                  |«      \  }}|dk(  rt        |«      S y)z.Convert mpmath's ``mpf`` to Python's ``int``. r   N)Úto_rationalr   )r$   r   r%   r   Úqs        r   Úfrom_RealFieldz PythonIntegerRing.from_RealFieldI   s+   € à�~‰~˜aÓ ‰ˆˆ1à�Š6Ü  Ó#Ð#ð r   c                 ó   — t        ||«      S )z)Compute extended GCD of ``a`` and ``b``. )r   ©r   r   Úbs      r   ÚgcdexzPythonIntegerRing.gcdexP   s   € ä˜A˜qÓ!Ð!r   c                 ó   — t        ||«      S )z Compute GCD of ``a`` and ``b``. )r	   r?   s      r   ÚgcdzPythonIntegerRing.gcdT   ó   € ä˜!˜QÓÐr   c                 ó   — t        ||«      S )z Compute LCM of ``a`` and ``b``. )r
   r?   s      r   ÚlcmzPythonIntegerRing.lcmX   rD   r   c                 ó   — t        |«      S )zCompute square root of ``a``. )Úpython_sqrtr   s     r   r   zPythonIntegerRing.sqrt\   s   € ä˜1‹~Ðr   c                 ó   — t        |«      S )zCompute factorial of ``a``. )Úpython_factorialr   s     r   r   zPythonIntegerRing.factorial`   s   € ä Ó"Ð"r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚdtypeÚzeroÚoneÚaliasr   r   r    r&   r(   r.   r1   r3   r5   r9   r=   rA   rC   rF   r   r   r   r   r   r   r      sv   „ ñð €EÙ�‹8€DÙ
�‹(€CØ€Eò3òòDòòòò
ò
+ò ò,ò
$ò"ò ò òó#r   r   N)rN   Úsympy.core.numbersr   Úsympy.polys.domains.groundtypesr   r   r   rH   r   rJ   r   r	   r
   Úsympy.polys.domains.integerringr   Úsympy.polys.polyerrorsr   Úsympy.utilitiesr   r   r   r   r   ú<module>rX      sC   ðÙ :õ *÷÷ ñ õ 8Ý 1Ý "àôT#˜ó T#ó ñT#r   