o
    jg
  ã                   @   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|  ƒ‚)z)Returns a ring associated with ``self``. z#there is no ring associated with %s)r   ©Úself© r	   úQ/var/www/html/zoom/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   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   G   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
   Úrevert_   s   zField.revertc                 C   s   t |ƒS )z$Return true if ``a`` is a invertible)Úboolr#   r	   r	   r
   Úis_unitf   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      s     r   N)	r*   Úsympy.polys.domains.ringr   Úsympy.polys.polyerrorsr   r   Úsympy.utilitiesr   r   r	   r	   r	   r
   Ú<module>   s    