o
    oÇh]  ã                   @   sP   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„ de	ƒZ
dS )	é    )ÚIndexed)ÚTuple)ÚDummy)Úsympify)ÚIntegralc                       s4   e Zd ZdZdd„ Z‡ fdd„Zedd„ ƒZ‡  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                 O   sX   t  |¡\}}t|ƒ}| |¡}tj| |g|¢R i |¤Ž}||_dd„ | ¡ D ƒ|_|S )Nc                 S   s   i | ]\}}||“qS © r   )Ú.0ÚkeyÚvalr   r   ús/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/sandbox/indexed_integrals.pyÚ
<dictcomp>/   s    z+IndexedIntegral.__new__.<locals>.<dictcomp>)	r   Ú_indexed_process_limitsr   Úxreplacer   Ú__new__Ú_indexed_replÚitemsÚ_indexed_reverse_repl)ÚclsÚfunctionÚlimitsÚassumptionsÚreplÚobjr   r   r   r   )   s   
zIndexedIntegral.__new__c                    s   t ƒ  ¡ }| | j¡S )N)ÚsuperÚdoitr   r   )ÚselfÚres©Ú	__class__r   r   r   2   s   
zIndexedIntegral.doitc                 C   sŠ   i }g }| D ]:}t |tttfƒr|d }|dd … }n|}d}t |tƒr;||vr2tt|ƒƒ}|||< | |f| ¡ q| |¡ q||fS )Nr   é   r   )Ú
isinstanceÚtupleÚlistr   r   r   ÚstrÚappend)r   r   Ú	newlimitsÚiÚvÚvrestÚrr   r   r   r   6   s   
z'IndexedIntegral._indexed_process_limits)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ústaticmethodr   Ú__classcell__r   r   r   r   r      s     	r   N)Úsympy.tensorr   Úsympy.core.containersr   Úsympy.core.symbolr   Úsympy.core.sympifyr   Úsympy.integrals.integralsr   r   r   r   r   r   Ú<module>   s    