[GiNaC-list] non-commutative symbols (again)

Jan jrheinlaender at gmx.de
Sat Feb 19 11:12:09 CET 2011


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,

More information about the GiNaC-list mailing list