[GiNaC-devel] Creating non-commutative symbols

Jan jrheinlaender at gmx.de
Wed Feb 16 08:46:56 CET 2011


Hello Alexei,

maybe I should explain why I need non-commutative symbols. Without them,
this code:

#include <ginac/ginac.h>

using namespace GiNaC;

int main() {
  symbol M1("M1");

  symbol x("x"), y("y");
  matrix M2(2,2);
  M2 = x, 0, y, 0;

  matrix M3(2,2);
  M3 = 0, x, x, 0;

  symbol M4("M3");

  ex nc;
  nc = M1 * M4;
  nc = nc.subs(M1 == M2);
  nc = nc.subs(M4 == M3);
  nc.evalm();
}

throws 
matrix::mul_scalar(): non-commutative scalar

Is that the expected behaviour?

> 2. The patch is a bit mathematically inconsistent:
>    - Non-commutative realsymbol and possymbol hardly make any sense.
>    - symbol::domain() still says domain::complex. This is very confusing.
>      Non-commutative complex numbers? What's that?
sorry, I am a mechanical engineer :-)

> All in all, just because making symbols non-commutative is technically
> possible doesn't mean it's a good idea. If you really need something
> like a non-commutative symbol, it's much safer (and in fact easier) to
> write a proper class (which inherits from basic).
OK, I will do that. But if I read your other explanations correctly,
even a separate class will not really solve the problem I described
above?

Best regards,
	Jan





More information about the GiNaC-devel mailing list