U
    L?h
                     @   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                   @   sh   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S )FieldzRepresents a field domain. Tc                 C   s   t d|  dS )z)Returns a ring associated with ``self``. z#there is no ring associated with %sN)r   self r	   K/var/www/html/venv/lib/python3.8/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   || S )z=Exact quotient of ``a`` and ``b``, implies ``__truediv__``.  r	   r   abr	   r	   r
   exquo   s    zField.exquoc                 C   s   || S )z6Quotient of ``a`` and ``b``, implies ``__truediv__``. r	   r   r	   r	   r
   quo   s    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   sh   z|   }W n tk
r&   | j Y S X || || |}|| || |}| ||| 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   sj   z|   }W n tk
r(   ||  Y S X || || |}|| || |}| ||| 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   G   s    z	Field.lcmc                 C   s   |rd| S t ddS )z!Returns ``a**(-1)`` if possible.    zzero is not reversibleN)r   r   r   r	   r	   r
   revert_   s    zField.revertc                 C   s   t |S )z$Return true if ``a`` is a invertible)boolr!   r	   r	   r
   is_unitf   s    zField.is_unitN)__name__
__module____qualname____doc__Zis_FieldZis_PIDr   r   r   r   r   r   r   r   r"   r$   r	   r	   r	   r
   r      s    r   N)	r(   Zsympy.polys.domains.ringr   Zsympy.polys.polyerrorsr   r   Zsympy.utilitiesr   r   r	   r	   r	   r
   <module>   s
   