ó
Ħĵ\c           @  sr   d  Z  d d l m Z m Z d d l m Z d d l m Z m Z d d l	 m
 Z
 e
 d e f d     Y Z d S(	   s(   Implementation of :class:`Field` class. i˙˙˙˙(   t   print_functiont   division(   t   Ring(   t   NotReversiblet   DomainError(   t   publict   Fieldc           B  sk   e  Z d  Z e Z e Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z RS(
   s   Represents a field domain. c         C  s   t  d |    d S(   s)   Returns a ring associated with ``self``. s#   there is no ring associated with %sN(   R   (   t   self(    (    s8   lib/python2.7/site-packages/sympy/polys/domains/field.pyt   get_ring   s    c         C  s   |  S(   s*   Returns a field associated with ``self``. (    (   R   (    (    s8   lib/python2.7/site-packages/sympy/polys/domains/field.pyt	   get_field   s    c         C  s   | | S(   s9   Exact quotient of ``a`` and ``b``, implies ``__div__``.  (    (   R   t   at   b(    (    s8   lib/python2.7/site-packages/sympy/polys/domains/field.pyt   exquo   s    c         C  s   | | S(   s2   Quotient of ``a`` and ``b``, implies ``__div__``. (    (   R   R
   R   (    (    s8   lib/python2.7/site-packages/sympy/polys/domains/field.pyt   quo   s    c         C  s   |  j  S(   s0   Remainder of ``a`` and ``b``, implies nothing.  (   t   zero(   R   R
   R   (    (    s8   lib/python2.7/site-packages/sympy/polys/domains/field.pyt   rem    s    c         C  s   | | |  j  f S(   s2   Division of ``a`` and ``b``, implies ``__div__``. (   R   (   R   R
   R   (    (    s8   lib/python2.7/site-packages/sympy/polys/domains/field.pyt   div$   s    c         C  s   y |  j    } Wn t k
 r' |  j SX| j |  j |  |  j |   } | j |  j |  |  j |   } |  j | |  | S(   sÙ  
        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   t   onet   gcdt   numert   lcmt   denomt   convert(   R   R
   R   t   ringt   pt   q(    (    s8   lib/python2.7/site-packages/sympy/polys/domains/field.pyR   (   s    $$c         C  s   y |  j    } Wn t k
 r( | | SX| j |  j |  |  j |   } | j |  j |  |  j |   } |  j | |  | S(   sç   
        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   R   (    (    s8   lib/python2.7/site-packages/sympy/polys/domains/field.pyR   H   s    	$$c         C  s   | r d | St  d   d S(   s!   Returns ``a**(-1)`` if possible. i   s   zero is not reversibleN(   R   (   R   R
   (    (    s8   lib/python2.7/site-packages/sympy/polys/domains/field.pyt   revert`   s    (   t   __name__t
   __module__t   __doc__t   Truet   is_Fieldt   is_PIDR   R	   R   R   R   R   R   R   R   (    (    (    s8   lib/python2.7/site-packages/sympy/polys/domains/field.pyR   	   s   							 	N(   R   t
   __future__R    R   t   sympy.polys.domains.ringR   t   sympy.polys.polyerrorsR   R   t   sympy.utilitiesR   R   (    (    (    s8   lib/python2.7/site-packages/sympy/polys/domains/field.pyt   <module>   s   