OK, sounds great. Now a follow on....or two... * How can I get the non-commuting part of the Mul? I see that Mul.flatten knows about it, but I don't see how to get it back.
* I then need to take an expression, find all the instances of Mul in the tree and replace those by something else, one by one. Is there a simple way of doing this? the most common usage case that I will have is a sum of terms; 3*A*B*|state1> + 4*C*D*|state> Thanks!!! Brian On Mon, Nov 10, 2008 at 1:08 PM, Ondrej Certik <[EMAIL PROTECTED]> wrote: > > On Mon, Nov 10, 2008 at 9:57 PM, Brian Granger <[EMAIL PROTECTED]> wrote: >> >> This is what I was afraid of. The problem is that the __mul__ that I >> need to get rid of is on Basic, which all my classes inherit from. I >> will probably just write a function that takes the flattened args of >> the final Mul class and "do the right thing" > > Exactly, that's the way to go, because we want to be able to > manipulate with the state in this form as well: > > A*B*C*D*|n> > > and optionally convert it to the form: > > E*|m> > > So the only way is to let sympy handle the multiplication (i.e. > associative but not commutative) and then apply our own function to > actually simplify it. > > Ondrej > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---
