o
    jgj  ã                   @   s\   d Z ddl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:`GMPYRationalField` class. é    )ÚGMPYRationalÚSymPyRationalÚ
gmpy_numerÚ
gmpy_denomÚ	factorial)ÚRationalField)Ú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 )(ÚGMPYRationalFieldzµRational field based on GMPY's ``mpq`` type.

    This will be the implementation of :ref:`QQ` if ``gmpy`` or ``gmpy2`` is
    installed. Elements will be of type ``gmpy.mpq``.
    r   é   ÚQQ_gmpyc                 C   s   d S )N© )Úselfr   r   ú]/var/www/html/zoom/venv/lib/python3.10/site-packages/sympy/polys/domains/gmpyrationalfield.pyÚ__init__   s   zGMPYRationalField.__init__c                 C   s   ddl m} |ƒ S )z'Returns ring associated with ``self``. r   )ÚGMPYIntegerRing)Úsympy.polys.domainsr   )r   r   r   r   r   Úget_ring   s   zGMPYRationalField.get_ringc                 C   s   t tt|ƒƒtt|ƒƒƒS )z!Convert ``a`` to a SymPy object. )r   Úintr   r   ©r   Úar   r   r   Úto_sympy"   s   
ÿzGMPYRationalField.to_sympyc                 C   sF   |j r
t|j|jƒS |jrddlm} ttt| 	|¡ƒŽ S t
d| ƒ‚)z&Convert SymPy's Integer to ``dtype``. r   )ÚRRz$expected ``Rational`` object, got %s)Úis_Rationalr   ÚpÚqÚis_Floatr   r   Úmapr   Úto_rationalr   )r   r   r   r   r   r   Ú
from_sympy'   s   zGMPYRationalField.from_sympyc                 C   ó   t |ƒS )z.Convert a Python ``int`` object to ``dtype``. ©r   ©ÚK1r   ÚK0r   r   r   Úfrom_ZZ_python1   ó   z GMPYRationalField.from_ZZ_pythonc                 C   s   t |j|jƒS )z3Convert a Python ``Fraction`` object to ``dtype``. )r   Ú	numeratorÚdenominatorr"   r   r   r   Úfrom_QQ_python5   s   z GMPYRationalField.from_QQ_pythonc                 C   r    )z,Convert a GMPY ``mpz`` object to ``dtype``. r!   r"   r   r   r   Úfrom_ZZ_gmpy9   r&   zGMPYRationalField.from_ZZ_gmpyc                 C   s   |S )z,Convert a GMPY ``mpq`` object to ``dtype``. r   r"   r   r   r   Úfrom_QQ_gmpy=   s   zGMPYRationalField.from_QQ_gmpyc                 C   s   |j dkr
t|jƒS dS )z3Convert a ``GaussianElement`` object to ``dtype``. r   N)Úyr   Úxr"   r   r   r   Úfrom_GaussianRationalFieldA   s   

ÿz,GMPYRationalField.from_GaussianRationalFieldc                 C   s   t tt| |¡ƒŽ S )z.Convert a mpmath ``mpf`` object to ``dtype``. )r   r   r   r   r"   r   r   r   Úfrom_RealFieldF   s   z GMPYRationalField.from_RealFieldc                 C   ó   t |ƒt |ƒ S )z=Exact quotient of ``a`` and ``b``, implies ``__truediv__``.  r!   ©r   r   Úbr   r   r   ÚexquoJ   ó   zGMPYRationalField.exquoc                 C   r0   )z6Quotient of ``a`` and ``b``, implies ``__truediv__``. r!   r1   r   r   r   ÚquoN   r4   zGMPYRationalField.quoc                 C   s   | j S )z0Remainder of ``a`` and ``b``, implies nothing.  )Úzeror1   r   r   r   ÚremR   ó   zGMPYRationalField.remc                 C   s   t |ƒt |ƒ | jfS )z6Division of ``a`` and ``b``, implies ``__truediv__``. )r   r6   r1   r   r   r   ÚdivV   s   zGMPYRationalField.divc                 C   ó   |j S )zReturns numerator of ``a``. )r'   r   r   r   r   ÚnumerZ   r8   zGMPYRationalField.numerc                 C   r:   )zReturns denominator of ``a``. )r(   r   r   r   r   Údenom^   r8   zGMPYRationalField.denomc                 C   s   t tt|ƒƒƒS )zReturns factorial of ``a``. )r   Úgmpy_factorialr   r   r   r   r   r   b   r4   zGMPYRationalField.factorialN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Údtyper6   ÚoneÚtypeÚtpÚaliasr   r   r   r   r%   r)   r*   r+   r.   r/   r3   r5   r7   r9   r;   r<   r   r   r   r   r   r
      s0    
r
   N)rA   Úsympy.polys.domains.groundtypesr   r   r   r   r   r=   Ú!sympy.polys.domains.rationalfieldr   Úsympy.polys.polyerrorsr   Úsympy.utilitiesr	   r
   r   r   r   r   Ú<module>   s    