o
    jg’  ã                   @   sp   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„ 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                   @   s¨   e Zd ZdZeZedƒZedƒZdZdd„ Z	dd„ Z
d	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#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                 C   s   dS )z$Allow instantiation of this domain. N© )Úselfr   r   ú]/var/www/html/zoom/venv/lib/python3.10/site-packages/sympy/polys/domains/pythonintegerring.pyÚ__init__   s    zPythonIntegerRing.__init__c                 C   ó   t |ƒS )z!Convert ``a`` to a SymPy object. )r   ©r   Úar   r   r   Úto_sympy   ó   zPythonIntegerRing.to_sympyc                 C   s0   |j rt|jƒS t|ƒrtt|ƒƒS td| ƒ‚)z&Convert SymPy's Integer to ``dtype``. zexpected an integer, got %s)Ú
is_Integerr   Úpr   Úintr   r   r   r   r   Ú
from_sympy!   s
   
zPythonIntegerRing.from_sympyc                 C   s
   |  |¡S )z5Convert ``ModularInteger(int)`` to Python's ``int``. )Úto_int©ÚK1r   ÚK0r   r   r   Úfrom_FF_python*   ó   
z PythonIntegerRing.from_FF_pythonc                 C   s   |S )z.Convert Python's ``int`` to Python's ``int``. r   r   r   r   r   Úfrom_ZZ_python.   s   z PythonIntegerRing.from_ZZ_pythonc                 C   ó   |j dkr|jS dS ©z3Convert Python's ``Fraction`` to Python's ``int``. r   N©ÚdenominatorÚ	numeratorr   r   r   r   Úfrom_QQ2   ó   
ÿzPythonIntegerRing.from_QQc                 C   r$   r%   r&   r   r   r   r   Úfrom_QQ_python7   r*   z PythonIntegerRing.from_QQ_pythonc                 C   s   t | |¡ƒS )z5Convert ``ModularInteger(mpz)`` to Python's ``int``. )r   r   r   r   r   r   Úfrom_FF_gmpy<   s   zPythonIntegerRing.from_FF_gmpyc                 C   r   )z,Convert GMPY's ``mpz`` to Python's ``int``. )r   r   r   r   r   Úfrom_ZZ_gmpy@   r   zPythonIntegerRing.from_ZZ_gmpyc                 C   s   |  ¡ dkrt| ¡ ƒS dS )z,Convert GMPY's ``mpq`` to Python's ``int``. r   N)Údenomr   Únumerr   r   r   r   Úfrom_QQ_gmpyD   s   ÿzPythonIntegerRing.from_QQ_gmpyc                 C   s"   |  |¡\}}|dkrt|ƒS dS )z.Convert mpmath's ``mpf`` to Python's ``int``. r   N)Úto_rationalr   )r   r   r    r   Úqr   r   r   Úfrom_RealFieldI   s   ÿz PythonIntegerRing.from_RealFieldc                 C   ó
   t ||ƒS )z)Compute extended GCD of ``a`` and ``b``. )r   ©r   r   Úbr   r   r   ÚgcdexP   r"   zPythonIntegerRing.gcdexc                 C   r4   )z Compute GCD of ``a`` and ``b``. )r   r5   r   r   r   ÚgcdT   r"   zPythonIntegerRing.gcdc                 C   r4   )z Compute LCM of ``a`` and ``b``. )r	   r5   r   r   r   ÚlcmX   r"   zPythonIntegerRing.lcmc                 C   r   )zCompute square root of ``a``. )Úpython_sqrtr   r   r   r   r   \   r   zPythonIntegerRing.sqrtc                 C   r   )zCompute factorial of ``a``. )Úpython_factorialr   r   r   r   r   `   r   zPythonIntegerRing.factorialN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚdtypeÚzeroÚoneÚaliasr   r   r   r!   r#   r)   r+   r,   r-   r0   r3   r7   r8   r9   r   r   r   r   r   r   r      s,    	r   N)r?   Úsympy.core.numbersr   Úsympy.polys.domains.groundtypesr   r   r   r:   r   r;   r   r   r	   Úsympy.polys.domains.integerringr
   Úsympy.polys.polyerrorsr   Úsympy.utilitiesr   r   r   r   r   r   Ú<module>   s    $