
    Xh                     ^    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                   \    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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    k/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/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                     |                      ||          }|| j        k    r,|| j        k    r| j        | j        | j        fS | j        ||z  |fS ||z  | j        |fS )zK
        Returns x, y, g such that a * x + b * y == g == gcd(a, b)
        )r"   r   r!   )r   r   r   ds       r   gcdexzField.gcdexG   sd     HHQNN	>>DI~~y$(DI55y!A#q((Q3	1$$r   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.lcmU   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.revertm   s"     	:Q3J 8999r   c                      t          |          S )z$Return true if ``a`` is a invertible)boolr1   s     r   is_unitzField.is_unitt   s    Awwr   N)__name__
__module____qualname____doc__is_Fieldis_PIDr   r   r   r   r   r   r"   r-   r$   r2   r5   r   r   r   r   r      s        %%HFH H H             ' ' '@% % %' ' '0: : :    r   r   N)	r9   sympy.polys.domains.ringr   sympy.polys.polyerrorsr   r   sympy.utilitiesr   r   r   r   r   <module>r?      s    . . * ) ) ) ) ) = = = = = = = = " " " " " "m m m m mD m m m m mr   