- epsilon*epsilon contractions work
[ginac.git] / ginac / clifford.cpp
1 /** @file clifford.cpp
2  *
3  *  Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #include "clifford.h"
24 #include "ex.h"
25 #include "idx.h"
26 #include "ncmul.h"
27 #include "symbol.h"
28 #include "numeric.h" // for I
29 #include "symmetry.h"
30 #include "lst.h"
31 #include "relational.h"
32 #include "mul.h"
33 #include "print.h"
34 #include "archive.h"
35 #include "debugmsg.h"
36 #include "utils.h"
37
38 #include <stdexcept>
39
40 namespace GiNaC {
41
42 GINAC_IMPLEMENT_REGISTERED_CLASS(clifford, indexed)
43 GINAC_IMPLEMENT_REGISTERED_CLASS(diracone, tensor)
44 GINAC_IMPLEMENT_REGISTERED_CLASS(diracgamma, tensor)
45 GINAC_IMPLEMENT_REGISTERED_CLASS(diracgamma5, tensor)
46
47 //////////
48 // default constructor, destructor, copy constructor assignment operator and helpers
49 //////////
50
51 clifford::clifford() : representation_label(0)
52 {
53         debugmsg("clifford default constructor", LOGLEVEL_CONSTRUCT);
54         tinfo_key = TINFO_clifford;
55 }
56
57 void clifford::copy(const clifford & other)
58 {
59         inherited::copy(other);
60         representation_label = other.representation_label;
61 }
62
63 DEFAULT_DESTROY(clifford)
64 DEFAULT_CTORS(diracone)
65 DEFAULT_CTORS(diracgamma)
66 DEFAULT_CTORS(diracgamma5)
67
68 //////////
69 // other constructors
70 //////////
71
72 /** Construct object without any indices. This constructor is for internal
73  *  use only. Use the dirac_ONE() function instead.
74  *  @see dirac_ONE */
75 clifford::clifford(const ex & b, unsigned char rl) : inherited(b), representation_label(rl)
76 {
77         debugmsg("clifford constructor from ex", LOGLEVEL_CONSTRUCT);
78         tinfo_key = TINFO_clifford;
79 }
80
81 /** Construct object with one Lorentz index. This constructor is for internal
82  *  use only. Use the dirac_gamma() function instead.
83  *  @see dirac_gamma */
84 clifford::clifford(const ex & b, const ex & mu, unsigned char rl) : inherited(b, mu), representation_label(rl)
85 {
86         debugmsg("clifford constructor from ex,ex", LOGLEVEL_CONSTRUCT);
87         GINAC_ASSERT(is_a<varidx>(mu));
88         tinfo_key = TINFO_clifford;
89 }
90
91 clifford::clifford(unsigned char rl, const exvector & v, bool discardable) : inherited(sy_none(), v, discardable), representation_label(rl)
92 {
93         debugmsg("clifford constructor from unsigned char,exvector", LOGLEVEL_CONSTRUCT);
94         tinfo_key = TINFO_clifford;
95 }
96
97 clifford::clifford(unsigned char rl, exvector * vp) : inherited(sy_none(), vp), representation_label(rl)
98 {
99         debugmsg("clifford constructor from unsigned char,exvector *", LOGLEVEL_CONSTRUCT);
100         tinfo_key = TINFO_clifford;
101 }
102
103 //////////
104 // archiving
105 //////////
106
107 clifford::clifford(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
108 {
109         debugmsg("clifford constructor from archive_node", LOGLEVEL_CONSTRUCT);
110         unsigned rl;
111         n.find_unsigned("label", rl);
112         representation_label = rl;
113 }
114
115 void clifford::archive(archive_node &n) const
116 {
117         inherited::archive(n);
118         n.add_unsigned("label", representation_label);
119 }
120
121 DEFAULT_UNARCHIVE(clifford)
122 DEFAULT_ARCHIVING(diracone)
123 DEFAULT_ARCHIVING(diracgamma)
124 DEFAULT_ARCHIVING(diracgamma5)
125
126 //////////
127 // functions overriding virtual functions from base classes
128 //////////
129
130 int clifford::compare_same_type(const basic & other) const
131 {
132         GINAC_ASSERT(is_of_type(other, clifford));
133         const clifford &o = static_cast<const clifford &>(other);
134
135         if (representation_label != o.representation_label) {
136                 // different representation label
137                 return representation_label < o.representation_label ? -1 : 1;
138         }
139
140         return inherited::compare_same_type(other);
141 }
142
143 bool clifford::match_same_type(const basic & other) const
144 {
145         GINAC_ASSERT(is_of_type(other, clifford));
146         const clifford &o = static_cast<const clifford &>(other);
147
148         return representation_label == o.representation_label;
149 }
150
151 void clifford::print(const print_context & c, unsigned level = 0) const
152 {
153         if (!is_a<diracgamma5>(seq[0]) && !is_a<diracgamma>(seq[0]) && !is_a<diracone>(seq[0])) {
154
155                 // dirac_slash() object is printed differently
156                 if (is_a<print_tree>(c))
157                         inherited::print(c, level);
158                 else if (is_a<print_latex>(c)) {
159                         c.s << "{";
160                         seq[0].print(c, level);
161                         c.s << "\\hspace{-1.0ex}/}";
162                 } else {
163                         seq[0].print(c, level);
164                         c.s << "\\";
165                 }
166
167         } else
168                 inherited::print(c, level);
169 }
170
171 DEFAULT_COMPARE(diracone)
172 DEFAULT_COMPARE(diracgamma)
173 DEFAULT_COMPARE(diracgamma5)
174
175 DEFAULT_PRINT_LATEX(diracone, "ONE", "\\mathbb{1}")
176 DEFAULT_PRINT_LATEX(diracgamma, "gamma", "\\gamma")
177 DEFAULT_PRINT_LATEX(diracgamma5, "gamma5", "{\\gamma^5}")
178
179 /** This function decomposes gamma~mu -> (1, mu) and a\ -> (a.ix, ix) */
180 static void base_and_index(const ex & c, ex & b, ex & i)
181 {
182         GINAC_ASSERT(is_a<clifford>(c));
183         GINAC_ASSERT(c.nops() == 2);
184
185         if (is_a<diracgamma>(c.op(0))) { // proper dirac gamma object
186                 i = c.op(1);
187                 b = _ex1();
188         } else { // slash object, generate new dummy index
189                 varidx ix((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(c.op(1)).get_dim());
190                 b = indexed(c.op(0), ix.toggle_variance());
191                 i = ix;
192         }
193 }
194
195 /** Contraction of a gamma matrix with something else. */
196 bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
197 {
198         GINAC_ASSERT(is_a<clifford>(*self));
199         GINAC_ASSERT(is_a<indexed>(*other));
200         GINAC_ASSERT(is_a<diracgamma>(self->op(0)));
201         unsigned char rl = ex_to<clifford>(*self).get_representation_label();
202
203         if (is_a<clifford>(*other)) {
204
205                 ex dim = ex_to<idx>(self->op(1)).get_dim();
206
207                 // gamma~mu gamma.mu = dim ONE
208                 if (other - self == 1) {
209                         *self = dim;
210                         *other = dirac_ONE(rl);
211                         return true;
212
213                 // gamma~mu gamma~alpha gamma.mu = (2-dim) gamma~alpha
214                 } else if (other - self == 2
215                         && is_a<clifford>(self[1])) {
216                         *self = 2 - dim;
217                         *other = _ex1();
218                         return true;
219
220                 // gamma~mu gamma~alpha gamma~beta gamma.mu = 4 g~alpha~beta + (dim-4) gamam~alpha gamma~beta
221                 } else if (other - self == 3
222                         && is_a<clifford>(self[1])
223                         && is_a<clifford>(self[2])) {
224                         ex b1, i1, b2, i2;
225                         base_and_index(self[1], b1, i1);
226                         base_and_index(self[2], b2, i2);
227                         *self = 4 * lorentz_g(i1, i2) * b1 * b2 * dirac_ONE(rl) + (dim - 4) * self[1] * self[2];
228                         self[1] = _ex1();
229                         self[2] = _ex1();
230                         *other = _ex1();
231                         return true;
232
233                 // gamma~mu gamma~alpha gamma~beta gamma~delta gamma.mu = -2 gamma~delta gamma~beta gamma~alpha - (dim-4) gamam~alpha gamma~beta gamma~delta
234                 } else if (other - self == 4
235                         && is_a<clifford>(self[1])
236                         && is_a<clifford>(self[2])
237                         && is_a<clifford>(self[3])) {
238                         *self = -2 * self[3] * self[2] * self[1] - (dim - 4) * self[1] * self[2] * self[3];
239                         self[1] = _ex1();
240                         self[2] = _ex1();
241                         self[3] = _ex1();
242                         *other = _ex1();
243                         return true;
244
245                 // gamma~mu S gamma~alpha gamma.mu = 2 gamma~alpha S - gamma~mu S gamma.mu gamma~alpha
246                 // (commutate contracted indices towards each other, simplify_indexed()
247                 // will re-expand and re-run the simplification)
248                 } else {
249                         exvector::iterator it = self + 1, next_to_last = other - 1;
250                         while (it != other) {
251                                 if (!is_a<clifford>(*it))
252                                         return false;
253                                 ++it;
254                         }
255
256                         it = self + 1;
257                         ex S = _ex1();
258                         while (it != next_to_last) {
259                                 S *= *it;
260                                 *it++ = _ex1();
261                         }
262
263                         *self = 2 * (*next_to_last) * S - (*self) * S * (*other) * (*next_to_last);
264                         *next_to_last = _ex1();
265                         *other = _ex1();
266                         return true;
267                 }
268         }
269
270         return false;
271 }
272
273 /** Perform automatic simplification on noncommutative product of clifford
274  *  objects. This removes superfluous ONEs, permutes gamma5's to the front
275  *  and removes squares of gamma objects. */
276 ex clifford::simplify_ncmul(const exvector & v) const
277 {
278         exvector s;
279         s.reserve(v.size());
280
281         // Remove superfluous ONEs
282         exvector::const_iterator cit = v.begin(), citend = v.end();
283         while (cit != citend) {
284                 if (!is_a<diracone>(cit->op(0)))
285                         s.push_back(*cit);
286                 cit++;
287         }
288
289         bool something_changed = false;
290         int sign = 1;
291
292         // Anticommute gamma5's to the front
293         if (s.size() >= 2) {
294                 exvector::iterator first = s.begin(), next_to_last = s.end() - 2;
295                 while (true) {
296                         exvector::iterator it = next_to_last;
297                         while (true) {
298                                 exvector::iterator it2 = it + 1;
299                                 if (!is_a<diracgamma5>(it->op(0)) && is_a<diracgamma5>(it2->op(0))) {
300                                         it->swap(*it2);
301                                         sign = -sign;
302                                         something_changed = true;
303                                 }
304                                 if (it == first)
305                                         break;
306                                 --it;
307                         }
308                         if (next_to_last == first)
309                                 break;
310                         --next_to_last;
311                 }
312         }
313
314         // Remove squares of gamma5
315         while (s.size() >= 2 && is_a<diracgamma5>(s[0].op(0)) && is_a<diracgamma5>(s[1].op(0))) {
316                 s.erase(s.begin(), s.begin() + 2);
317                 something_changed = true;
318         }
319
320         // Remove equal adjacent gammas
321         if (s.size() >= 2) {
322                 exvector::iterator it = s.begin(), itend = s.end() - 1;
323                 while (it != itend) {
324                         ex & a = it[0];
325                         ex & b = it[1];
326                         if (is_a<diracgamma>(a.op(0)) && is_a<diracgamma>(b.op(0))) {
327                                 const ex & ia = a.op(1);
328                                 const ex & ib = b.op(1);
329                                 if (ia.is_equal(ib)) { // gamma~alpha gamma~alpha -> g~alpha~alpha
330                                         a = lorentz_g(ia, ib);
331                                         b = dirac_ONE(representation_label);
332                                         something_changed = true;
333                                 }
334                         } else if (!is_a<diracgamma>(a.op(0)) && !is_a<diracgamma>(b.op(0))) {
335                                 const ex & ba = a.op(0);
336                                 const ex & bb = b.op(0);
337                                 if (ba.is_equal(bb)) { // a\ a\ -> a^2
338                                         varidx ix((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(a.op(1)).get_dim());
339                                         a = indexed(ba, ix) * indexed(bb, ix.toggle_variance());
340                                         b = dirac_ONE(representation_label);
341                                         something_changed = true;
342                                 }
343                         }
344                         ++it;
345                 }
346         }
347
348         if (s.empty())
349                 return clifford(diracone(), representation_label) * sign;
350         if (something_changed)
351                 return nonsimplified_ncmul(s) * sign;
352         else
353                 return simplified_ncmul(s) * sign;
354 }
355
356 ex clifford::thisexprseq(const exvector & v) const
357 {
358         return clifford(representation_label, v);
359 }
360
361 ex clifford::thisexprseq(exvector * vp) const
362 {
363         return clifford(representation_label, vp);
364 }
365
366 //////////
367 // global functions
368 //////////
369
370 ex dirac_ONE(unsigned char rl)
371 {
372         return clifford(diracone(), rl);
373 }
374
375 ex dirac_gamma(const ex & mu, unsigned char rl)
376 {
377         if (!is_a<varidx>(mu))
378                 throw(std::invalid_argument("index of Dirac gamma must be of type varidx"));
379
380         return clifford(diracgamma(), mu, rl);
381 }
382
383 ex dirac_gamma5(unsigned char rl)
384 {
385         return clifford(diracgamma5(), rl);
386 }
387
388 ex dirac_gamma6(unsigned char rl)
389 {
390         return clifford(diracone(), rl) + clifford(diracgamma5(), rl);
391 }
392
393 ex dirac_gamma7(unsigned char rl)
394 {
395         return clifford(diracone(), rl) - clifford(diracgamma5(), rl);
396 }
397
398 ex dirac_slash(const ex & e, const ex & dim, unsigned char rl)
399 {
400         // Slashed vectors are actually stored as a clifford object with the
401         // vector as its base expression and a (dummy) index that just serves
402         // for storing the space dimensionality
403         return clifford(e, varidx(0, dim), rl);
404 }
405
406 /** Check whether a given tinfo key (as returned by return_type_tinfo()
407  *  is that of a clifford object with the specified representation label. */
408 static bool is_clifford_tinfo(unsigned ti, unsigned char rl)
409 {
410         return ti == (TINFO_clifford + rl);
411 }
412
413 /** Check whether a given tinfo key (as returned by return_type_tinfo()
414  *  is that of a clifford object (with an arbitrary representation label). */
415 static bool is_clifford_tinfo(unsigned ti)
416 {
417         return (ti & ~0xff) == TINFO_clifford;
418 }
419
420 /** Take trace of a string of an even number of Dirac gammas given a vector
421  *  of indices. */
422 static ex trace_string(exvector::const_iterator ix, unsigned num)
423 {
424         // Tr gamma.mu gamma.nu = 4 g.mu.nu
425         if (num == 2)
426                 return lorentz_g(ix[0], ix[1]);
427
428         // Tr gamma.mu gamma.nu gamma.rho gamma.sig = 4 (g.mu.nu g.rho.sig + g.nu.rho g.mu.sig - g.mu.rho g.nu.sig
429         else if (num == 4)
430                 return lorentz_g(ix[0], ix[1]) * lorentz_g(ix[2], ix[3])
431                      + lorentz_g(ix[1], ix[2]) * lorentz_g(ix[0], ix[3])
432                      - lorentz_g(ix[0], ix[2]) * lorentz_g(ix[1], ix[3]);
433
434         // Traces of 6 or more gammas are computed recursively:
435         // Tr gamma.mu1 gamma.mu2 ... gamma.mun =
436         //   + g.mu1.mu2 * Tr gamma.mu3 ... gamma.mun
437         //   - g.mu1.mu3 * Tr gamma.mu2 gamma.mu4 ... gamma.mun
438         //   + g.mu1.mu4 * Tr gamma.mu3 gamma.mu3 gamma.mu5 ... gamma.mun
439         //   - ...
440         //   + g.mu1.mun * Tr gamma.mu2 ... gamma.mu(n-1)
441         exvector v(num - 2);
442         int sign = 1;
443         ex result;
444         for (unsigned i=1; i<num; i++) {
445                 for (unsigned n=1, j=0; n<num; n++) {
446                         if (n == i)
447                                 continue;
448                         v[j++] = ix[n];
449                 }
450                 result += sign * lorentz_g(ix[0], ix[i]) * trace_string(v.begin(), num-2);
451                 sign = -sign;
452         }
453         return result;
454 }
455
456 ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
457 {
458         if (is_a<clifford>(e)) {
459
460                 if (ex_to<clifford>(e).get_representation_label() == rl
461                  && is_a<diracone>(e.op(0)))
462                         return trONE;
463                 else
464                         return _ex0();
465
466         } else if (is_ex_exactly_of_type(e, mul)) {
467
468                 // Trace of product: pull out non-clifford factors
469                 ex prod = _ex1();
470                 for (unsigned i=0; i<e.nops(); i++) {
471                         const ex &o = e.op(i);
472                         if (is_clifford_tinfo(o.return_type_tinfo(), rl))
473                                 prod *= dirac_trace(o, rl, trONE);
474                         else
475                                 prod *= o;
476                 }
477                 return prod;
478
479         } else if (is_ex_exactly_of_type(e, ncmul)) {
480
481                 if (!is_clifford_tinfo(e.return_type_tinfo(), rl))
482                         return _ex0();
483
484                 // Expand product, if necessary
485                 ex e_expanded = e.expand();
486                 if (!is_a<ncmul>(e_expanded))
487                         return dirac_trace(e_expanded, rl, trONE);
488
489                 // gamma5 gets moved to the front so this check is enough
490                 bool has_gamma5 = is_a<diracgamma5>(e.op(0).op(0));
491                 unsigned num = e.nops();
492
493                 if (has_gamma5) {
494
495                         // Trace of gamma5 * odd number of gammas and trace of
496                         // gamma5 * gamma.mu * gamma.nu are zero
497                         if ((num & 1) == 0 || num == 3)
498                                 return _ex0();
499
500                         // Tr gamma5 gamma.mu gamma.nu gamma.rho gamma.sigma = 4I * epsilon(mu, nu, rho, sigma)
501                         if (num == 5) {
502                                 ex b1, i1, b2, i2, b3, i3, b4, i4;
503                                 base_and_index(e.op(1), b1, i1);
504                                 base_and_index(e.op(2), b2, i2);
505                                 base_and_index(e.op(3), b3, i3);
506                                 base_and_index(e.op(4), b4, i4);
507                                 return trONE * I * (eps0123(i1, i2, i3, i4) * b1 * b2 * b3 * b4).simplify_indexed();
508                         }
509
510                         // Tr gamma5 S_2k =
511                         //   I/4! * epsilon0123.mu1.mu2.mu3.mu4 * Tr gamma.mu1 gamma.mu2 gamma.mu3 gamma.mu4 S_2k
512                         exvector ix(num-1), bv(num-1);
513                         for (unsigned i=1; i<num; i++)
514                                 base_and_index(e.op(i), bv[i-1], ix[i-1]);
515                         num--;
516                         int *iv = new int[num];
517                         ex result;
518                         for (unsigned i=0; i<num-3; i++) {
519                                 ex idx1 = ix[i];
520                                 for (unsigned j=i+1; j<num-2; j++) {
521                                         ex idx2 = ix[j];
522                                         for (unsigned k=j+1; k<num-1; k++) {
523                                                 ex idx3 = ix[k];
524                                                 for (unsigned l=k+1; l<num; l++) {
525                                                         ex idx4 = ix[l];
526                                                         iv[0] = i; iv[1] = j; iv[2] = k; iv[3] = l;
527                                                         exvector v;
528                                                         v.reserve(num - 4);
529                                                         for (unsigned n=0, t=4; n<num; n++) {
530                                                                 if (n == i || n == j || n == k || n == l)
531                                                                         continue;
532                                                                 iv[t++] = n;
533                                                                 v.push_back(ix[n]);
534                                                         }
535                                                         int sign = permutation_sign(iv, iv + num);
536                                                         result += sign * eps0123(idx1, idx2, idx3, idx4)
537                                                                 * trace_string(v.begin(), num - 4);
538                                                 }
539                                         }
540                                 }
541                         }
542                         delete[] iv;
543                         return trONE * I * result * mul(bv);
544
545                 } else { // no gamma5
546
547                         // Trace of odd number of gammas is zero
548                         if ((num & 1) == 1)
549                                 return _ex0();
550
551                         // Tr gamma.mu gamma.nu = 4 g.mu.nu
552                         if (num == 2) {
553                                 ex b1, i1, b2, i2;
554                                 base_and_index(e.op(0), b1, i1);
555                                 base_and_index(e.op(1), b2, i2);
556                                 return trONE * (lorentz_g(i1, i2) * b1 * b2).simplify_indexed();
557                         }
558
559                         exvector iv(num), bv(num);
560                         for (unsigned i=0; i<num; i++)
561                                 base_and_index(e.op(i), bv[i], iv[i]);
562
563                         return trONE * (trace_string(iv.begin(), num) * mul(bv)).simplify_indexed();
564                 }
565
566         } else if (e.nops() > 0) {
567
568                 // Trace maps to all other container classes (this includes sums)
569                 pointer_to_map_function_2args<unsigned char, const ex &> fcn(dirac_trace, rl, trONE);
570                 return e.map(fcn);
571
572         } else
573                 return _ex0();
574 }
575
576 ex canonicalize_clifford(const ex & e)
577 {
578         // Scan for any ncmul objects
579         lst srl;
580         ex aux = e.to_rational(srl);
581         for (unsigned i=0; i<srl.nops(); i++) {
582
583                 ex lhs = srl.op(i).lhs();
584                 ex rhs = srl.op(i).rhs();
585
586                 if (is_ex_exactly_of_type(rhs, ncmul)
587                  && rhs.return_type() == return_types::noncommutative
588                  && is_clifford_tinfo(rhs.return_type_tinfo())) {
589
590                         // Expand product, if necessary
591                         ex rhs_expanded = rhs.expand();
592                         if (!is_a<ncmul>(rhs_expanded)) {
593                                 srl.let_op(i) = (lhs == canonicalize_clifford(rhs_expanded));
594                                 continue;
595
596                         } else if (!is_a<clifford>(rhs.op(0)))
597                                 continue;
598
599                         exvector v;
600                         v.reserve(rhs.nops());
601                         for (unsigned j=0; j<rhs.nops(); j++)
602                                 v.push_back(rhs.op(j));
603
604                         // Stupid recursive bubble sort because we only want to swap adjacent gammas
605                         exvector::iterator it = v.begin(), next_to_last = v.end() - 1;
606                         if (is_a<diracgamma5>(it->op(0)))
607                                 ++it;
608                         while (it != next_to_last) {
609                                 if (it[0].compare(it[1]) > 0) {
610                                         ex save0 = it[0], save1 = it[1];
611                                         ex b1, i1, b2, i2;
612                                         base_and_index(it[0], b1, i1);
613                                         base_and_index(it[1], b2, i2);
614                                         it[0] = (lorentz_g(i1, i2) * b1 * b2).simplify_indexed();
615                                         it[1] = _ex2();
616                                         ex sum = ncmul(v);
617                                         it[0] = save1;
618                                         it[1] = save0;
619                                         sum -= ncmul(v, true);
620                                         srl.let_op(i) = (lhs == canonicalize_clifford(sum));
621                                         goto next_sym;
622                                 }
623                                 ++it;
624                         }
625 next_sym:       ;
626                 }
627         }
628         return aux.subs(srl).simplify_indexed();
629 }
630
631 } // namespace GiNaC