(expr, index)
return func(*terms)
Expand the first Add containing a simple KroneckerDelta.
Expand the first Add containing a simple KroneckerDelta.
Expand the first Add containing a simple KroneckerDelta .
def _expand_delta(expr, index):
    """
    Expand the first Add containing a simple KroneckerDelta.
    """
    if not expr.is_Mul:
        return expr
    delta = None
    func = Add
    terms = [S(1)]
    for h in expr.args:
        if delta is None and h.is_Add and _has_simple_delta(h, index):
            delta = True
            func = h.func
            terms = [terms[0]*t for t in h.args]
        else:
            terms = [t*h for t in terms]
    return func(*terms)
def _expand_delta ( expr , index ) : if not expr . is_Mul : return expr delta = None func = Add terms = [ S ( 1 ) ] for h in expr . args : if delta is None and h . is_Add and _has_simple_delta ( h , index ) : delta = True func = h . func terms = [ terms [ 0 ] * t for t in h . args ] else : terms = [ t * h for t in terms ] return func ( * terms )