a
    RG5dj  ã                   @   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   úa/var/www/html/django/DPS/env/lib/python3.9/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   sJ   |j rt|j|jƒS |jr:ddlm} ttt| 	|¡ƒŽ S t
d| ƒ‚dS )z&Convert SymPy's Integer to ``dtype``. r   )ÚRRz$expected ``Rational`` object, got %sN)Úis_Rationalr   ÚpÚqÚis_Floatr   r   Úmapr   Úto_rationalr   )r   r   r   r   r   r   Ú
from_sympy'   s    zGMPYRationalField.from_sympyc                 C   s   t |ƒS )z.Convert a Python ``int`` object to ``dtype``. ©r   ©ÚK1r   ÚK0r   r   r   Úfrom_ZZ_python1   s    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   s   t |ƒS )z,Convert a GMPY ``mpz`` object to ``dtype``. r    r!   r   r   r   Úfrom_ZZ_gmpy9   s    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   s   t |ƒt |ƒ S )z=Exact quotient of ``a`` and ``b``, implies ``__truediv__``.  r    ©r   r   Úbr   r   r   ÚexquoJ   s    zGMPYRationalField.exquoc                 C   s   t |ƒt |ƒ S )z6Quotient of ``a`` and ``b``, implies ``__truediv__``. r    r.   r   r   r   ÚquoN   s    zGMPYRationalField.quoc                 C   s   | j S )z0Remainder of ``a`` and ``b``, implies nothing.  )Úzeror.   r   r   r   ÚremR   s    zGMPYRationalField.remc                 C   s   t |ƒt |ƒ | jfS )z6Division of ``a`` and ``b``, implies ``__truediv__``. )r   r2   r.   r   r   r   ÚdivV   s    zGMPYRationalField.divc                 C   s   |j S )zReturns numerator of ``a``. )r%   r   r   r   r   ÚnumerZ   s    zGMPYRationalField.numerc                 C   s   |j S )zReturns denominator of ``a``. )r&   r   r   r   r   Údenom^   s    zGMPYRationalField.denomc                 C   s   t tt|ƒƒƒS )zReturns factorial of ``a``. )r   Úgmpy_factorialr   r   r   r   r   r   b   s    zGMPYRationalField.factorialN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Údtyper2   ÚoneÚtypeÚtpÚaliasr   r   r   r   r$   r'   r(   r)   r,   r-   r0   r1   r3   r4   r5   r6   r   r   r   r   r   r
      s.   
r
   N)r;   Úsympy.polys.domains.groundtypesr   r   r   r   r   r7   Z!sympy.polys.domains.rationalfieldr   Úsympy.polys.polyerrorsr   Úsympy.utilitiesr	   r
   r   r   r   r   Ú<module>   s   