o
    i                     @   sp   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 deZd	S )
z2Implementation of :class:`GMPYIntegerRing` class.     )GMPYIntegerSymPyInteger	factorial
gmpy_gcdexgmpy_gcdgmpy_lcmsqrt)
int_valued)IntegerRing)CoercionFailed)publicc                   @   s   e Zd ZdZeZedZedZee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%d& Zd'S )(GMPYIntegerRingzInteger 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      ZZZ_gmpyc                 C   s   dS )z$Allow instantiation of this domain. N )selfr   r   r/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/sympy/polys/domains/gmpyintegerring.py__init__   s    zGMPYIntegerRing.__init__c                 C   s   t t|S )z!Convert ``a`` to a SymPy object. )r   intr   ar   r   r   to_sympy   s   zGMPYIntegerRing.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)Z
is_Integerr   pr	   r   r   r   r   r   r   
from_sympy#   s
   
zGMPYIntegerRing.from_sympyc                 C   
   | |S )z3Convert ``ModularInteger(int)`` to GMPY's ``mpz``. Zto_intK1r   K0r   r   r   from_FF_python,      
zGMPYIntegerRing.from_FF_pythonc                 C      t |S )z,Convert Python's ``int`` to GMPY's ``mpz``. )r   r   r   r   r   from_ZZ_python0      zGMPYIntegerRing.from_ZZ_pythonc                 C      |j dkr
t|jS dS z1Convert Python's ``Fraction`` to GMPY's ``mpz``. r   Ndenominatorr   	numeratorr   r   r   r   from_QQ4      

zGMPYIntegerRing.from_QQc                 C   r#   r$   r%   r   r   r   r   from_QQ_python9   r)   zGMPYIntegerRing.from_QQ_pythonc                 C   r   )z3Convert ``ModularInteger(mpz)`` to GMPY's ``mpz``. r   r   r   r   r   from_FF_gmpy>   r   zGMPYIntegerRing.from_FF_gmpyc                 C   s   |S )z*Convert GMPY's ``mpz`` to GMPY's ``mpz``. r   r   r   r   r   from_ZZ_gmpyB   s   zGMPYIntegerRing.from_ZZ_gmpyc                 C   s   |j dkr|jS dS )z(Convert GMPY ``mpq`` to GMPY's ``mpz``. r   N)r&   r'   r   r   r   r   from_QQ_gmpyF   s   
zGMPYIntegerRing.from_QQ_gmpyc                 C   s"   | |\}}|dkrt|S dS )z,Convert mpmath's ``mpf`` to GMPY's ``mpz``. r   N)Zto_rationalr   )r   r   r   r   qr   r   r   from_RealFieldK   s   zGMPYIntegerRing.from_RealFieldc                 C   s   |j dkr|jS d S )Nr   )yxr   r   r   r   from_GaussianIntegerRingR   s   
z(GMPYIntegerRing.from_GaussianIntegerRingc                 C   s   t ||\}}}|||fS )z)Compute extended GCD of ``a`` and ``b``. )r   )r   r   bhstr   r   r   gcdexV   s   
zGMPYIntegerRing.gcdexc                 C   
   t ||S )z Compute GCD of ``a`` and ``b``. )r   r   r   r3   r   r   r   gcd[   r   zGMPYIntegerRing.gcdc                 C   r8   )z Compute LCM of ``a`` and ``b``. )r   r9   r   r   r   lcm_   r   zGMPYIntegerRing.lcmc                 C   r    )zCompute square root of ``a``. )	gmpy_sqrtr   r   r   r   r   c   r"   zGMPYIntegerRing.sqrtc                 C   r    )zCompute factorial of ``a``. )gmpy_factorialr   r   r   r   r   g   r"   zGMPYIntegerRing.factorialN)__name__
__module____qualname____doc__r   Zdtypezeroonetypetpaliasr   r   r   r   r!   r(   r*   r+   r,   r-   r/   r2   r7   r:   r;   r   r   r   r   r   r   r      s0    	r   N)rA   Zsympy.polys.domains.groundtypesr   r   r   r=   r   r   r   r   r<   Zsympy.core.numbersr	   Zsympy.polys.domains.integerringr
   Zsympy.polys.polyerrorsr   Zsympy.utilitiesr   r   r   r   r   r   <module>   s    $