
    wg]                     V    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	  G d de	      Z
y)	    )Indexed)Tuple)Dummy)sympify)Integralc                   8     e Zd ZdZd Z fdZed        Z xZS )IndexedIntegrala/  
    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                    t         j                  |      \  }}t        |      }|j                  |      }t	        j
                  | |g|i |}||_        |j                         D ci c]  \  }}||
 c}}|_        |S c c}}w N)	r	   _indexed_process_limitsr   xreplacer   __new___indexed_replitems_indexed_reverse_repl)clsfunctionlimitsassumptionsreplobjkeyvals           d/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/sympy/sandbox/indexed_integrals.pyr   zIndexedIntegral.__new__)   s    &>>vFf8$$$T*sHEvEE >Bjjl$K(#sS#X$K!
 %Ls   )Bc                 V    t         |          }|j                  | j                        S r   )superdoitr   r   )selfres	__class__s     r   r   zIndexedIntegral.doit2   s#    gln||D6677    c                    i }g }| D ]  }t        |t        t        t        f      r|d   }|dd  }n|}d}t        |t              r3||vrt        t        |            }|||<   |j                  f|z          p|j                  |        ||fS )Nr       )
isinstancetuplelistr   r   r   strappend)r   r   	newlimitsivvrestrs          r   r   z'IndexedIntegral._indexed_process_limits6   s    	 	$A!eT512aD!"!W%D=c!fADG  !e,  #	$ Yr!   )	__name__
__module____qualname____doc__r   r   staticmethodr   __classcell__)r    s   @r   r	   r	      s'    @8  r!   r	   N)sympy.tensorr   sympy.core.containersr   sympy.core.symbolr   sympy.core.sympifyr   sympy.integrals.integralsr   r	   r$   r!   r   <module>r:      s"      ' # & .@h @r!   