Update copyright statements.
[ginac.git] / ginac / color.cpp
1 /** @file color.cpp
2  *
3  *  Implementation of GiNaC's color (SU(3) Lie algebra) objects. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2014 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 #include "color.h"
24 #include "idx.h"
25 #include "ncmul.h"
26 #include "symmetry.h"
27 #include "operators.h"
28 #include "numeric.h"
29 #include "mul.h"
30 #include "power.h" // for sqrt()
31 #include "symbol.h"
32 #include "archive.h"
33 #include "utils.h"
34
35 #include <iostream>
36 #include <stdexcept>
37
38 namespace GiNaC {
39
40 GINAC_IMPLEMENT_REGISTERED_CLASS(color, indexed)
41
42 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(su3one, tensor,
43   print_func<print_dflt>(&su3one::do_print).
44   print_func<print_latex>(&su3one::do_print_latex))
45
46 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(su3t, tensor,
47   print_func<print_dflt>(&su3t::do_print).
48   print_func<print_latex>(&su3t::do_print))
49
50 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(su3f, tensor,
51   print_func<print_dflt>(&su3f::do_print).
52   print_func<print_latex>(&su3f::do_print))
53
54 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(su3d, tensor,
55   print_func<print_dflt>(&su3d::do_print).
56   print_func<print_latex>(&su3d::do_print))
57
58 //////////
59 // default constructors
60 //////////
61
62 color::color() : representation_label(0)
63 {
64 }
65
66 DEFAULT_CTOR(su3one)
67 DEFAULT_CTOR(su3t)
68 DEFAULT_CTOR(su3f)
69 DEFAULT_CTOR(su3d)
70
71 //////////
72 // other constructors
73 //////////
74
75 /** Construct object without any color index. This constructor is for
76  *  internal use only. Use the color_ONE() function instead.
77  *  @see color_ONE */
78 color::color(const ex & b, unsigned char rl) : inherited(b), representation_label(rl)
79 {
80 }
81
82 /** Construct object with one color index. This constructor is for internal
83  *  use only. Use the color_T() function instead.
84  *  @see color_T */
85 color::color(const ex & b, const ex & i1, unsigned char rl) : inherited(b, i1), representation_label(rl)
86 {
87 }
88
89 color::color(unsigned char rl, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl)
90 {
91 }
92
93 color::color(unsigned char rl, std::auto_ptr<exvector> vp) : inherited(not_symmetric(), vp), representation_label(rl)
94 {
95 }
96
97 return_type_t color::return_type_tinfo() const
98 {
99         return make_return_type_t<color>(representation_label);
100 }
101
102 //////////
103 // archiving
104 //////////
105
106 void color::read_archive(const archive_node& n, lst& sym_lst)
107 {
108         inherited::read_archive(n, sym_lst);
109         unsigned rl;
110         n.find_unsigned("label", rl);
111         representation_label = rl;
112 }
113
114 void color::archive(archive_node &n) const
115 {
116         inherited::archive(n);
117         n.add_unsigned("label", representation_label);
118 }
119
120 GINAC_BIND_UNARCHIVER(color);
121 GINAC_BIND_UNARCHIVER(su3one);
122 GINAC_BIND_UNARCHIVER(su3t);
123 GINAC_BIND_UNARCHIVER(su3f);
124 GINAC_BIND_UNARCHIVER(su3d);
125
126 //////////
127 // functions overriding virtual functions from base classes
128 //////////
129
130 int color::compare_same_type(const basic & other) const
131 {
132         GINAC_ASSERT(is_a<color>(other));
133         const color &o = static_cast<const color &>(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 color::match_same_type(const basic & other) const
144 {
145         GINAC_ASSERT(is_a<color>(other));
146         const color &o = static_cast<const color &>(other);
147
148         return representation_label == o.representation_label;
149 }
150
151 DEFAULT_COMPARE(su3one)
152 DEFAULT_COMPARE(su3t)
153 DEFAULT_COMPARE(su3f)
154 DEFAULT_COMPARE(su3d)
155
156 DEFAULT_PRINT_LATEX(su3one, "ONE", "\\mathbb{1}")
157 DEFAULT_PRINT(su3t, "T")
158 DEFAULT_PRINT(su3f, "f")
159 DEFAULT_PRINT(su3d, "d")
160
161 /** Perform automatic simplification on noncommutative product of color
162  *  objects. This removes superfluous ONEs. */
163 ex color::eval_ncmul(const exvector & v) const
164 {
165         exvector s;
166         s.reserve(v.size());
167
168         // Remove superfluous ONEs
169         exvector::const_iterator it = v.begin(), itend = v.end();
170         while (it != itend) {
171                 if (!is_a<su3one>(it->op(0)))
172                         s.push_back(*it);
173                 it++;
174         }
175
176         if (s.empty())
177                 return color(su3one(), representation_label);
178         else
179                 return hold_ncmul(s);
180 }
181
182 ex color::thiscontainer(const exvector & v) const
183 {
184         return color(representation_label, v);
185 }
186
187 ex color::thiscontainer(std::auto_ptr<exvector> vp) const
188 {
189         return color(representation_label, vp);
190 }
191
192 /** Given a vector iv3 of three indices and a vector iv2 of two indices that
193  *  is a subset of iv3, return the (free) index that is in iv3 but not in
194  *  iv2 and the sign introduced by permuting that index to the front.
195  *
196  *  @param iv3 Vector of 3 indices
197  *  @param iv2 Vector of 2 indices, must be a subset of iv3
198  *  @param sig Returs sign introduced by index permutation
199  *  @return the free index (the one that is in iv3 but not in iv2) */
200 static ex permute_free_index_to_front(const exvector & iv3, const exvector & iv2, int & sig)
201 {
202         GINAC_ASSERT(iv3.size() == 3);
203         GINAC_ASSERT(iv2.size() == 2);
204
205         sig = 1;
206
207 #define TEST_PERMUTATION(A,B,C,P) \
208         if (iv3[B].is_equal(iv2[0]) && iv3[C].is_equal(iv2[1])) { \
209                 sig = P; \
210                 return iv3[A]; \
211         }
212         
213         TEST_PERMUTATION(0,1,2,  1);
214         TEST_PERMUTATION(0,2,1, -1);
215         TEST_PERMUTATION(1,0,2, -1);
216         TEST_PERMUTATION(1,2,0,  1);
217         TEST_PERMUTATION(2,0,1,  1);
218         TEST_PERMUTATION(2,1,0, -1);
219
220         throw(std::logic_error("permute_free_index_to_front(): no valid permutation found"));
221 }
222
223 /** Automatic symbolic evaluation of indexed symmetric structure constant. */
224 ex su3d::eval_indexed(const basic & i) const
225 {
226         GINAC_ASSERT(is_a<indexed>(i));
227         GINAC_ASSERT(i.nops() == 4);
228         GINAC_ASSERT(is_a<su3d>(i.op(0)));
229
230         // Convolutions are zero
231         if (!(static_cast<const indexed &>(i).get_dummy_indices().empty()))
232                 return _ex0;
233
234         // Numeric evaluation
235         if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
236
237                 // Sort indices
238                 int v[3];
239                 for (unsigned j=0; j<3; j++)
240                         v[j] = ex_to<numeric>(ex_to<idx>(i.op(j + 1)).get_value()).to_int();
241                 if (v[0] > v[1]) std::swap(v[0], v[1]);
242                 if (v[0] > v[2]) std::swap(v[0], v[2]);
243                 if (v[1] > v[2]) std::swap(v[1], v[2]);
244
245 #define CMPINDICES(A,B,C) ((v[0] == (A)) && (v[1] == (B)) && (v[2] == (C)))
246
247                 // Check for non-zero elements
248                 if (CMPINDICES(1,4,6) || CMPINDICES(1,5,7) || CMPINDICES(2,5,6)
249                  || CMPINDICES(3,4,4) || CMPINDICES(3,5,5))
250                         return _ex1_2;
251                 else if (CMPINDICES(2,4,7) || CMPINDICES(3,6,6) || CMPINDICES(3,7,7))
252                         return _ex_1_2;
253                 else if (CMPINDICES(1,1,8) || CMPINDICES(2,2,8) || CMPINDICES(3,3,8))
254                         return sqrt(_ex3)*_ex1_3;
255                 else if (CMPINDICES(8,8,8))
256                         return sqrt(_ex3)*_ex_1_3;
257                 else if (CMPINDICES(4,4,8) || CMPINDICES(5,5,8)
258                       || CMPINDICES(6,6,8) || CMPINDICES(7,7,8))
259                         return sqrt(_ex3)/_ex_6;
260                 else
261                         return _ex0;
262         }
263
264         // No further simplifications
265         return i.hold();
266 }
267
268 /** Automatic symbolic evaluation of indexed antisymmetric structure constant. */
269 ex su3f::eval_indexed(const basic & i) const
270 {
271         GINAC_ASSERT(is_a<indexed>(i));
272         GINAC_ASSERT(i.nops() == 4);
273         GINAC_ASSERT(is_a<su3f>(i.op(0)));
274
275         // Numeric evaluation
276         if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
277
278                 // Sort indices, remember permutation sign
279                 int v[3];
280                 for (unsigned j=0; j<3; j++)
281                         v[j] = ex_to<numeric>(ex_to<idx>(i.op(j + 1)).get_value()).to_int();
282                 int sign = 1;
283                 if (v[0] > v[1]) { std::swap(v[0], v[1]); sign = -sign; }
284                 if (v[0] > v[2]) { std::swap(v[0], v[2]); sign = -sign; }
285                 if (v[1] > v[2]) { std::swap(v[1], v[2]); sign = -sign; }
286
287                 // Check for non-zero elements
288                 if (CMPINDICES(1,2,3))
289                         return sign;
290                 else if (CMPINDICES(1,4,7) || CMPINDICES(2,4,6)
291                       || CMPINDICES(2,5,7) || CMPINDICES(3,4,5))
292                         return _ex1_2 * sign;
293                 else if (CMPINDICES(1,5,6) || CMPINDICES(3,6,7))
294                         return _ex_1_2 * sign;
295                 else if (CMPINDICES(4,5,8) || CMPINDICES(6,7,8))
296                         return sqrt(_ex3)/2 * sign;
297                 else
298                         return _ex0;
299         }
300
301         // No further simplifications
302         return i.hold();
303 }
304
305
306 /** Contraction of generator with something else. */
307 bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
308 {
309         GINAC_ASSERT(is_a<indexed>(*self));
310         GINAC_ASSERT(is_a<indexed>(*other));
311         GINAC_ASSERT(self->nops() == 2);
312         GINAC_ASSERT(is_a<su3t>(self->op(0)));
313         unsigned char rl = ex_to<color>(*self).get_representation_label();
314
315         if (is_exactly_a<su3t>(other->op(0))) {
316
317                 // Contraction only makes sense if the represenation labels are equal
318                 GINAC_ASSERT(is_a<color>(*other));
319                 if (ex_to<color>(*other).get_representation_label() != rl)
320                         return false;
321
322                 // T.a T.a = 4/3 ONE
323                 if (other - self == 1) {
324                         *self = numeric(4, 3);
325                         *other = color_ONE(rl);
326                         return true;
327
328                 // T.a T.b T.a = -1/6 T.b
329                 } else if (other - self == 2
330                         && is_a<color>(self[1])) {
331                         *self = numeric(-1, 6);
332                         *other = _ex1;
333                         return true;
334
335                 // T.a S T.a = 1/2 Tr(S) - 1/6 S
336                 } else {
337                         exvector::iterator it = self + 1;
338                         while (it != other) {
339                                 if (!is_a<color>(*it)) {
340                                         return false;
341                                 }
342                                 it++;
343                         }
344
345                         it = self + 1;
346                         ex S = _ex1;
347                         while (it != other) {
348                                 S *= *it;
349                                 *it++ = _ex1;
350                         }
351
352                         *self = color_trace(S, rl) * color_ONE(rl) / 2 - S / 6;
353                         *other = _ex1;
354                         return true;
355                 }
356         }
357
358         return false;
359 }
360
361 /** Contraction of an indexed symmetric structure constant with something else. */
362 bool su3d::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
363 {
364         GINAC_ASSERT(is_a<indexed>(*self));
365         GINAC_ASSERT(is_a<indexed>(*other));
366         GINAC_ASSERT(self->nops() == 4);
367         GINAC_ASSERT(is_a<su3d>(self->op(0)));
368
369         if (is_exactly_a<su3d>(other->op(0))) {
370
371                 // Find the dummy indices of the contraction
372                 exvector self_indices = ex_to<indexed>(*self).get_indices();
373                 exvector other_indices = ex_to<indexed>(*other).get_indices();
374                 exvector all_indices = self_indices;
375                 all_indices.insert(all_indices.end(), other_indices.begin(), other_indices.end());
376                 exvector free_indices, dummy_indices;
377                 find_free_and_dummy(all_indices, free_indices, dummy_indices);
378
379                 // d.abc d.abc = 40/3
380                 if (dummy_indices.size() == 3) {
381                         *self = numeric(40, 3);
382                         *other = _ex1;
383                         return true;
384
385                 // d.akl d.bkl = 5/3 delta.ab
386                 } else if (dummy_indices.size() == 2) {
387                         exvector a;
388                         std::back_insert_iterator<exvector> ita(a);
389                         ita = set_difference(self_indices.begin(), self_indices.end(), dummy_indices.begin(), dummy_indices.end(), ita, ex_is_less());
390                         ita = set_difference(other_indices.begin(), other_indices.end(), dummy_indices.begin(), dummy_indices.end(), ita, ex_is_less());
391                         GINAC_ASSERT(a.size() == 2);
392                         *self = numeric(5, 3) * delta_tensor(a[0], a[1]);
393                         *other = _ex1;
394                         return true;
395                 }
396
397         } else if (is_exactly_a<su3t>(other->op(0))) {
398
399                 // d.abc T.b T.c = 5/6 T.a
400                 if (other+1 != v.end()
401                  && is_exactly_a<su3t>(other[1].op(0))
402                  && ex_to<indexed>(*self).has_dummy_index_for(other[1].op(1))) {
403
404                         exvector self_indices = ex_to<indexed>(*self).get_indices();
405                         exvector dummy_indices;
406                         dummy_indices.push_back(other[0].op(1));
407                         dummy_indices.push_back(other[1].op(1));
408                         int sig;
409                         ex a = permute_free_index_to_front(self_indices, dummy_indices, sig);
410                         *self = numeric(5, 6);
411                         other[0] = color_T(a, ex_to<color>(other[0]).get_representation_label());
412                         other[1] = _ex1;
413                         return true;
414                 }
415         }
416
417         return false;
418 }
419
420 /** Contraction of an indexed antisymmetric structure constant with something else. */
421 bool su3f::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
422 {
423         GINAC_ASSERT(is_a<indexed>(*self));
424         GINAC_ASSERT(is_a<indexed>(*other));
425         GINAC_ASSERT(self->nops() == 4);
426         GINAC_ASSERT(is_a<su3f>(self->op(0)));
427
428         if (is_exactly_a<su3f>(other->op(0))) { // f*d is handled by su3d class
429
430                 // Find the dummy indices of the contraction
431                 exvector dummy_indices;
432                 dummy_indices = ex_to<indexed>(*self).get_dummy_indices(ex_to<indexed>(*other));
433
434                 // f.abc f.abc = 24
435                 if (dummy_indices.size() == 3) {
436                         *self = 24;
437                         *other = _ex1;
438                         return true;
439
440                 // f.akl f.bkl = 3 delta.ab
441                 } else if (dummy_indices.size() == 2) {
442                         int sign1, sign2;
443                         ex a = permute_free_index_to_front(ex_to<indexed>(*self).get_indices(), dummy_indices, sign1);
444                         ex b = permute_free_index_to_front(ex_to<indexed>(*other).get_indices(), dummy_indices, sign2);
445                         *self = sign1 * sign2 * 3 * delta_tensor(a, b);
446                         *other = _ex1;
447                         return true;
448                 }
449
450         } else if (is_exactly_a<su3t>(other->op(0))) {
451
452                 // f.abc T.b T.c = 3/2 I T.a
453                 if (other+1 != v.end()
454                  && is_exactly_a<su3t>(other[1].op(0))
455                  && ex_to<indexed>(*self).has_dummy_index_for(other[1].op(1))) {
456
457                         exvector self_indices = ex_to<indexed>(*self).get_indices();
458                         exvector dummy_indices;
459                         dummy_indices.push_back(other[0].op(1));
460                         dummy_indices.push_back(other[1].op(1));
461                         int sig;
462                         ex a = permute_free_index_to_front(self_indices, dummy_indices, sig);
463                         *self = numeric(3, 2) * sig * I;
464                         other[0] = color_T(a, ex_to<color>(other[0]).get_representation_label());
465                         other[1] = _ex1;
466                         return true;
467                 }
468         }
469
470         return false;
471 }
472
473 //////////
474 // global functions
475 //////////
476
477 ex color_ONE(unsigned char rl)
478 {
479         static ex ONE = (new su3one)->setflag(status_flags::dynallocated);
480         return color(ONE, rl);
481 }
482
483 ex color_T(const ex & a, unsigned char rl)
484 {
485         static ex t = (new su3t)->setflag(status_flags::dynallocated);
486
487         if (!is_a<idx>(a))
488                 throw(std::invalid_argument("indices of color_T must be of type idx"));
489         if (!ex_to<idx>(a).get_dim().is_equal(8))
490                 throw(std::invalid_argument("index dimension for color_T must be 8"));
491
492         return color(t, a, rl);
493 }
494
495 ex color_f(const ex & a, const ex & b, const ex & c)
496 {
497         static ex f = (new su3f)->setflag(status_flags::dynallocated);
498
499         if (!is_a<idx>(a) || !is_a<idx>(b) || !is_a<idx>(c))
500                 throw(std::invalid_argument("indices of color_f must be of type idx"));
501         if (!ex_to<idx>(a).get_dim().is_equal(8) || !ex_to<idx>(b).get_dim().is_equal(8) || !ex_to<idx>(c).get_dim().is_equal(8))
502                 throw(std::invalid_argument("index dimension for color_f must be 8"));
503
504         return indexed(f, antisymmetric3(), a, b, c);
505 }
506
507 ex color_d(const ex & a, const ex & b, const ex & c)
508 {
509         static ex d = (new su3d)->setflag(status_flags::dynallocated);
510
511         if (!is_a<idx>(a) || !is_a<idx>(b) || !is_a<idx>(c))
512                 throw(std::invalid_argument("indices of color_d must be of type idx"));
513         if (!ex_to<idx>(a).get_dim().is_equal(8) || !ex_to<idx>(b).get_dim().is_equal(8) || !ex_to<idx>(c).get_dim().is_equal(8))
514                 throw(std::invalid_argument("index dimension for color_d must be 8"));
515
516         return indexed(d, symmetric3(), a, b, c);
517 }
518
519 ex color_h(const ex & a, const ex & b, const ex & c)
520 {
521         return color_d(a, b, c) + I * color_f(a, b, c);
522 }
523
524 /** Check whether a given tinfo key (as returned by return_type_tinfo()
525  *  is that of a color object (with an arbitrary representation label). */
526 static bool is_color_tinfo(const return_type_t& ti)
527 {
528         return *(ti.tinfo) == typeid(color);
529 }
530
531 /** Extract representation label from tinfo key (as returned by
532  *  return_type_tinfo()). */
533 static unsigned char get_representation_label(const return_type_t& ti)
534 {
535         return (unsigned char)ti.rl;
536 }
537
538 ex color_trace(const ex & e, const std::set<unsigned char> & rls)
539 {
540         if (is_a<color>(e)) {
541
542                 unsigned char rl = ex_to<color>(e).get_representation_label();
543
544                 // Are we taking the trace over this object's representation label?
545                 if (rls.find(rl) == rls.end())
546                         return e;
547
548                 // Yes, all generators are traceless, except for color_ONE
549                 if (is_a<su3one>(e.op(0)))
550                         return _ex3;
551                 else
552                         return _ex0;
553
554         } else if (is_exactly_a<mul>(e)) {
555
556                 // Trace of product: pull out non-color factors
557                 ex prod = _ex1;
558                 for (size_t i=0; i<e.nops(); i++) {
559                         const ex &o = e.op(i);
560                         if (is_color_tinfo(o.return_type_tinfo()))
561                                 prod *= color_trace(o, rls);
562                         else
563                                 prod *= o;
564                 }
565                 return prod;
566
567         } else if (is_exactly_a<ncmul>(e)) {
568
569                 unsigned char rl = get_representation_label(e.return_type_tinfo());
570
571                 // Are we taking the trace over this string's representation label?
572                 if (rls.find(rl) == rls.end())
573                         return e;
574
575                 // Yes, expand product if necessary
576                 ex e_expanded = e.expand();
577                 if (!is_a<ncmul>(e_expanded))
578                         return color_trace(e_expanded, rls);
579
580                 size_t num = e.nops();
581
582                 if (num == 2) {
583
584                         // Tr T_a T_b = 1/2 delta_a_b
585                         return delta_tensor(e.op(0).op(1), e.op(1).op(1)) / 2;
586
587                 } else if (num == 3) {
588
589                         // Tr T_a T_b T_c = 1/4 h_a_b_c
590                         return color_h(e.op(0).op(1), e.op(1).op(1), e.op(2).op(1)) / 4;
591
592                 } else {
593
594                         // Traces of 4 or more generators are computed recursively:
595                         // Tr T_a1 .. T_an =
596                         //     1/6 delta_a(n-1)_an Tr T_a1 .. T_a(n-2)
597                         //   + 1/2 h_a(n-1)_an_k Tr T_a1 .. T_a(n-2) T_k
598                         const ex &last_index = e.op(num - 1).op(1);
599                         const ex &next_to_last_index = e.op(num - 2).op(1);
600                         idx summation_index((new symbol)->setflag(status_flags::dynallocated), 8);
601
602                         exvector v1;
603                         v1.reserve(num - 2);
604                         for (size_t i=0; i<num-2; i++)
605                                 v1.push_back(e.op(i));
606
607                         exvector v2 = v1;
608                         v2.push_back(color_T(summation_index, rl));
609
610                         return delta_tensor(next_to_last_index, last_index) * color_trace(ncmul(v1), rl) / 6
611                                + color_h(next_to_last_index, last_index, summation_index) * color_trace(ncmul(v2), rl) / 2;
612                 }
613
614         } else if (e.nops() > 0) {
615
616                 // Trace maps to all other container classes (this includes sums)
617                 pointer_to_map_function_1arg<const std::set<unsigned char> &> fcn(color_trace, rls);
618                 return e.map(fcn);
619
620         } else
621                 return _ex0;
622 }
623
624 ex color_trace(const ex & e, const lst & rll)
625 {
626         // Convert list to set
627         std::set<unsigned char> rls;
628         for (lst::const_iterator i = rll.begin(); i != rll.end(); ++i) {
629                 if (i->info(info_flags::nonnegint))
630                         rls.insert(ex_to<numeric>(*i).to_int());
631         }
632
633         return color_trace(e, rls);
634 }
635
636 ex color_trace(const ex & e, unsigned char rl)
637 {
638         // Convert label to set
639         std::set<unsigned char> rls;
640         rls.insert(rl);
641
642         return color_trace(e, rls);
643 }
644
645 } // namespace GiNaC