B
    ˜‘[  ã               @   sp   d Z ddlmZmZ ddlmZ ddlmZmZm	Z	m
Z
mZmZ ddlmZ ddlmZ eG dd„ deƒƒZd	S )
z3Implementaton of :class:`GMPYRationalField` class. é    )Úprint_functionÚdivision)ÚRationalField)ÚGMPYRationalÚSymPyRationalÚ
gmpy_numerÚ
gmpy_denomÚgmpy_factorialÚ	gmpy_qdiv)Ú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%S )&ÚGMPYRationalFieldz(Rational field based on GMPY mpq class. r   é   ZQQ_gmpyc             C   s   d S )N© )Úselfr   r   úDlib/python3.7/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)Zis_Rationalr   ÚpÚqZ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_python/   s    z GMPYRationalField.from_ZZ_pythonc             C   s   t |j|jƒS )z/Convert a Python `Fraction` object to `dtype`. )r   Ú	numeratorÚdenominator)r   r   r    r   r   r   Úfrom_QQ_python3   s    z GMPYRationalField.from_QQ_pythonc             C   s   t |ƒS )z(Convert a GMPY `mpz` object to `dtype`. )r   )r   r   r    r   r   r   Úfrom_ZZ_gmpy7   s    zGMPYRationalField.from_ZZ_gmpyc             C   s   |S )z(Convert a GMPY `mpq` object to `dtype`. r   )r   r   r    r   r   r   Úfrom_QQ_gmpy;   s    zGMPYRationalField.from_QQ_gmpyc             C   s   t tt| |¡ƒŽ S )z*Convert a mpmath `mpf` object to `dtype`. )r   r   r   r   )r   r   r    r   r   r   Úfrom_RealField?   s    z GMPYRationalField.from_RealFieldc             C   s   t |ƒt |ƒ S )z3Exact quotient of `a` and `b`, implies `__div__`.  )r   )r   r   Úbr   r   r   ÚexquoC   s    zGMPYRationalField.exquoc             C   s   t |ƒt |ƒ S )z,Quotient of `a` and `b`, implies `__div__`. )r   )r   r   r(   r   r   r   ÚquoG   s    zGMPYRationalField.quoc             C   s   | j S )z,Remainder of `a` and `b`, implies nothing.  )Úzero)r   r   r(   r   r   r   ÚremK   s    zGMPYRationalField.remc             C   s   t |ƒt |ƒ | jfS )z,Division of `a` and `b`, implies `__div__`. )r   r+   )r   r   r(   r   r   r   ÚdivO   s    zGMPYRationalField.divc             C   s   |j S )zReturns numerator of `a`. )r"   )r   r   r   r   r   ÚnumerS   s    zGMPYRationalField.numerc             C   s   |j S )zReturns denominator of `a`. )r#   )r   r   r   r   r   ÚdenomW   s    zGMPYRationalField.denomc             C   s   t tt|ƒƒƒS )zReturns factorial of `a`. )r   r	   r   )r   r   r   r   r   Ú	factorial[   s    zGMPYRationalField.factorialN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Zdtyper+   ZoneÚtypeÚtpÚaliasr   r   r   r   r!   r$   r%   r&   r'   r)   r*   r,   r-   r.   r/   r0   r   r   r   r   r      s,   
r   N)r4   Z
__future__r   r   Z!sympy.polys.domains.rationalfieldr   Zsympy.polys.domains.groundtypesr   r   r   r   r	   r
   Zsympy.polys.polyerrorsr   Zsympy.utilitiesr   r   r   r   r   r   Ú<module>   s    