ó
¡¼™\c           @  s´   d  Z  d d l m Z m Z d d l m Z d d l m Z d d l m	 Z	 d d l
 m Z d d l m Z m Z m Z m Z d d l m Z e d	 e e e	 f d
 „  ƒ  Yƒ Z d S(   s1   Implementation of :class:`AlgebraicField` class. iÿÿÿÿ(   t   print_functiont   division(   t   CharacteristicZero(   t   Field(   t   SimpleDomain(   t   ANP(   t   CoercionFailedt   DomainErrort   NotAlgebraict   IsomorphismFailed(   t   publict   AlgebraicFieldc           B  sä   e  Z d  Z e Z e Z Z e Z e	 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 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s2   A class for representing algebraic number fields. c         G  sâ   | j  s t d ƒ ‚ n  d d l m } | |  _ | | ƒ |  _ |  j j j |  _ | |  _	 |  _
 d |  _ |  j f |  _ |  _ |  | d ƒ | d ƒ g ƒ |  _ |  j j |  j j | ƒ |  _ |  j j |  j j | ƒ |  _ d  S(   Ns&   ground domain must be a rational fieldiÿÿÿÿ(   t   to_number_fieldi   i    (   t   is_QQR   t   sympy.polys.numberfieldsR   t   orig_extt   extt   minpolyt   rept   modt   domaint   domt   ngenst   symbolst   genst   unitt   dtypet   zerot   one(   t   selfR   R   R   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   __init__   s    			!c         C  s   |  j  | |  j j |  j ƒ S(   N(   R   R   R   R   (   R   t   element(    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   new*   s    c         C  s"   t  |  j ƒ d t  |  j ƒ d S(   Nt   <t   >(   t   strR   R   (   R   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   __str__-   s    c         C  s%   t  |  j j |  j |  j |  j f ƒ S(   N(   t   hasht	   __class__t   __name__R   R   R   (   R   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   __hash__0   s    c         C  s1   t  | t ƒ o0 |  j | j k o0 |  j | j k S(   s0   Returns ``True`` if two domains are equivalent. (   t
   isinstanceR   R   R   (   R   t   other(    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   __eq__3   s    c         G  s   t  |  j |  j f | Œ S(   s?   Returns an algebraic field, i.e. `\mathbb{Q}(\alpha, \ldots)`. (   R   R   R   (   R   t	   extension(    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   algebraic_field8   s    c         C  s&   d d l  m } | |  j | ƒ j ƒ  S(   s!   Convert ``a`` to a SymPy object. iÿÿÿÿ(   t   AlgebraicNumber(   R   R.   R   t   as_expr(   R   t   aR.   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   to_sympy<   s    c         C  s•   y |  |  j  j | ƒ g ƒ SWn t k
 r0 n Xd d l m } y  |  | | |  j ƒ j ƒ  ƒ SWn- t t f k
 r t d | |  f ƒ ‚ n Xd S(   s)   Convert SymPy's expression to ``dtype``. iÿÿÿÿ(   R   s(   %s is not a valid algebraic number in %sN(	   R   t
   from_sympyR   R   R   R   t   native_coeffsR   R	   (   R   R0   R   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyR2   A   s     c         C  s   |  |  j  j | | ƒ ƒ S(   s.   Convert a Python ``int`` object to ``dtype``. (   R   t   convert(   t   K1R0   t   K0(    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   from_ZZ_pythonP   s    c         C  s   |  |  j  j | | ƒ ƒ S(   s3   Convert a Python ``Fraction`` object to ``dtype``. (   R   R4   (   R5   R0   R6   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   from_QQ_pythonT   s    c         C  s   |  |  j  j | | ƒ ƒ S(   s,   Convert a GMPY ``mpz`` object to ``dtype``. (   R   R4   (   R5   R0   R6   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   from_ZZ_gmpyX   s    c         C  s   |  |  j  j | | ƒ ƒ S(   s,   Convert a GMPY ``mpq`` object to ``dtype``. (   R   R4   (   R5   R0   R6   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   from_QQ_gmpy\   s    c         C  s   |  |  j  j | | ƒ ƒ S(   s.   Convert a mpmath ``mpf`` object to ``dtype``. (   R   R4   (   R5   R0   R6   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   from_RealField`   s    c         C  s   t  d |  ƒ ‚ d S(   s)   Returns a ring associated with ``self``. s#   there is no ring associated with %sN(   R   (   R   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   get_ringd   s    c         C  s   |  j  j | j ƒ  ƒ S(   s#   Returns True if ``a`` is positive. (   R   t   is_positivet   LC(   R   R0   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyR=   h   s    c         C  s   |  j  j | j ƒ  ƒ S(   s#   Returns True if ``a`` is negative. (   R   t   is_negativeR>   (   R   R0   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyR?   l   s    c         C  s   |  j  j | j ƒ  ƒ S(   s'   Returns True if ``a`` is non-positive. (   R   t   is_nonpositiveR>   (   R   R0   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyR@   p   s    c         C  s   |  j  j | j ƒ  ƒ S(   s'   Returns True if ``a`` is non-negative. (   R   t   is_nonnegativeR>   (   R   R0   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyRA   t   s    c         C  s   | S(   s   Returns numerator of ``a``. (    (   R   R0   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   numerx   s    c         C  s   |  j  S(   s   Returns denominator of ``a``. (   R   (   R   R0   (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   denom|   s    (    R'   t
   __module__t   __doc__R   R   t   Truet   is_AlgebraicFieldt   is_Algebraict   is_Numericalt   Falset   has_assoc_Ringt   has_assoc_FieldR   R    R$   R(   R+   R-   R1   R2   R7   R8   R9   R:   R;   R<   R=   R?   R@   RA   RB   RC   (    (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyR      s4   
																			N(   RE   t
   __future__R    R   t&   sympy.polys.domains.characteristiczeroR   t   sympy.polys.domains.fieldR   t    sympy.polys.domains.simpledomainR   t   sympy.polys.polyclassesR   t   sympy.polys.polyerrorsR   R   R   R	   t   sympy.utilitiesR
   R   (    (    (    sA   lib/python2.7/site-packages/sympy/polys/domains/algebraicfield.pyt   <module>   s   "