[GiNaC-devel] Creating non-commutative symbols

Jan jrheinlaender at gmx.de
Tue Feb 15 16:17:04 CET 2011


Hi Alexei,

would you accept this patch to make creation of non-commutative symbols
easier?

Problem:
The GiNaC info documentation claims:

"Both symbols and user-defined functions can be specified as being non-commutative"

Currently this is only possible by defining a new subclass of symbol and
overloading return_type().

Solution:
Added unsigned rtype to class symbol
Overloaded return_type()
Modified constructors (including realsymbol and possymbol), printing and
archiving accordingly

------------
Now my next question is (after applying the above patch) whether there
is a bug in ncmul::eval(). I created this test program

#include <ginac/ginac.h>

using namespace GiNaC;

int main() {
  symbol M1("M1", "M1", return_types::noncommutative);

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

  symbol M3("M3", "M3", return_types::noncommutative);

  ex nc;
  nc = M1 * M2; // Produces a mul !!
  nc = M1 * M1; // Produces a ncmul
  nc = M1 * M3; // Produces a ncmul
  nc = nc.subs(M1 == M2); // Produces a mul !!
}

As you can see, the assignment sometimes creates a mul when a ncmul
should be created.

Best regards,
	Jan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: symbol.patch
Type: text/x-patch
Size: 5129 bytes
Desc: not available
URL: <http://www.cebix.net/pipermail/ginac-devel/attachments/20110215/211f930f/attachment.patch>


More information about the GiNaC-devel mailing list