
    Ed
                     ^    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dS )z(Implementation of :class:`Field` class.     )Ring)NotReversibleDomainError)publicc                   V    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S )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    9lib/python3.11/site-packages/sympy/polys/domains/field.pyget_ringzField.get_ring   s    ?$FG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
    yr   c                     ||z  | j         fS )z6Division of ``a`` and ``b``, implies ``__truediv__``. r   r   s      r   divz	Field.div#   s    1udir   c                 ~   	 |                                  }n# t          $ r
 | j        cY S w xY w|                    |                     |          |                     |                    }|                    |                     |          |                     |                    }|                     ||          |z  S )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    ,	==??DD 	 	 	8OOO	 HHTZZ]]DJJqMM22HHTZZ]]DJJqMM22||At$$Q&&s    ++c                 z   	 |                                  }n# t          $ r ||z  cY S w xY w|                    |                     |          |                     |                    }|                    |                     |          |                     |                    }|                     ||          |z  S )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    	==??DD 	 	 	Q3JJJ	 HHTZZ]]DJJqMM22HHTZZ]]DJJqMM22||At$$Q&&s    ))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99r   c                      t          |          S )z$Return true if ``a`` is a invertible)boolr.   s     r   is_unitzField.is_unitf   s    Awwr   N)__name__
__module____qualname____doc__is_Fieldis_PIDr   r   r   r   r   r   r"   r$   r/   r2   r   r   r   r   r      s        %%HFH H 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   