manpagez: man pages & more
info ginac
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.15 Non-commutative objects

GiNaC is equipped to handle certain non-commutative algebras. Three classes of non-commutative objects are built-in which are mostly of use in high energy physics:

The clifford and color classes are subclasses of indexed because the elements of these algebras usually carry indices. The matrix class is described in more detail in Matrices.

Unlike most computer algebra systems, GiNaC does not primarily provide an operator (often denoted ‘&*’) for representing inert products of arbitrary objects. Rather, non-commutativity in GiNaC is a property of the classes of objects involved, and non-commutative products are formed with the usual ‘*’ operator, as are ordinary products. GiNaC is capable of figuring out by itself which objects commutate and will group the factors by their class. Consider this example:

 
    ...
    varidx mu(symbol("mu"), 4), nu(symbol("nu"), 4);
    idx a(symbol("a"), 8), b(symbol("b"), 8);
    ex e = -dirac_gamma(mu) * (2*color_T(a)) * 8 * color_T(b) * dirac_gamma(nu);
    cout << e << endl;
     // -> -16*(gamma~mu*gamma~nu)*(T.a*T.b)
    ...

As can be seen, GiNaC pulls out the overall commutative factor ‘-16’ and groups the non-commutative factors (the gammas and the su(3) generators) together while preserving the order of factors within each class (because Clifford objects commutate with color objects). The resulting expression is a commutative product with two factors that are themselves non-commutative products (‘gamma~mu*gamma~nu’ and ‘T.a*T.b’). For clarification, parentheses are placed around the non-commutative products in the output.

Non-commutative products are internally represented by objects of the class ncmul, as opposed to commutative products which are handled by the mul class. You will normally not have to worry about this distinction, though.

The advantage of this approach is that you never have to worry about using (or forgetting to use) a special operator when constructing non-commutative expressions. Also, non-commutative products in GiNaC are more intelligent than in other computer algebra systems; they can, for example, automatically canonicalize themselves according to rules specified in the implementation of the non-commutative classes. The drawback is that to work with other than the built-in algebras you have to implement new classes yourself. Both symbols and user-defined functions can be specified as being non-commutative.

Information about the commutativity of an object or expression can be obtained with the two member functions

 
unsigned ex::return_type() const;
unsigned ex::return_type_tinfo() const;

The return_type() function returns one of three values (defined in the header file ‘flags.h’), corresponding to three categories of expressions in GiNaC:

The value returned by the return_type_tinfo() method is valid only when the return type of the expression is noncommutative. It is a value that is unique to the class of the object, but may vary every time a GiNaC program is being run (it is dynamically assigned on start-up).

Here are a couple of examples:

Expression

return_type()

return_type_tinfo()

42

commutative

-

2*x-y

commutative

-

dirac_ONE()

noncommutative

TINFO_clifford

dirac_gamma(mu)*dirac_gamma(nu)

noncommutative

TINFO_clifford

2*color_T(a)

noncommutative

TINFO_color

dirac_ONE()*color_T(a)

noncommutative_composite

-

Note: the return_type_tinfo() of Clifford objects is only equal to TINFO_clifford for objects with a representation label of zero. Other representation labels yield a different return_type_tinfo(), but it's the same for any two objects with the same label. This is also true for color objects.

A last note: With the exception of matrices, positive integer powers of non-commutative objects are automatically expanded in GiNaC. For example, pow(a*b, 2) becomes ‘a*b*a*b’ if ‘a’ and ‘b’ are non-commutative expressions).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.