(mul)
Remove Identities from a MatMul

    This is a modified version of sympy.strategies.rm_id.
    This is necesssary because MatMul may contain both MatrixExprs and Exprs
    as args.

    See Also
    --------
        sympy.strategies.rm_id
Remove Identities from a MatMul
Remove Identities from a MatMul
def remove_ids(mul):
    """ Remove Identities from a MatMul

    This is a modified version of sympy.strategies.rm_id.
    This is necesssary because MatMul may contain both MatrixExprs and Exprs
    as args.

    See Also
    --------
        sympy.strategies.rm_id
    """
    # Separate Exprs from MatrixExprs in args
    factor, mmul = mul.as_coeff_mmul()
    # Apply standard rm_id for MatMuls
    result = rm_id(lambda x: x.is_Identity is True)(mmul)
    if result != mmul:
        return newmul(factor, *result.args)  # Recombine and return
    else:
        return mul
def remove_ids ( mul ) : # Separate Exprs from MatrixExprs in args factor , mmul = mul . as_coeff_mmul ( ) # Apply standard rm_id for MatMuls result = rm_id ( lambda x : x . is_Identity is True ) ( mmul ) if result != mmul : return newmul ( factor , * result . args ) # Recombine and return else : return mul