Hello, I'm afraid the logic of this is still beyond me (yes, it might be my mathematical ignorance). I created a class ncsymbol derived from basic (by copying the GinaC symbol class and overloading return_type()) Now I have the following test program --------------- #include <ginac/ginac.h> #include "ncsymbol.h" using namespace GiNaC; int main() { ncsymbol s1("s1", "s1"); symbol x("x"), y("y"); matrix M1(2,2); M1 = x, 0, y, 0; matrix M2(2,2); M2 = 0, x, x, 0; ncsymbol s2("s2"); ex nc; nc = s1 * s2; // Produces a ncmul nc = nc.subs(s1 == M1); // Produces a mul !! nc = M2 * M3; // Produces a ncmul nc = s1 * M2; // Produces a mul !! } ------------------------ 1. Why does replacing a non-commutative object with another non-commutative object result in the ncmul becoming a mul? 2. Why is the product of two (different) non-commutative objects a mul and not a ncmul? Thanks for any light, Jan
Hi, Jan!
1. Why does replacing a non-commutative object with another non-commutative object result in the ncmul becoming a mul? 2. Why is the product of two (different) non-commutative objects a mul and not a ncmul?
In a nutshell, non-commutative objects of the different (C++) types are assumed to commute with each other (say, Dirac matrices commute with Gell-Mann ones). One can change this behavior by overriding the return_type_tinfo() method. See the tutorial (section titled `Non-commutative objects') for more details and examples. Hope this helps, Alexei
Hi, Alexei, thank you for your detailed help.
See the tutorial (section titled `Non-commutative objects') for more details and examples. I looked at it and set the return_type() of my non-commutative symbol class to noncommutative_composite. If I understand the documentation correctly, this means that the ncsymbol does not commutate with anything. The advantage being that I can substitute it with any non-commutative object, not just with matrices.
Is that correct, or do I need to got the return_type_tinfo() way? I won't ever be substituting the ncsymbol with something commutative in my application so that shouldn't be a problem. Thanks for your help! Jan
participants (2)
-
Alexei Sheplyakov
-
Jan