ó
¡¼™\c           @   sì   d  d l  m Z m 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 m Z m Z m Z d  d l m Z d e f d „  ƒ  YZ d	 e e f d
 „  ƒ  YZ d e e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   simplifyt   trigsimp(   t   call_highest_priorityt
   _sympifyit(   t	   StdFactKB(   t   factort   difft   Integral(   t   St   Addt   Mult	   count_ops(   t   Exprt   BasisDependentc           B   sâ  e  Z d  Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d	 e	 ƒ e d
 ƒ d „  ƒ ƒ Z
 e d	 e	 ƒ e d ƒ d „  ƒ ƒ Z d „  Z e d	 e	 ƒ e d ƒ d „  ƒ ƒ Z e d ƒ d „  ƒ Z e Z e Z d! d „ Z e j e j j 7_ e Z d e e e d „ Z e j e j 7_ d „  Z e j e j 7_ d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  e  j e! j 7_ e d „ Z" d „  Z# d „  Z$ e$ j e% j 7_ d  „  Z& RS("   sÒ   
    Super class containing functionality common to vectors and
    dyadics.
    Named so because the representation of these quantities in
    sympy.vector is dependent on the basis they are expressed in.
    t   __radd__c         C   s   |  j  |  | ƒ S(   N(   t	   _add_func(   t   selft   other(    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   __add__   s    R   c         C   s   |  j  | |  ƒ S(   N(   R   (   R   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR      s    t   __rsub__c         C   s   |  j  |  | ƒ S(   N(   R   (   R   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   __sub__   s    R   c         C   s   |  j  | |  ƒ S(   N(   R   (   R   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR      s    R   t   __rmul__c         C   s   |  j  |  | ƒ S(   N(   t	   _mul_func(   R   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   __mul__!   s    R   c         C   s   |  j  | |  ƒ S(   N(   R   (   R   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR   &   s    c         C   s   |  j  t d ƒ |  ƒ S(   Niÿÿÿÿ(   R   R   (   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   __neg__+   s    t   __rdiv__c         C   s   |  j  | ƒ S(   N(   t   _div_helper(   R   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   __div__.   s    R   c         C   s
   t  d ƒ S(   Ns   Invalid divisor for division(   t	   TypeError(   R   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR   3   s    c         K   sG   |  j  } x7 |  j j ƒ  D]& \ } } | | j | |  | 7} q W| S(   s…   
        Implements the SymPy evalf routine for this quantity.

        evalf's documentation
        =====================

        (   t   zerot
   componentst   itemst   evalf(   R   t   prect   optionst   vect   kt   v(    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR    :   s    	g333333û?c         C   sW   g  |  j  j ƒ  D]4 \ } } t | d | d | d | d | ƒ| ^ q } |  j | Œ  S(   sŽ   
        Implements the SymPy simplify routine for this quantity.

        simplify's documentation
        ========================

        t   ratiot   measuret   rationalt   inverse(   R   R   t   simpR   (   R   R&   R'   R(   R)   R$   R%   t   simp_components(    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR    K   s    Gc         K   sB   g  |  j  j ƒ  D] \ } } t | |  | ^ q } |  j | Œ  S(   s   
        Implements the SymPy trigsimp routine, for this quantity.

        trigsimp's documentation
        ========================

        (   R   R   t   tsimpR   (   R   t   optsR$   R%   t   trig_components(    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR   Z   s    2c      	   C   s"   |  j  d | d | d | d | ƒ S(   NR&   R'   R(   R)   (   R    (   R   R&   R'   R(   R)   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   _eval_simplifyh   s    c         K   s   |  j  |   S(   N(   R   (   R   R-   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   _eval_trigsimpk   s    c         C   s   |  j  | ƒ S(   N(   R   (   R   t   wrt(    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   _eval_derivativen   s    c         O   sE   g  |  j  j ƒ  D]" \ } } t | | | Ž | ^ q } |  j | Œ  S(   N(   R   R   R   R   (   R   t   symbolst   assumptionsR$   R%   t   integral_components(    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   _eval_Integralq   s    5c         C   s   |  t  j f S(   s‚   
        Returns the expression as a tuple wrt the following
        transformation -

        expression -> a/b -> a, b

        (   R   t   One(   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   as_numer_denomv   s    c         O   sE   g  |  j  j ƒ  D]" \ } } t | | | Ž | ^ q } |  j | Œ  S(   sµ   
        Implements the SymPy factor routine, on the scalar parts
        of a basis-dependent expression.

        factor's documentation
        ========================

        (   R   R   t   fctrR   (   R   t   argst   kwargsR$   R%   t   fctr_components(    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR   €   s    	5c         C   s   t  d ƒ |  f S(   s2   Efficiently extract the coefficient of a product. i   (   R   (   R   R(   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   as_coeff_Mul   s    c         G   s7   g  |  j  D] } | |  j  | ^ q
 } d t | ƒ f S(   s4   Efficiently extract the coefficient of a summation. i    (   R   t   tuple(   R   t   depst   xt   l(    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   as_coeff_add“   s    'c         O   st   x, | D]$ } t  | t ƒ r t d ƒ ‚ q q Wg  |  j j ƒ  D]" \ } } t | | | Ž | ^ q? } |  j | Œ  S(   s   
        Implements the SymPy diff routine, for vectors.

        diff's documentation
        ========================

        s   Invalid arg for differentiation(   t
   isinstanceR   R   R   R   t   dfR   (   R   R:   R;   R@   R$   R%   t   diff_components(    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR   ˜   s    5c         K   s=   g  |  j  D]  } |  j  | j |   | ^ q
 } |  j | Œ  S(   s(   Calls .doit() on each term in the Dyadic(   R   t   doitR   (   R   t   hintsR@   t   doit_components(    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyRF   ©   s    -N('   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   t   NotImplementedR   R   R   R   R   t   __truediv__t   __rtruediv__t   NoneR    R   t   nR   t   FalseR    R*   R   R,   R/   R0   R2   R6   R8   R   R9   R=   RB   R   RD   RF   (    (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR   	   sD   							
			t   BasisDependentAddc           B   s    e  Z d  Z d „  Z e j Z RS(   st   
    Denotes sum of basis dependent quantities such that they cannot
    be expressed as base or Mul instances.
    c         O   së  i  } xé t  | ƒ D]Û \ } } t | |  j ƒ s’ t | t ƒ rU |  j | j Œ  } q’ t | t ƒ ry |  j | j Œ  } q’ t t	 | ƒ d ƒ ‚ n  | |  j
 k r§ q n  t | d ƒ r x5 | j D]' } | j | d ƒ | j | | | <qÀ Wq q Wt | j ƒ  ƒ } x( | D]  } | | d k r| | =qqWt | ƒ d k rH|  j
 Sg  | D] } | | | ^ qO} t t |  ƒ j |  | | Ž }	 t |	 t ƒ r¦|  j |	 j Œ  Si t d 6}
 t |
 ƒ |	 _ | |	 _ t | j ƒ  ƒ d j |	 _ |	 S(   Ns     cannot be interpreted correctlyR   i    t   commutative(   t	   enumerateRC   t
   _expr_typeR
   R   R:   R	   R   R   t   strR   t   hasattrR   t   gett   listt   keyst   lent   superRR   t   __new__t   TrueR   t   _assumptionst   _componentst   _sys(   t   clsR:   R"   R   t   it   argR@   t   tempt   newargst   objR4   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR]   ¶   s<    ,!	(   RI   RJ   RK   R]   R	   t   __init__(    (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyRR   °   s   	+t   BasisDependentMulc           B   s8   e  Z d  Z d „  Z e j Z d d „ Z e Z e Z	 RS(   sJ   
    Denotes product of base- basis dependent quantity with a scalar.
    c         O   sN  d d l  m } m } m } m } d } t d ƒ } t }	 g  }
 xæ | D]Þ } t | |  j ƒ rr | d 7} t	 }	 qG | t d ƒ k r t	 }	 qG t | |  j
 |  j f ƒ rË | d 7} | j } | | j 9} qG t | |  j ƒ rð | d 7} | } qG t | | | | | f ƒ r|
 j | ƒ qG | | 9} qG W| d k rDt d ƒ ‚ n | d k r]t | | Ž  S|	 rj|  j St | |  j ƒ r±g  | j D] } |  j | | ƒ ^ q†} |  j | Œ  St t |  ƒ j |  | | j |
 | Ž } t | t ƒ r÷|  j | j Œ  S| j | _ | | _ i t	 d 6} t | ƒ | _ i | | j 6| _ | j j | _ | S(   Niÿÿÿÿ(   t   Crosst   Dott   Curlt   Gradienti    i   s   Invalid multiplicationRS   (   t   sympy.vectorRj   Rk   Rl   Rm   R   RQ   RC   t
   _zero_funcR^   t
   _base_funcR   t   _base_instancet   _measure_numberR   t   appendt
   ValueErrorR
   R   R:   R\   Ri   R]   R	   R   R_   R`   Ra   (   Rb   R:   R"   Rj   Rk   Rl   Rm   t   countt   measure_numbert   zeroflagt
   extra_argsRd   t   exprR@   Rf   Rg   R4   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR]   é   sX    "
		
	
	%		c         C   s\   |  j  j ƒ  } d | k s3 d | k s3 d | k rD d | d } n  | d |  j j | ƒ S(   Nt   (t   -t   +t   )t   *(   Rr   t   __str__Rq   (   R   t   printert   measure_str(    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR   %  s
    N(
   RI   RJ   RK   R]   R
   Rh   RO   R   t   __repr__t	   _sympystr(    (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyRi   ä   s   	:	t   BasisDependentZeroc           B   s¿   e  Z d  Z i  Z d „  Z d „  Z e d ƒ d „  ƒ Z e Z e d ƒ d „  ƒ Z	 e d ƒ d „  ƒ Z
 e d	 ƒ d
 „  ƒ Z e d ƒ d „  ƒ Z d „  Z d „  Z d d „ Z e Z e Z RS(   s:   
    Class to denote a zero basis dependent instance.
    c         C   s=   t  t |  ƒ j |  ƒ } t t d ƒ |  g ƒ j ƒ  | _ | S(   Ni    (   R\   R„   R]   R>   R   t   __hash__t   _hash(   Rb   Rg   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR]   6  s    !c         C   s   |  j  S(   N(   R†   (   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR…   =  s    t   __req__c         C   s   t  | |  j ƒ S(   N(   RC   Ro   (   R   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   __eq__@  s    R   c         C   s&   t  | |  j ƒ r | St d ƒ ‚ d  S(   Ns#   Invalid argument types for addition(   RC   RU   R   (   R   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR   F  s    R   c         C   s&   t  | |  j ƒ r | St d ƒ ‚ d  S(   Ns#   Invalid argument types for addition(   RC   RU   R   (   R   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR   M  s    R   c         C   s'   t  | |  j ƒ r | St d ƒ ‚ d  S(   Ns&   Invalid argument types for subtraction(   RC   RU   R   (   R   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR   T  s    R   c         C   s&   t  | |  j ƒ r | St d ƒ ‚ d  S(   Ns&   Invalid argument types for subtraction(   RC   RU   R   (   R   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR   [  s    c         C   s   |  S(   N(    (   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR   b  s    c         C   s   |  S(   s@   
        Returns the normalized version of this vector.
        (    (   R   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt	   normalizee  s    c         C   s   d S(   Nt   0(    (   R   R€   (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR   k  s    N(   RI   RJ   RK   R   R]   R…   R   Rˆ   R‡   R   R   R   R   R   R‰   RO   R   R‚   Rƒ   (    (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyR„   0  s   				N(   t   sympy.simplifyR    R*   R   R,   t   sympy.core.decoratorsR   R   t   sympy.core.assumptionsR   t   sympyR   R9   R   RD   R   t
   sympy.coreR   R	   R
   R   t   sympy.core.exprR   R   RR   Ri   R„   (    (    (    s:   lib/python2.7/site-packages/sympy/vector/basisdependent.pyt   <module>   s   "§4L