Hi!

while using the Indexed class from sympy.tensor I have run into the 
following problem:

cse(...) fails for expressions having "Indexed" instances. They are not 
handled correctly in opt_cse() in cse_main.py
A possible work-around is to substitute the Indexed instances with dummies, 
perform the CSE elimination and then
resubstitute the dummies for the indexed symbols. But this is not pretty 
and I think that cse(...) should handle this
on its own.

Example:

    from sympy import *

    len_y = 5
    y = IndexedBase('y', shape=(len_y,))
    x = IndexedBase('x', shape=(len_y,))
    Dy = IndexedBase('Dy', shape=(len_y-1,))
    i = Idx('i', len_y-1)

    expr1 = (y[i+1]-y[i])/(x[i+1]-x[i])
    expr2 = 1/(x[i+1]-x[i])
    print(cse([expr1, expr2]))

this will cause an infinite recursive call stack to _find_opts raising:
    RuntimeError: maximum recursion depth exceeded in __instancecheck__


Does anybody know what the best approach here would be? Add something to 
the Indexed class or modify
opt_cse?

Best regards
/Björn

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to