On Mon, Nov 10, 2008 at 8:16 PM, Brian Granger <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> By default, Python's * operator work in L->R order, so:
>
> a*b*c*d = ((a*b)*c)*d
>
> But, I am implementing some operators from quantum mechanics that I
> want to apply like this:
>
> a*b*c*d = a*(b*(c*d))
>
> I
On Mon, Nov 10, 2008 at 8:31 PM, Ondrej Certik <[EMAIL PROTECTED]> wrote:
> On Mon, Nov 10, 2008 at 8:16 PM, Brian Granger <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
>>
>> By default, Python's * operator work in L->R order, so:
>>
>> a*b*c*d = ((a*b)*c)*d
>>
>> But, I am implementing some operators from
> Could you please elaborate? What you want is a noncommutative
> *nonassociative* algebra. As far as I know, everything in quantum
> mechanics is at least associative.
Sure, everything in my case is associative. But in practice, it is
easier to do the multiplications in a certain order. I end
On Mon, Nov 10, 2008 at 13:16, Brian Granger <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> By default, Python's * operator work in L->R order, so:
>
> a*b*c*d = ((a*b)*c)*d
>
> But, I am implementing some operators from quantum mechanics that I
> want to apply like this:
>
> a*b*c*d = a*(b*(c*d))
>
> Is
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"
Cheers,
Brian
On Mon, Nov 10, 2008 at 12:
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 f
OK, sounds great. Now a follow onor 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 b
Never mind, I figured this out myself:
On Mon, Nov 10, 2008 at 1:15 PM, Brian Granger <[EMAIL PROTECTED]> wrote:
> OK, sounds great. Now a follow onor 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.
On Mon, Nov 10, 2008 at 10:15 PM, Brian Granger <[EMAIL PROTECTED]> wrote:
>
> OK, sounds great. Now a follow onor 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.
You need to do something like:
[p fo
On Mon, Nov 10, 2008 at 10:46 PM, Brian Granger <[EMAIL PROTECTED]> wrote:
>
> Never mind, I figured this out myself:
>
> On Mon, Nov 10, 2008 at 1:15 PM, Brian Granger <[EMAIL PROTECTED]> wrote:
>> OK, sounds great. Now a follow onor two...
>>
>> * How can I get the non-commuting part of the
10 matches
Mail list logo