o
    Rh                     @   sD   d Z ddlmZ ddlmZmZ ddlmZ eG dd deZdS )z(Implementation of :class:`Field` class.     )Ring)NotReversibleDomainError)publicc                   @   sp   e Zd ZdZdZdZdd Zdd Zdd Zd	d
 Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd ZdS )FieldzRepresents a field domain. Tc                 C   s   t d|  )z)Returns a ring associated with ``self``. z#there is no ring associated with %s)r   self r	   [/home/air/sanwanet/backup_V2/venv/lib/python3.10/site-packages/sympy/polys/domains/field.pyget_ring   s   zField.get_ringc                 C   s   | S )z*Returns a field associated with ``self``. r	   r   r	   r	   r
   	get_field   s   zField.get_fieldc                 C      || S )z=Exact quotient of ``a`` and ``b``, implies ``__truediv__``.  r	   r   abr	   r	   r
   exquo      zField.exquoc                 C   r   )z6Quotient of ``a`` and ``b``, implies ``__truediv__``. r	   r   r	   r	   r
   quo   r   z	Field.quoc                 C   s   | j S )z0Remainder of ``a`` and ``b``, implies nothing.  zeror   r	   r	   r
   rem   s   z	Field.remc                 C   s   || | j fS )z6Division of ``a`` and ``b``, implies ``__truediv__``. r   r   r	   r	   r
   div#   s   z	Field.divc                 C   sf   z|   }W n ty   | j Y S w || || |}|| || |}| ||| 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qr	   r	   r
   r   '   s   
z	Field.gcdc                 C   sP   |  ||}|| jkr || jkr| j| j| jfS | j|| |fS || | j|fS )zK
        Returns x, y, g such that a * x + b * y == g == gcd(a, b)
        )r   r   r   )r   r   r   dr	   r	   r
   gcdexG   s   

zField.gcdexc                 C   sh   z|   }W n ty   ||  Y S w || || |}|| || |}| ||| 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   r	   r	   r
   r   U   s   z	Field.lcmc                 C   s   |rd| S t d)z!Returns ``a**(-1)`` if possible.    zzero is not reversible)r   r   r   r	   r	   r
   revertm   s   zField.revertc                 C   s   t |S )z$Return true if ``a`` is a invertible)boolr%   r	   r	   r
   is_unitt   r   zField.is_unitN)__name__
__module____qualname____doc__is_Fieldis_PIDr   r   r   r   r   r   r   r#   r   r&   r(   r	   r	   r	   r
   r      s     r   N)	r,   sympy.polys.domains.ringr   sympy.polys.polyerrorsr   r   sympy.utilitiesr   r   r	   r	   r	   r
   <module>   s    