
    Edj                     v    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e	                      ZdS )	z4Implementation of :class:`GMPYRationalField` class.     )GMPYRationalSymPyRational
gmpy_numer
gmpy_denom	factorial)RationalField)CoercionFailed)publicc                       e Zd ZdZeZ ed          Z ed          Z ee          Z	dZ
d Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )GMPYRationalFieldzRational 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                     d S )N )selfs    Elib/python3.11/site-packages/sympy/polys/domains/gmpyrationalfield.py__init__zGMPYRationalField.__init__   s        c                 "    ddl m}  |            S )z'Returns ring associated with ``self``. r   )GMPYIntegerRing)sympy.polys.domainsr   )r   r   s     r   get_ringzGMPYRationalField.get_ring   s"    777777   r   c                     t          t          t          |                    t          t          |                              S )z!Convert ``a`` to a SymPy object. )r   intr   r   r   as     r   to_sympyzGMPYRationalField.to_sympy"   s5    SA// A//1 1 	1r   c                     |j         rt          |j        |j                  S |j        r5ddlm} t          t          t          |	                    |                     S t          d|z            )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   s      r   
from_sympyzGMPYRationalField.from_sympy'   ss    = 	MQS)))Z 	M......S"..*;*;!<!<== !G!!KLLLr   c                      t          |          S )z.Convert a Python ``int`` object to ``dtype``. r   K1r   K0s      r   from_ZZ_pythonz GMPYRationalField.from_ZZ_python1       Ar   c                 6    t          |j        |j                  S )z3Convert a Python ``Fraction`` object to ``dtype``. )r   	numeratordenominatorr)   s      r   from_QQ_pythonz GMPYRationalField.from_QQ_python5   s    AK777r   c                      t          |          S )z,Convert a GMPY ``mpz`` object to ``dtype``. r(   r)   s      r   from_ZZ_gmpyzGMPYRationalField.from_ZZ_gmpy9   r-   r   c                     |S )z,Convert a GMPY ``mpq`` object to ``dtype``. r   r)   s      r   from_QQ_gmpyzGMPYRationalField.from_QQ_gmpy=   s    r   c                 D    |j         dk    rt          |j                  S dS )z3Convert a ``GaussianElement`` object to ``dtype``. r   N)yr   xr)   s      r   from_GaussianRationalFieldz,GMPYRationalField.from_GaussianRationalFieldA   s*    3!8 	%$$$	% 	%r   c                 `    t          t          t          |                    |                     S )z.Convert a mpmath ``mpf`` object to ``dtype``. )r   r$   r   r%   r)   s      r   from_RealFieldz GMPYRationalField.from_RealFieldF   s#    SbnnQ&7&78899r   c                 @    t          |          t          |          z  S )z=Exact quotient of ``a`` and ``b``, implies ``__truediv__``.  r(   r   r   bs      r   exquozGMPYRationalField.exquoJ       Aa00r   c                 @    t          |          t          |          z  S )z6Quotient of ``a`` and ``b``, implies ``__truediv__``. r(   r=   s      r   quozGMPYRationalField.quoN   r@   r   c                     | j         S )z0Remainder of ``a`` and ``b``, implies nothing.  )zeror=   s      r   remzGMPYRationalField.remR   s
    yr   c                 N    t          |          t          |          z  | j        fS )z6Division of ``a`` and ``b``, implies ``__truediv__``. )r   rD   r=   s      r   divzGMPYRationalField.divV   s     Aa0$);;r   c                     |j         S )zReturns numerator of ``a``. )r/   r   s     r   numerzGMPYRationalField.numerZ   s
    {r   c                     |j         S )zReturns denominator of ``a``. )r0   r   s     r   denomzGMPYRationalField.denom^   s
    }r   c                 T    t          t          t          |                              S )zReturns factorial of ``a``. )r   gmpy_factorialr   r   s     r   r   zGMPYRationalField.factorialb   s    N3q6622333r   N)__name__
__module____qualname____doc__r   dtyperD   onetypetpaliasr   r   r   r&   r,   r1   r3   r5   r9   r;   r?   rB   rE   rG   rI   rK   r   r   r   r   r   r      sS         E588D
%((C	cBE  ! ! !
1 1 1
M M M  8 8 8    % % %
: : :1 1 11 1 1  < < <    4 4 4 4 4r   r   N)rQ   sympy.polys.domains.groundtypesr   r   r   r   r   rM   !sympy.polys.domains.rationalfieldr   sympy.polys.polyerrorsr	   sympy.utilitiesr
   r   r   r   r   <module>r[      s    : :              < ; ; ; ; ; 1 1 1 1 1 1 " " " " " "W4 W4 W4 W4 W4 W4 W4 W4 W4 W4r   