
    Ed]                     ^    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
dS )	    )Indexed)Tuple)Dummy)sympify)Integralc                   >     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                               |          \  }}t          |          }|                    |          }t	          j        | |g|R i |}||_        d |                                D             |_        |S )Nc                     i | ]\  }}||	S  r   ).0keyvals      ?lib/python3.11/site-packages/sympy/sandbox/indexed_integrals.py
<dictcomp>z+IndexedIntegral.__new__.<locals>.<dictcomp>/   s    $K$K$K(#sS#$K$K$K    )	r	   _indexed_process_limitsr   xreplacer   __new___indexed_replitems_indexed_reverse_repl)clsfunctionlimitsassumptionsreplobjs         r   r   zIndexedIntegral.__new__)   s    &>>vFFf8$$$$T**sHEvEEEEE $K$Kdjjll$K$K$K!
r   c                 x    t                                                      }|                    | j                  S )N)superdoitr   r   )selfres	__class__s     r   r!   zIndexedIntegral.doit2   s)    ggllnn||D6777r   c                 `   i }g }| D ]}t          |t          t          t          f          r|d         }|dd          }n|}d}t          |t                    r?||vr!t          t          |                    }|||<   |                    |f|z              |                    |           ||fS )Nr      r   )
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2 aD!""!W%% $D=  c!ffADG  !e,,,,  ####Yr   )	__name__
__module____qualname____doc__r   r!   staticmethodr   __classcell__)r$   s   @r   r	   r	      sm         @  8 8 8 8 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   