Hi, it seems that the following lines ex e1 = indexed(t,i); e1.subs(indexed(t,idx(i_,3))==idx(i_,3).get_value()*indexed(t,idx(i_,3))); ,where i and i_ are idx and wildcard objects respectively, doesn't substitute t.i with i*t.i. t.i still remains it's original form. Is there any way I can do such subs: t.i-->i*t.i? Thank you. Yong
Hi! On Thu, Jul 10, 2003 at 05:11:01PM +0800, Yong Xiao wrote:
Hi, it seems that the following lines ex e1 = indexed(t,i); e1.subs(indexed(t,idx(i_,3))==idx(i_,3).get_value()*indexed(t,idx(i_,3))); ,where i and i_ are idx and wildcard objects respectively, doesn't substitute t.i with i*t.i.
Hm? This works for me: symbol t("t"); idx i(symbol("i"), 3); ex e1 = indexed(t, i); ex i_ = wild(); ex e2 = e1.subs(indexed(t, idx(i_, 3)) == i_ * indexed(t, idx(i_, 3))); cout << e1 << " -> " << e2 << endl; // prints "t.i -> i*t.i" Perhaps you forgot that subs() returns its result as a new expression? Bye, Christian -- / Physics is an algorithm \/ http://www.uni-mainz.de/~bauec002/
Hm? This works for me:
symbol t("t"); idx i(symbol("i"), 3); ex e1 = indexed(t, i); ex i_ = wild(); ex e2 = e1.subs(indexed(t, idx(i_, 3)) == i_ * indexed(t, idx(i_, 3))); cout << e1 << " -> " << e2 << endl; // prints "t.i -> i*t.i"
Perhaps you forgot that subs() returns its result as a new expression? Oh, yes. It's really stupid that I forgot this. Thank you much. :-)
Yong
participants (2)
-
Christian Bauer
-
Yong Xiao