]> www.ginac.de Git - ginac.git/blob - ginac/clifford.cpp
- use initializers in exception class pole_error.
[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) 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<clifford>(*cit) || !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<clifford>(*it) && is_a<clifford>(*it2) && !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<clifford>(s[0]) && is_a<clifford>(s[1]) && 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, itend = s.end() - 1;
323                 for (it = s.begin(); it != itend; ++it) {
324                         ex & a = it[0];
325                         ex & b = it[1];
326                         if (!is_a<clifford>(a) || !is_a<clifford>(b))
327                                 continue;
328                         if (is_a<diracgamma>(a.op(0)) && is_a<diracgamma>(b.op(0))) {
329                                 const ex & ia = a.op(1);
330                                 const ex & ib = b.op(1);
331                                 if (ia.is_equal(ib)) { // gamma~alpha gamma~alpha -> g~alpha~alpha
332                                         a = lorentz_g(ia, ib);
333                                         b = dirac_ONE(representation_label);
334                                         something_changed = true;
335                                 }
336                         } else if (!is_a<diracgamma>(a.op(0)) && !is_a<diracgamma>(b.op(0))) {
337                                 const ex & ba = a.op(0);
338                                 const ex & bb = b.op(0);
339                                 if (ba.is_equal(bb)) { // a\ a\ -> a^2
340                                         varidx ix((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(a.op(1)).get_dim());
341                                         a = indexed(ba, ix) * indexed(bb, ix.toggle_variance());
342                                         b = dirac_ONE(representation_label);
343                                         something_changed = true;
344                                 }
345                         }
346                 }
347         }
348
349         if (s.empty())
350                 return clifford(diracone(), representation_label) * sign;
351         if (something_changed)
352                 return nonsimplified_ncmul(s) * sign;
353         else
354                 return simplified_ncmul(s) * sign;
355 }
356
357 ex clifford::thisexprseq(const exvector & v) const
358 {
359         return clifford(representation_label, v);
360 }
361
362 ex clifford::thisexprseq(exvector * vp) const
363 {
364         return clifford(representation_label, vp);
365 }
366
367 //////////
368 // global functions
369 //////////
370
371 ex dirac_ONE(unsigned char rl)
372 {
373         return clifford(diracone(), rl);
374 }
375
376 ex dirac_gamma(const ex & mu, unsigned char rl)
377 {
378         if (!is_a<varidx>(mu))
379                 throw(std::invalid_argument("index of Dirac gamma must be of type varidx"));
380
381         return clifford(diracgamma(), mu, rl);
382 }
383
384 ex dirac_gamma5(unsigned char rl)
385 {
386         return clifford(diracgamma5(), rl);
387 }
388
389 ex dirac_gamma6(unsigned char rl)
390 {
391         return clifford(diracone(), rl) + clifford(diracgamma5(), rl);
392 }
393
394 ex dirac_gamma7(unsigned char rl)
395 {
396         return clifford(diracone(), rl) - clifford(diracgamma5(), rl);
397 }
398
399 ex dirac_slash(const ex & e, const ex & dim, unsigned char rl)
400 {
401         // Slashed vectors are actually stored as a clifford object with the
402         // vector as its base expression and a (dummy) index that just serves
403         // for storing the space dimensionality
404         return clifford(e, varidx(0, dim), rl);
405 }
406
407 /** Check whether a given tinfo key (as returned by return_type_tinfo()
408  *  is that of a clifford object with the specified representation label. */
409 static bool is_clifford_tinfo(unsigned ti, unsigned char rl)
410 {
411         return ti == (TINFO_clifford + rl);
412 }
413
414 /** Check whether a given tinfo key (as returned by return_type_tinfo()
415  *  is that of a clifford object (with an arbitrary representation label). */
416 static bool is_clifford_tinfo(unsigned ti)
417 {
418         return (ti & ~0xff) == TINFO_clifford;
419 }
420
421 /** Take trace of a string of an even number of Dirac gammas given a vector
422  *  of indices. */
423 static ex trace_string(exvector::const_iterator ix, unsigned num)
424 {
425         // Tr gamma.mu gamma.nu = 4 g.mu.nu
426         if (num == 2)
427                 return lorentz_g(ix[0], ix[1]);
428
429         // 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
430         else if (num == 4)
431                 return lorentz_g(ix[0], ix[1]) * lorentz_g(ix[2], ix[3])
432                      + lorentz_g(ix[1], ix[2]) * lorentz_g(ix[0], ix[3])
433                      - lorentz_g(ix[0], ix[2]) * lorentz_g(ix[1], ix[3]);
434
435         // Traces of 6 or more gammas are computed recursively:
436         // Tr gamma.mu1 gamma.mu2 ... gamma.mun =
437         //   + g.mu1.mu2 * Tr gamma.mu3 ... gamma.mun
438         //   - g.mu1.mu3 * Tr gamma.mu2 gamma.mu4 ... gamma.mun
439         //   + g.mu1.mu4 * Tr gamma.mu3 gamma.mu3 gamma.mu5 ... gamma.mun
440         //   - ...
441         //   + g.mu1.mun * Tr gamma.mu2 ... gamma.mu(n-1)
442         exvector v(num - 2);
443         int sign = 1;
444         ex result;
445         for (unsigned i=1; i<num; i++) {
446                 for (unsigned n=1, j=0; n<num; n++) {
447                         if (n == i)
448                                 continue;
449                         v[j++] = ix[n];
450                 }
451                 result += sign * lorentz_g(ix[0], ix[i]) * trace_string(v.begin(), num-2);
452                 sign = -sign;
453         }
454         return result;
455 }
456
457 ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
458 {
459         if (is_a<clifford>(e)) {
460
461                 if (ex_to<clifford>(e).get_representation_label() == rl
462                  && is_a<diracone>(e.op(0)))
463                         return trONE;
464                 else
465                         return _ex0();
466
467         } else if (is_ex_exactly_of_type(e, mul)) {
468
469                 // Trace of product: pull out non-clifford factors
470                 ex prod = _ex1();
471                 for (unsigned i=0; i<e.nops(); i++) {
472                         const ex &o = e.op(i);
473                         if (is_clifford_tinfo(o.return_type_tinfo(), rl))
474                                 prod *= dirac_trace(o, rl, trONE);
475                         else
476                                 prod *= o;
477                 }
478                 return prod;
479
480         } else if (is_ex_exactly_of_type(e, ncmul)) {
481
482                 if (!is_clifford_tinfo(e.return_type_tinfo(), rl))
483                         return _ex0();
484
485                 // Expand product, if necessary
486                 ex e_expanded = e.expand();
487                 if (!is_a<ncmul>(e_expanded))
488                         return dirac_trace(e_expanded, rl, trONE);
489
490                 // gamma5 gets moved to the front so this check is enough
491                 bool has_gamma5 = is_a<diracgamma5>(e.op(0).op(0));
492                 unsigned num = e.nops();
493
494                 if (has_gamma5) {
495
496                         // Trace of gamma5 * odd number of gammas and trace of
497                         // gamma5 * gamma.mu * gamma.nu are zero
498                         if ((num & 1) == 0 || num == 3)
499                                 return _ex0();
500
501                         // Tr gamma5 gamma.mu gamma.nu gamma.rho gamma.sigma = 4I * epsilon(mu, nu, rho, sigma)
502                         if (num == 5) {
503                                 ex b1, i1, b2, i2, b3, i3, b4, i4;
504                                 base_and_index(e.op(1), b1, i1);
505                                 base_and_index(e.op(2), b2, i2);
506                                 base_and_index(e.op(3), b3, i3);
507                                 base_and_index(e.op(4), b4, i4);
508                                 return trONE * I * (eps0123(i1, i2, i3, i4) * b1 * b2 * b3 * b4).simplify_indexed();
509                         }
510
511                         // Tr gamma5 S_2k =
512                         //   I/4! * epsilon0123.mu1.mu2.mu3.mu4 * Tr gamma.mu1 gamma.mu2 gamma.mu3 gamma.mu4 S_2k
513                         exvector ix(num-1), bv(num-1);
514                         for (unsigned i=1; i<num; i++)
515                                 base_and_index(e.op(i), bv[i-1], ix[i-1]);
516                         num--;
517                         int *iv = new int[num];
518                         ex result;
519                         for (unsigned i=0; i<num-3; i++) {
520                                 ex idx1 = ix[i];
521                                 for (unsigned j=i+1; j<num-2; j++) {
522                                         ex idx2 = ix[j];
523                                         for (unsigned k=j+1; k<num-1; k++) {
524                                                 ex idx3 = ix[k];
525                                                 for (unsigned l=k+1; l<num; l++) {
526                                                         ex idx4 = ix[l];
527                                                         iv[0] = i; iv[1] = j; iv[2] = k; iv[3] = l;
528                                                         exvector v;
529                                                         v.reserve(num - 4);
530                                                         for (unsigned n=0, t=4; n<num; n++) {
531                                                                 if (n == i || n == j || n == k || n == l)
532                                                                         continue;
533                                                                 iv[t++] = n;
534                                                                 v.push_back(ix[n]);
535                                                         }
536                                                         int sign = permutation_sign(iv, iv + num);
537                                                         result += sign * eps0123(idx1, idx2, idx3, idx4)
538                                                                 * trace_string(v.begin(), num - 4);
539                                                 }
540                                         }
541                                 }
542                         }
543                         delete[] iv;
544                         return trONE * I * result * mul(bv);
545
546                 } else { // no gamma5
547
548                         // Trace of odd number of gammas is zero
549                         if ((num & 1) == 1)
550                                 return _ex0();
551
552                         // Tr gamma.mu gamma.nu = 4 g.mu.nu
553                         if (num == 2) {
554                                 ex b1, i1, b2, i2;
555                                 base_and_index(e.op(0), b1, i1);
556                                 base_and_index(e.op(1), b2, i2);
557                                 return trONE * (lorentz_g(i1, i2) * b1 * b2).simplify_indexed();
558                         }
559
560                         exvector iv(num), bv(num);
561                         for (unsigned i=0; i<num; i++)
562                                 base_and_index(e.op(i), bv[i], iv[i]);
563
564                         return trONE * (trace_string(iv.begin(), num) * mul(bv)).simplify_indexed();
565                 }
566
567         } else if (e.nops() > 0) {
568
569                 // Trace maps to all other container classes (this includes sums)
570                 pointer_to_map_function_2args<unsigned char, const ex &> fcn(dirac_trace, rl, trONE);
571                 return e.map(fcn);
572
573         } else
574                 return _ex0();
575 }
576
577 ex canonicalize_clifford(const ex & e)
578 {
579         // Scan for any ncmul objects
580         lst srl;
581         ex aux = e.to_rational(srl);
582         for (unsigned i=0; i<srl.nops(); i++) {
583
584                 ex lhs = srl.op(i).lhs();
585                 ex rhs = srl.op(i).rhs();
586
587                 if (is_ex_exactly_of_type(rhs, ncmul)
588                  && rhs.return_type() == return_types::noncommutative
589                  && is_clifford_tinfo(rhs.return_type_tinfo())) {
590
591                         // Expand product, if necessary
592                         ex rhs_expanded = rhs.expand();
593                         if (!is_a<ncmul>(rhs_expanded)) {
594                                 srl.let_op(i) = (lhs == canonicalize_clifford(rhs_expanded));
595                                 continue;
596
597                         } else if (!is_a<clifford>(rhs.op(0)))
598                                 continue;
599
600                         exvector v;
601                         v.reserve(rhs.nops());
602                         for (unsigned j=0; j<rhs.nops(); j++)
603                                 v.push_back(rhs.op(j));
604
605                         // Stupid recursive bubble sort because we only want to swap adjacent gammas
606                         exvector::iterator it = v.begin(), next_to_last = v.end() - 1;
607                         if (is_a<diracgamma5>(it->op(0)))
608                                 ++it;
609                         while (it != next_to_last) {
610                                 if (it[0].compare(it[1]) > 0) {
611                                         ex save0 = it[0], save1 = it[1];
612                                         ex b1, i1, b2, i2;
613                                         base_and_index(it[0], b1, i1);
614                                         base_and_index(it[1], b2, i2);
615                                         it[0] = (lorentz_g(i1, i2) * b1 * b2).simplify_indexed();
616                                         it[1] = _ex2();
617                                         ex sum = ncmul(v);
618                                         it[0] = save1;
619                                         it[1] = save0;
620                                         sum -= ncmul(v, true);
621                                         srl.let_op(i) = (lhs == canonicalize_clifford(sum));
622                                         goto next_sym;
623                                 }
624                                 ++it;
625                         }
626 next_sym:       ;
627                 }
628         }
629         return aux.subs(srl).simplify_indexed();
630 }
631
632 } // namespace GiNaC