ó
”¼\c           @   sL   d  d l  m Z d  d l m Z m Z m Z m Z d e f d     YZ d S(   i’’’’(   t   Indexed(   t   Integralt   Dummyt   sympifyt   Tuplet   IndexedIntegralc           B   s/   e  Z d  Z d   Z d   Z e d    Z RS(   s/  
    Experimental class to test integration by indexed variables.

    Usage is analogue to ``Integral``, it simply adds awareness of
    integration over indices.

    Contraction of non-identical index symbols referring to the same
    ``IndexedBase`` is not yet supported.

    Examples
    ========

    >>> from sympy.sandbox.indexed_integrals import IndexedIntegral
    >>> from sympy import IndexedBase, symbols
    >>> A = IndexedBase('A')
    >>> i, j = symbols('i j', integer=True)
    >>> ii = IndexedIntegral(A[i], A[i])
    >>> ii
    Integral(_A[i], _A[i])
    >>> ii.doit()
    A[i]**2/2

    If the indices are different, indexed objects are considered to be
    different variables:

    >>> i2 = IndexedIntegral(A[j], A[i])
    >>> i2
    Integral(A[j], _A[i])
    >>> i2.doit()
    A[i]*A[j]
    c         O   st   t  j |  \ } } t |  } | j |  } t j |  | | |  } | | _ t d   | j   D  | _	 | S(   Nc         s   s!   |  ] \ } } | | f Vq d  S(   N(    (   t   .0t   keyt   val(    (    s>   lib/python2.7/site-packages/sympy/sandbox/indexed_integrals.pys	   <genexpr>,   s    (
   R   t   _indexed_process_limitsR   t   xreplaceR   t   __new__t   _indexed_replt   dictt   itemst   _indexed_reverse_repl(   t   clst   functiont   limitst   assumptionst   replt   obj(    (    s>   lib/python2.7/site-packages/sympy/sandbox/indexed_integrals.pyR   &   s    	c         C   s%   t  t |   j   } | j |  j  S(   N(   t   superR   t   doitR
   R   (   t   selft   res(    (    s>   lib/python2.7/site-packages/sympy/sandbox/indexed_integrals.pyR   /   s    c         C   sĄ   i  } g  } x§ |  D] } t  | t t t f  rH | d } | d } n | } d } t  | t  r„ | | k r t t |   } | | | <n  | j | f |  q | j |  q W| | f S(   Ni    i   (    (   t
   isinstancet   tuplet   listR   R    R   t   strt   append(   R   R   t	   newlimitst   it   vt   vrestt   r(    (    s>   lib/python2.7/site-packages/sympy/sandbox/indexed_integrals.pyR	   3   s    
(   t   __name__t
   __module__t   __doc__R   R   t   staticmethodR	   (    (    (    s>   lib/python2.7/site-packages/sympy/sandbox/indexed_integrals.pyR      s   			N(   t   sympy.tensorR    t   sympyR   R   R   R   R   (    (    (    s>   lib/python2.7/site-packages/sympy/sandbox/indexed_integrals.pyt   <module>   s   "