
    sg
                     P    d Z ddlmZ ddlmZmZ ddlmZ e G d de             Zy)z(Implementation of :class:`Field` class.     )Ring)NotReversibleDomainError)publicc                   T    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y)FieldzRepresents a field domain. Tc                     t        d| z        )z)Returns a ring associated with ``self``. z#there is no ring associated with %s)r   selfs    L/var/www/html/venv/lib/python3.12/site-packages/sympy/polys/domains/field.pyget_ringzField.get_ring   s    ?$FGG    c                     | S )z*Returns a field associated with ``self``.  r
   s    r   	get_fieldzField.get_field   s    r   c                     ||z  S )z=Exact quotient of ``a`` and ``b``, implies ``__truediv__``.  r   r   abs      r   exquozField.exquo       1ur   c                     ||z  S )z6Quotient of ``a`` and ``b``, implies ``__truediv__``. r   r   s      r   quoz	Field.quo   r   r   c                     | j                   S )z0Remainder of ``a`` and ``b``, implies nothing.  zeror   s      r   remz	Field.rem   s    yyr   c                 $    ||z  | j                   fS )z6Division of ``a`` and ``b``, implies ``__truediv__``. r   r   s      r   divz	Field.div#   s    1udiir   c                 D   	 | j                         }|j                  | j	                  |      | j	                  |            }|j                  | j                  |      | j                  |            }| j                  ||      |z  S # t        $ r | j                  cY S w xY w)a  
        Returns GCD of ``a`` and ``b``.

        This definition of GCD over fields allows to clear denominators
        in `primitive()`.

        Examples
        ========

        >>> from sympy.polys.domains import QQ
        >>> from sympy import S, gcd, primitive
        >>> from sympy.abc import x

        >>> QQ.gcd(QQ(2, 3), QQ(4, 9))
        2/9
        >>> gcd(S(2)/3, S(4)/9)
        2/9
        >>> primitive(2*x/3 + S(4)/9)
        (2/9, 3*x + 2)

        )r   r   onegcdnumerlcmdenomconvertr   r   r   ringpqs         r   r"   z	Field.gcd'   s    ,	==?D HHTZZ]DJJqM2HHTZZ]DJJqM2||At$Q&&  	88O	s   B BBc                 6   	 | j                         }|j                  | j                  |      | j                  |            }|j	                  | j                  |      | j                  |            }| j                  ||      |z  S # t        $ r ||z  cY S w xY w)z
        Returns LCM of ``a`` and ``b``.

        >>> from sympy.polys.domains import QQ
        >>> from sympy import S, lcm

        >>> QQ.lcm(QQ(2, 3), QQ(4, 9))
        4/3
        >>> lcm(S(2)/3, S(4)/9)
        4/3

        )r   r   r$   r#   r"   r%   r&   r'   s         r   r$   z	Field.lcmG   s    	==?D HHTZZ]DJJqM2HHTZZ]DJJqM2||At$Q&&  	Q3J	s   B BBc                 &    |rd|z  S t        d      )z!Returns ``a**(-1)`` if possible.    zzero is not reversible)r   r   r   s     r   revertzField.revert_   s    Q3J 899r   c                     t        |      S )z$Return true if ``a`` is a invertible)boolr.   s     r   is_unitzField.is_unitf   s    Awr   N)__name__
__module____qualname____doc__is_Fieldis_PIDr   r   r   r   r   r   r"   r$   r/   r2   r   r   r   r   r      sC    %HFH '@'0:r   r   N)	r6   sympy.polys.domains.ringr   sympy.polys.polyerrorsr   r   sympy.utilitiesr   r   r   r   r   <module>r<      s/    . * = "_D _ _r   