ó
    Š*£h^  ã                   ó–   • S r SSKJr  SSKJrJrJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  SSKJr  \ " S	 S
\
\\5      5       r\" 5       rg)z0Implementation of :class:`RationalField` class. é    ©ÚMPQ)ÚSymPyRationalÚ	is_squareÚsqrtrem)ÚCharacteristicZero)ÚField)ÚSimpleDomain)ÚCoercionFailed)Úpublicc                   ó   • \ rS rSrSrSrSrS=rrSr	Sr
Sr\r\" S5      r\" S5      r\" \5      rS rS rS	 rS
 rS rS rSS.S jrS rS rS rS rS rS rS rS r S r!S r"S r#S r$S r%S r&S r'S r(S  r)S!r*g)"ÚRationalFieldé   aÃ  Abstract base class for the domain :ref:`QQ`.

The :py:class:`RationalField` class represents the field of rational
numbers $\mathbb{Q}$ as a :py:class:`~.Domain` in the domain system.
:py:class:`RationalField` is a superclass of
:py:class:`PythonRationalField` and :py:class:`GMPYRationalField` one of
which will be the implementation for :ref:`QQ` depending on whether either
of ``gmpy`` or ``gmpy2`` is installed or not.

See also
========

Domain
ÚQQTr   é   c                 ó   • g )N© ©Úselfs    Ú^/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/polys/domains/rationalfield.pyÚ__init__ÚRationalField.__init__-   s   € Øó    c                 ó:   • [        U[        5      (       a  g[        $ )z0Returns ``True`` if two domains are equivalent. T)Ú
isinstancer   ÚNotImplemented)r   Úothers     r   Ú__eq__ÚRationalField.__eq__0   s   € ä�eœ]×+Ñ+Øä!Ð!r   c                 ó   • [        S5      $ )zReturns hash code of ``self``. r   )Úhashr   s    r   Ú__hash__ÚRationalField.__hash__7   s   € ä�D‹zÐr   c                 ó   • SSK Jn  U$ )z'Returns ring associated with ``self``. r   )ÚZZ)Úsympy.polys.domainsr%   )r   r%   s     r   Úget_ringÚRationalField.get_ring;   s
   € å*Øˆ	r   c                 óf   • [        [        UR                  5      [        UR                  5      5      $ )z!Convert ``a`` to a SymPy object. )r   ÚintÚ	numeratorÚdenominator©r   Úas     r   Úto_sympyÚRationalField.to_sympy@   s!   € äœS §¡Ó-¬s°1·=±=Ó/AÓBÐBr   c                 óø   • UR                   (       a   [        UR                  UR                  5      $ UR                  (       a+  SSKJn  [        [        [        UR                  U5      5      6 $ [        SU-  5      e)z&Convert SymPy's Integer to ``dtype``. r   )ÚRRz"expected `Rational` object, got %s)Úis_Rationalr   ÚpÚqÚis_Floatr&   r2   Úmapr*   Úto_rationalr   )r   r.   r2   s      r   Ú
from_sympyÚRationalField.from_sympyD   sS   € à�=�=Ü�q—s‘s˜AŸC™C“=Ð Ø�Z�ZÝ.ÜœœC §¡°Ó!2Ó3Ð4Ð4ä Ð!EÈÑ!IÓJÐJr   N)Úaliasc                ó&   • SSK Jn  U" U /UQ7SU06$ )a„  Returns an algebraic field, i.e. `\mathbb{Q}(\alpha, \ldots)`.

Parameters
==========

*extension : One or more :py:class:`~.Expr`
    Generators of the extension. These should be expressions that are
    algebraic over `\mathbb{Q}`.

alias : str, :py:class:`~.Symbol`, None, optional (default=None)
    If provided, this will be used as the alias symbol for the
    primitive element of the returned :py:class:`~.AlgebraicField`.

Returns
=======

:py:class:`~.AlgebraicField`
    A :py:class:`~.Domain` representing the algebraic field extension.

Examples
========

>>> from sympy import QQ, sqrt
>>> QQ.algebraic_field(sqrt(2))
QQ<sqrt(2)>
r   )ÚAlgebraicFieldr;   )r&   r=   )r   r;   Ú	extensionr=   s       r   Úalgebraic_fieldÚRationalField.algebraic_fieldN   s   € õ6 	7Ù˜dÐ< YÒ<°eÑ<Ð<r   c                 óz   • UR                   (       a*  U R                  UR                  5       UR                  5      $ g)zRConvert a :py:class:`~.ANP` object to :ref:`QQ`.

See :py:meth:`~.Domain.convert`
N)Ú	is_groundÚconvertÚLCÚdom©ÚK1r.   ÚK0s      r   Úfrom_AlgebraicFieldÚ!RationalField.from_AlgebraicFieldl   s+   € ð
 �;�;Ø—:‘:˜aŸd™d›f b§f¡fÓ-Ð-ð r   c                 ó   • [        U5      $ ©z.Convert a Python ``int`` object to ``dtype``. r   rF   s      r   Úfrom_ZZÚRationalField.from_ZZt   ó   € ä�1‹vˆr   c                 ó   • [        U5      $ rL   r   rF   s      r   Úfrom_ZZ_pythonÚRationalField.from_ZZ_pythonx   rO   r   c                 óB   • [        UR                  UR                  5      $ ©z3Convert a Python ``Fraction`` object to ``dtype``. ©r   r+   r,   rF   s      r   Úfrom_QQÚRationalField.from_QQ|   ó   € ä�1—;‘; §¡Ó.Ð.r   c                 óB   • [        UR                  UR                  5      $ rT   rU   rF   s      r   Úfrom_QQ_pythonÚRationalField.from_QQ_python€   rX   r   c                 ó   • [        U5      $ )z,Convert a GMPY ``mpz`` object to ``dtype``. r   rF   s      r   Úfrom_ZZ_gmpyÚRationalField.from_ZZ_gmpy„   rO   r   c                 ó   • U$ )z,Convert a GMPY ``mpq`` object to ``dtype``. r   rF   s      r   Úfrom_QQ_gmpyÚRationalField.from_QQ_gmpyˆ   s   € àˆr   c                 óN   • UR                   S:X  a  [        UR                  5      $ g)z3Convert a ``GaussianElement`` object to ``dtype``. r   N)Úyr   ÚxrF   s      r   Úfrom_GaussianRationalFieldÚ(RationalField.from_GaussianRationalFieldŒ   s   € à�3‰3�!‹8Ü�q—s‘s“8ˆOð r   c                 óL   • [        [        [        UR                  U5      5      6 $ )z.Convert a mpmath ``mpf`` object to ``dtype``. )r   r7   r*   r8   rF   s      r   Úfrom_RealFieldÚRationalField.from_RealField‘   s   € ä”Cœ˜RŸ^™^¨AÓ.Ó/Ð0Ð0r   c                 ó0   • [        U5      [        U5      -  $ )z=Exact quotient of ``a`` and ``b``, implies ``__truediv__``.  r   ©r   r.   Úbs      r   ÚexquoÚRationalField.exquo•   ó   € ä�1‹vœ˜A›‰Ðr   c                 ó0   • [        U5      [        U5      -  $ )z6Quotient of ``a`` and ``b``, implies ``__truediv__``. r   rk   s      r   ÚquoÚRationalField.quo™   ro   r   c                 ó   • U R                   $ )z0Remainder of ``a`` and ``b``, implies nothing.  )Úzerork   s      r   ÚremÚRationalField.rem�   s   € à�y‰yÐr   c                 óH   • [        U5      [        U5      -  U R                  4$ )z6Division of ``a`` and ``b``, implies ``__truediv__``. )r   rt   rk   s      r   ÚdivÚRationalField.div¡   s   € ä�1‹vœ˜A›‰ §	¡	Ð)Ð)r   c                 ó   • UR                   $ )zReturns numerator of ``a``. )r+   r-   s     r   ÚnumerÚRationalField.numer¥   s   € à�{‰{Ðr   c                 ó   • UR                   $ )zReturns denominator of ``a``. )r,   r-   s     r   ÚdenomÚRationalField.denom©   s   € à�}‰}Ðr   c                 ód   • [        UR                  5      =(       a    [        UR                  5      $ )z«Return ``True`` if ``a`` is a square.

Explanation
===========
A rational number is a square if and only if there exists
a rational number ``b`` such that ``b * b == a``.
)r   r+   r,   r-   s     r   r   ÚRationalField.is_square­   s!   € ô ˜Ÿ™Ó%×B¬)°A·M±MÓ*BÐBr   c                 ó²   • UR                   S:  a  g[        UR                   5      u  p#US:w  a  g[        UR                  5      u  pEUS:w  a  g[        X$5      $ )zUNon-negative square root of ``a`` if ``a`` is a square.

See also
========
is_square
r   N)r+   r   r,   r   )r   r.   Úp_sqrtÚp_remÚq_sqrtÚq_rems         r   ÚexsqrtÚRationalField.exsqrt·   sQ   € ð �;‰;˜‹?ØÜ §¡Ó,‰ˆØ�A‹:ØÜ §¡Ó.‰ˆØ�A‹:ØÜ�6Ó"Ð"r   r   )+Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úrepr;   Úis_RationalFieldÚis_QQÚis_NumericalÚhas_assoc_RingÚhas_assoc_Fieldr   Údtypert   ÚoneÚtypeÚtpr   r   r"   r'   r/   r9   r?   rI   rM   rQ   rV   rZ   r]   r`   re   rh   rm   rq   ru   rx   r{   r~   r   r‡   Ú__static_attributes__r   r   r   r   r      sÍ   † ñð €CØ€Eà#Ð#Ð�uØ€Là€NØ€Oà€EÙ�‹8€DÙ
�‹(€CÙ	ˆc‹€Bòò"òòò
CòKð 15õ =ò<.òòò/ò/òòòò
1òòòò*òòòCõ#r   r   N)r�   Úsympy.external.gmpyr   Úsympy.polys.domains.groundtypesr   r   r   Ú&sympy.polys.domains.characteristiczeror   Úsympy.polys.domains.fieldr	   Ú sympy.polys.domains.simpledomainr
   Úsympy.polys.polyerrorsr   Úsympy.utilitiesr   r   r   r   r   r   Ú<module>r       sM   ðÙ 6õ $ç MÑ Må EÝ +Ý 9Ý 1Ý "àôw#�EÐ-¨|ó w#ó ðw#ñr ƒ_�r   