ó
Ħĵ\c           @  sx   d  Z  d d l m Z m Z d d l m Z d d l m Z m Z m	 Z	 d d l
 m Z e d e f d     Y Z d S(	   s'   Implementation of :class:`Ring` class. i˙˙˙˙(   t   print_functiont   division(   t   Domain(   t   ExactQuotientFailedt   NotInvertiblet   NotReversible(   t   publict   Ringc           B  s   e  Z d  Z 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 e Z RS(   s   Represents a ring domain. c         C  s   |  S(   s)   Returns a ring associated with ``self``. (    (   t   self(    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   get_ring   s    c         C  s+   | | r t  | | |    n | | Sd S(   s>   Exact quotient of ``a`` and ``b``, implies ``__floordiv__``.  N(   R   (   R   t   at   b(    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   exquo   s    
c         C  s   | | S(   s7   Quotient of ``a`` and ``b``, implies ``__floordiv__``. (    (   R   R
   R   (    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   quo   s    c         C  s   | | S(   s4   Remainder of ``a`` and ``b``, implies ``__mod__``.  (    (   R   R
   R   (    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   rem   s    c         C  s   t  | |  S(   s5   Division of ``a`` and ``b``, implies ``__divmod__``. (   t   divmod(   R   R
   R   (    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   div#   s    c         C  sB   |  j  | |  \ } } } |  j |  r2 | | St d   d S(   s"   Returns inversion of ``a mod b``. s   zero divisorN(   t   gcdext   is_oneR   (   R   R
   R   t   st   tt   h(    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   invert'   s    c         C  s#   |  j  |  r | St d   d S(   s!   Returns ``a**(-1)`` if possible. s"   only unity is reversible in a ringN(   R   R   (   R   R
   (    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   revert0   s    c         C  s.   y |  j  |  t SWn t k
 r) t SXd  S(   N(   R   t   TrueR   t   False(   R   R
   (    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   is_unit7   s
    c         C  s   | S(   s   Returns numerator of ``a``. (    (   R   R
   (    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   numer>   s    c         C  s   |  j  S(   s   Returns denominator of `a`. (   t   one(   R   R
   (    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   denomB   s    c         C  s
   t   d S(   sÊ   
        Generate a free module of rank ``rank`` over self.

        >>> from sympy.abc import x
        >>> from sympy import QQ
        >>> QQ.old_poly_ring(x).free_module(2)
        QQ[x]**2
        N(   t   NotImplementedError(   R   t   rank(    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   free_moduleF   s    	c         G  sE   d d l  m } | |  |  j d  j g  | D] } | g ^ q,    S(   sħ   
        Generate an ideal of ``self``.

        >>> from sympy.abc import x
        >>> from sympy import QQ
        >>> QQ.old_poly_ring(x).ideal(x**2)
        <x**2>
        i˙˙˙˙(   t   ModuleImplementedIdeali   (   t   sympy.polys.agca.idealsR!   R    t	   submodule(   R   t   gensR!   t   x(    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   idealQ   s    	c         C  sN   d d l  m } d d l m } t | |  sA |  j |   } n  | |  |  S(   sÖ  
        Form a quotient ring of ``self``.

        Here ``e`` can be an ideal or an iterable.

        >>> from sympy.abc import x
        >>> from sympy import QQ
        >>> QQ.old_poly_ring(x).quotient_ring(QQ.old_poly_ring(x).ideal(x**2))
        QQ[x]/<x**2>
        >>> QQ.old_poly_ring(x).quotient_ring([x**2])
        QQ[x]/<x**2>

        The division operator has been overloaded for this:

        >>> QQ.old_poly_ring(x)/[x**2]
        QQ[x]/<x**2>
        i˙˙˙˙(   t   Ideal(   t   QuotientRing(   R"   R'   t    sympy.polys.domains.quotientringR(   t
   isinstanceR&   (   R   t   eR'   R(   (    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   quotient_ring^   s
    c         C  s   |  j  |  S(   N(   R,   (   R   R+   (    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   __div__v   s    (   t   __name__t
   __module__t   __doc__R   t   is_RingR	   R   R   R   R   R   R   R   R   R   R    R&   R,   R-   t   __truediv__(    (    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyR   
   s"   															N(   R0   t
   __future__R    R   t   sympy.polys.domains.domainR   t   sympy.polys.polyerrorsR   R   R   t   sympy.utilitiesR   R   (    (    (    s7   lib/python2.7/site-packages/sympy/polys/domains/ring.pyt   <module>   s   