§
    OŠtj’  ã                   óŠ   — 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d	S )
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dS )Ú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                 ó   — dS )z$Allow instantiation of this domain. N© )Úselfs    úc/var/www/html/CA-Chatbot/venv/lib/python3.11/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!   sT   € àŒ<ð 	DÝ  ¤Ñ%Ô%Ð%Ý˜‰]Œ]ð 	DÝ ¥ Q¡¤Ñ(Ô(Ð(å Ð!>ÀÑ!BÑCÔCÐCr   c                 ó,   — |                      |¦  «        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 dS ©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 dS r*   r+   r#   s      r   Úfrom_QQ_pythonz PythonIntegerRing.from_QQ_python7   r/   r   c                 óF   — t          |                     |¦  «        ¦  «        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                 óx   — |                      ¦   «         dk    r!t          |                     ¦   «         ¦  «        S dS )z,Convert GMPY's ``mpq`` to Python's ``int``. r   N)Údenomr   Únumerr#   s      r   Úfrom_QQ_gmpyzPythonIntegerRing.from_QQ_gmpyD   s0   € à�7Š7‰9Œ9˜Š>ˆ>Ý  §¢¡¤Ñ+Ô+Ð+ð ˆ>r   c                 ó`   — |                      |¦  «        \  }}|dk    rt          |¦  «        S dS )z.Convert mpmath's ``mpf`` to Python's ``int``. r   N)Úto_rationalr   )r$   r   r%   r   Úqs        r   Úfrom_RealFieldz PythonIntegerRing.from_RealFieldI   s5   € à�~Š~˜aÑ Ô ‰ˆˆ1à�Š6ˆ6Ý  Ñ#Ô#Ð#ð ˆ6r   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      s7  € € € € € ðð ð €EØˆ5�‰8Œ8€DØ
ˆ%�‰(Œ(€CØ€Eð3ð 3ð 3ðð ð ðDð Dð 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      sù   ðØ :Ð :ð *Ð )Ð )Ð )Ð )Ð )ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð 8Ð 7Ð 7Ð 7Ð 7Ð 7Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø "Ð "Ð "Ð "Ð "Ð "àðT#ð T#ð T#ð T#ð T#˜ñ T#ô T#ñ „ðT#ð T#ð T#r   