consider the sympy expressions -
a = a_1*e_1+...+a_n*e_n
b = b_1*e_1+...+b_n*e_n
where the a_i's and the b_i's are commutative sympy expressions and the
e_i's are non-commutative symbols and you have a dictionary
mul_dict = {e_i*e_j: f(e_i,e_j)}
if mul_dict is fully populated then
a*b = (a*b).subs(mul_dict)
However many of the entries in the dictionary will never be used since
most of
the a_i's and b_i's will be zero, but you don't know which ones ahead of
the multiplication.
Likewise the function f(e_i,e_j) is know but time consuming to evaluate.
Is there a way to do a subsitution in a sympy expression where if
e_i*e_j is a key subs will use
the dictionary, but is e_i*e_j is not a key f(e_i,e_j) will be
evaluated, added to the dictionary, and
the substitution performed?
--
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?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.