use new-style print methods
[ginac.git] / ginac / tensor.cpp
1 /** @file tensor.cpp
2  *
3  *  Implementation of GiNaC's special tensors. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2003 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 <iostream>
24 #include <stdexcept>
25 #include <vector>
26
27 #include "tensor.h"
28 #include "idx.h"
29 #include "indexed.h"
30 #include "symmetry.h"
31 #include "relational.h"
32 #include "operators.h"
33 #include "lst.h"
34 #include "numeric.h"
35 #include "matrix.h"
36 #include "print.h"
37 #include "archive.h"
38 #include "utils.h"
39
40 namespace GiNaC {
41
42 GINAC_IMPLEMENT_REGISTERED_CLASS(tensor, basic)
43
44 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(tensdelta, tensor,
45   print_func<print_dflt>(&tensdelta::do_print).
46   print_func<print_latex>(&tensdelta::do_print_latex))
47
48 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(tensmetric, tensor,
49   print_func<print_dflt>(&tensmetric::do_print).
50   print_func<print_latex>(&tensmetric::do_print))
51
52 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(minkmetric, tensmetric,
53   print_func<print_dflt>(&minkmetric::do_print).
54   print_func<print_latex>(&minkmetric::do_print_latex))
55
56 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(spinmetric, tensmetric,
57   print_func<print_dflt>(&spinmetric::do_print).
58   print_func<print_latex>(&spinmetric::do_print_latex))
59
60 GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(tensepsilon, tensor,
61   print_func<print_dflt>(&tensepsilon::do_print).
62   print_func<print_latex>(&tensepsilon::do_print_latex))
63
64 //////////
65 // constructors
66 //////////
67
68 tensor::tensor() : inherited(TINFO_tensor)
69 {
70         setflag(status_flags::evaluated | status_flags::expanded);
71 }
72
73 DEFAULT_CTOR(tensdelta)
74 DEFAULT_CTOR(tensmetric)
75
76 minkmetric::minkmetric() : pos_sig(false)
77 {
78         tinfo_key = TINFO_minkmetric;
79 }
80
81 spinmetric::spinmetric()
82 {
83         tinfo_key = TINFO_spinmetric;
84 }
85
86 minkmetric::minkmetric(bool ps) : pos_sig(ps)
87 {
88         tinfo_key = TINFO_minkmetric;
89 }
90
91 tensepsilon::tensepsilon() : minkowski(false), pos_sig(false)
92 {
93         tinfo_key = TINFO_tensepsilon;
94 }
95
96 tensepsilon::tensepsilon(bool mink, bool ps) : minkowski(mink), pos_sig(ps)
97 {
98         tinfo_key = TINFO_tensepsilon;
99 }
100
101 //////////
102 // archiving
103 //////////
104
105 DEFAULT_ARCHIVING(tensor)
106 DEFAULT_ARCHIVING(tensdelta)
107 DEFAULT_ARCHIVING(tensmetric)
108 DEFAULT_ARCHIVING(spinmetric)
109 DEFAULT_UNARCHIVE(minkmetric)
110 DEFAULT_UNARCHIVE(tensepsilon)
111
112 minkmetric::minkmetric(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
113 {
114         n.find_bool("pos_sig", pos_sig);
115 }
116
117 void minkmetric::archive(archive_node &n) const
118 {
119         inherited::archive(n);
120         n.add_bool("pos_sig", pos_sig);
121 }
122
123 tensepsilon::tensepsilon(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
124 {
125         n.find_bool("minkowski", minkowski);
126         n.find_bool("pos_sig", pos_sig);
127 }
128
129 void tensepsilon::archive(archive_node &n) const
130 {
131         inherited::archive(n);
132         n.add_bool("minkowski", minkowski);
133         n.add_bool("pos_sig", pos_sig);
134 }
135
136 //////////
137 // functions overriding virtual functions from base classes
138 //////////
139
140 DEFAULT_COMPARE(tensor)
141 DEFAULT_COMPARE(tensdelta)
142 DEFAULT_COMPARE(tensmetric)
143 DEFAULT_COMPARE(spinmetric)
144
145 int minkmetric::compare_same_type(const basic & other) const
146 {
147         GINAC_ASSERT(is_a<minkmetric>(other));
148         const minkmetric &o = static_cast<const minkmetric &>(other);
149
150         if (pos_sig != o.pos_sig)
151                 return pos_sig ? -1 : 1;
152         else
153                 return inherited::compare_same_type(other);
154 }
155
156 int tensepsilon::compare_same_type(const basic & other) const
157 {
158         GINAC_ASSERT(is_a<tensepsilon>(other));
159         const tensepsilon &o = static_cast<const tensepsilon &>(other);
160
161         if (minkowski != o.minkowski)
162                 return minkowski ? -1 : 1;
163         else if (pos_sig != o.pos_sig)
164                 return pos_sig ? -1 : 1;
165         else
166                 return inherited::compare_same_type(other);
167 }
168
169 DEFAULT_PRINT_LATEX(tensdelta, "delta", "\\delta")
170 DEFAULT_PRINT(tensmetric, "g")
171 DEFAULT_PRINT_LATEX(minkmetric, "eta", "\\eta")
172 DEFAULT_PRINT_LATEX(spinmetric, "eps", "\\varepsilon")
173 DEFAULT_PRINT_LATEX(tensepsilon, "eps", "\\varepsilon")
174
175 /** Automatic symbolic evaluation of an indexed delta tensor. */
176 ex tensdelta::eval_indexed(const basic & i) const
177 {
178         GINAC_ASSERT(is_a<indexed>(i));
179         GINAC_ASSERT(i.nops() == 3);
180         GINAC_ASSERT(is_a<tensdelta>(i.op(0)));
181
182         const idx & i1 = ex_to<idx>(i.op(1));
183         const idx & i2 = ex_to<idx>(i.op(2));
184
185         // The dimension of the indices must be equal, otherwise we use the minimal
186         // dimension
187         if (!i1.get_dim().is_equal(i2.get_dim())) {
188                 ex min_dim = i1.minimal_dim(i2);
189                 exmap m;
190                 m[i1] = i1.replace_dim(min_dim);
191                 m[i2] = i2.replace_dim(min_dim);
192                 return i.subs(m, subs_options::no_pattern);
193         }
194
195         // Trace of delta tensor is the (effective) dimension of the space
196         if (is_dummy_pair(i1, i2)) {
197                 try {
198                         return i1.minimal_dim(i2);
199                 } catch (std::exception &e) {
200                         return i.hold();
201                 }
202         }
203
204         // Numeric evaluation
205         if (static_cast<const indexed &>(i).all_index_values_are(info_flags::integer)) {
206                 int n1 = ex_to<numeric>(i1.get_value()).to_int(), n2 = ex_to<numeric>(i2.get_value()).to_int();
207                 if (n1 == n2)
208                         return _ex1;
209                 else
210                         return _ex0;
211         }
212
213         // No further simplifications
214         return i.hold();
215 }
216
217 /** Automatic symbolic evaluation of an indexed metric tensor. */
218 ex tensmetric::eval_indexed(const basic & i) const
219 {
220         GINAC_ASSERT(is_a<indexed>(i));
221         GINAC_ASSERT(i.nops() == 3);
222         GINAC_ASSERT(is_a<tensmetric>(i.op(0)));
223         GINAC_ASSERT(is_a<varidx>(i.op(1)));
224         GINAC_ASSERT(is_a<varidx>(i.op(2)));
225
226         const varidx & i1 = ex_to<varidx>(i.op(1));
227         const varidx & i2 = ex_to<varidx>(i.op(2));
228
229         // The dimension of the indices must be equal, otherwise we use the minimal
230         // dimension
231         if (!i1.get_dim().is_equal(i2.get_dim())) {
232                 ex min_dim = i1.minimal_dim(i2);
233                 exmap m;
234                 m[i1] = i1.replace_dim(min_dim);
235                 m[i2] = i2.replace_dim(min_dim);
236                 return i.subs(m, subs_options::no_pattern);
237         }
238
239         // A metric tensor with one covariant and one contravariant index gets
240         // replaced by a delta tensor
241         if (i1.is_covariant() != i2.is_covariant())
242                 return delta_tensor(i1, i2);
243
244         // No further simplifications
245         return i.hold();
246 }
247
248 /** Automatic symbolic evaluation of an indexed Lorentz metric tensor. */
249 ex minkmetric::eval_indexed(const basic & i) const
250 {
251         GINAC_ASSERT(is_a<indexed>(i));
252         GINAC_ASSERT(i.nops() == 3);
253         GINAC_ASSERT(is_a<minkmetric>(i.op(0)));
254         GINAC_ASSERT(is_a<varidx>(i.op(1)));
255         GINAC_ASSERT(is_a<varidx>(i.op(2)));
256
257         const varidx & i1 = ex_to<varidx>(i.op(1));
258         const varidx & i2 = ex_to<varidx>(i.op(2));
259
260         // Numeric evaluation
261         if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
262                 int n1 = ex_to<numeric>(i1.get_value()).to_int(), n2 = ex_to<numeric>(i2.get_value()).to_int();
263                 if (n1 != n2)
264                         return _ex0;
265                 else if (n1 == 0)
266                         return pos_sig ? _ex_1 : _ex1;
267                 else
268                         return pos_sig ? _ex1 : _ex_1;
269         }
270
271         // Perform the usual evaluations of a metric tensor
272         return inherited::eval_indexed(i);
273 }
274
275 /** Automatic symbolic evaluation of an indexed metric tensor. */
276 ex spinmetric::eval_indexed(const basic & i) const
277 {
278         GINAC_ASSERT(is_a<indexed>(i));
279         GINAC_ASSERT(i.nops() == 3);
280         GINAC_ASSERT(is_a<spinmetric>(i.op(0)));
281         GINAC_ASSERT(is_a<spinidx>(i.op(1)));
282         GINAC_ASSERT(is_a<spinidx>(i.op(2)));
283
284         const spinidx & i1 = ex_to<spinidx>(i.op(1));
285         const spinidx & i2 = ex_to<spinidx>(i.op(2));
286
287         // Convolutions are zero
288         if (!(static_cast<const indexed &>(i).get_dummy_indices().empty()))
289                 return _ex0;
290
291         // Numeric evaluation
292         if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
293                 int n1 = ex_to<numeric>(i1.get_value()).to_int(), n2 = ex_to<numeric>(i2.get_value()).to_int();
294                 if (n1 == n2)
295                         return _ex0;
296                 else if (n1 < n2)
297                         return _ex1;
298                 else
299                         return _ex_1;
300         }
301
302         // No further simplifications
303         return i.hold();
304 }
305
306 /** Automatic symbolic evaluation of an indexed epsilon tensor. */
307 ex tensepsilon::eval_indexed(const basic & i) const
308 {
309         GINAC_ASSERT(is_a<indexed>(i));
310         GINAC_ASSERT(i.nops() > 1);
311         GINAC_ASSERT(is_a<tensepsilon>(i.op(0)));
312
313         // Convolutions are zero
314         if (!(static_cast<const indexed &>(i).get_dummy_indices().empty()))
315                 return _ex0;
316
317         // Numeric evaluation
318         if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
319
320                 // Get sign of index permutation (the indices should already be in
321                 // a canonic order but we can't assume what exactly that order is)
322                 std::vector<int> v;
323                 v.reserve(i.nops() - 1);
324                 for (size_t j=1; j<i.nops(); j++)
325                         v.push_back(ex_to<numeric>(ex_to<idx>(i.op(j)).get_value()).to_int());
326                 int sign = permutation_sign(v.begin(), v.end());
327
328                 // In a Minkowski space, check for covariant indices
329                 if (minkowski) {
330                         for (size_t j=1; j<i.nops(); j++) {
331                                 const ex & x = i.op(j);
332                                 if (!is_a<varidx>(x))
333                                         throw(std::runtime_error("indices of epsilon tensor in Minkowski space must be of type varidx"));
334                                 if (ex_to<varidx>(x).is_covariant())
335                                         if (ex_to<idx>(x).get_value().is_zero())
336                                                 sign = (pos_sig ? -sign : sign);
337                                         else
338                                                 sign = (pos_sig ? sign : -sign);
339                         }
340                 }
341
342                 return sign;
343         }
344
345         // No further simplifications
346         return i.hold();
347 }
348
349 bool tensor::replace_contr_index(exvector::iterator self, exvector::iterator other) const
350 {
351         // Try to contract the first index
352         const idx *self_idx = &ex_to<idx>(self->op(1));
353         const idx *free_idx = &ex_to<idx>(self->op(2));
354         bool first_index_tried = false;
355
356 again:
357         if (self_idx->is_symbolic()) {
358                 for (size_t i=1; i<other->nops(); i++) {
359                         const idx &other_idx = ex_to<idx>(other->op(i));
360                         if (is_dummy_pair(*self_idx, other_idx)) {
361
362                                 // Contraction found, remove this tensor and substitute the
363                                 // index in the second object
364                                 try {
365                                         // minimal_dim() throws an exception when index dimensions are not comparable
366                                         ex min_dim = self_idx->minimal_dim(other_idx);
367                                         *other = other->subs(other_idx == free_idx->replace_dim(min_dim));
368                                         *self = _ex1; // *other is assigned first because assigning *self invalidates free_idx
369                                         return true;
370                                 } catch (std::exception &e) {
371                                         return false;
372                                 }
373                         }
374                 }
375         }
376
377         if (!first_index_tried) {
378
379                 // No contraction with the first index found, try the second index
380                 self_idx = &ex_to<idx>(self->op(2));
381                 free_idx = &ex_to<idx>(self->op(1));
382                 first_index_tried = true;
383                 goto again;
384         }
385
386         return false;
387 }
388
389 /** Contraction of an indexed delta tensor with something else. */
390 bool tensdelta::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
391 {
392         GINAC_ASSERT(is_a<indexed>(*self));
393         GINAC_ASSERT(is_a<indexed>(*other));
394         GINAC_ASSERT(self->nops() == 3);
395         GINAC_ASSERT(is_a<tensdelta>(self->op(0)));
396
397         // Replace the dummy index with this tensor's other index and remove
398         // the tensor (this is valid for contractions with all other tensors)
399         return replace_contr_index(self, other);
400 }
401
402 /** Contraction of an indexed metric tensor with something else. */
403 bool tensmetric::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
404 {
405         GINAC_ASSERT(is_a<indexed>(*self));
406         GINAC_ASSERT(is_a<indexed>(*other));
407         GINAC_ASSERT(self->nops() == 3);
408         GINAC_ASSERT(is_a<tensmetric>(self->op(0)));
409
410         // If contracting with the delta tensor, let the delta do it
411         // (don't raise/lower delta indices)
412         if (is_a<tensdelta>(other->op(0)))
413                 return false;
414
415         // Replace the dummy index with this tensor's other index and remove
416         // the tensor
417         return replace_contr_index(self, other);
418 }
419
420 /** Contraction of an indexed spinor metric with something else. */
421 bool spinmetric::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() == 3);
426         GINAC_ASSERT(is_a<spinmetric>(self->op(0)));
427
428         // Contractions between spinor metrics
429         if (is_a<spinmetric>(other->op(0))) {
430                 const idx &self_i1 = ex_to<idx>(self->op(1));
431                 const idx &self_i2 = ex_to<idx>(self->op(2));
432                 const idx &other_i1 = ex_to<idx>(other->op(1));
433                 const idx &other_i2 = ex_to<idx>(other->op(2));
434
435                 if (is_dummy_pair(self_i1, other_i1)) {
436                         if (is_dummy_pair(self_i2, other_i2))
437                                 *self = _ex2;
438                         else
439                                 *self = delta_tensor(self_i2, other_i2);
440                         *other = _ex1;
441                         return true;
442                 } else if (is_dummy_pair(self_i1, other_i2)) {
443                         if (is_dummy_pair(self_i2, other_i1))
444                                 *self = _ex_2;
445                         else
446                                 *self = -delta_tensor(self_i2, other_i1);
447                         *other = _ex1;
448                         return true;
449                 } else if (is_dummy_pair(self_i2, other_i1)) {
450                         *self = -delta_tensor(self_i1, other_i2);
451                         *other = _ex1;
452                         return true;
453                 } else if (is_dummy_pair(self_i2, other_i2)) {
454                         *self = delta_tensor(self_i1, other_i1);
455                         *other = _ex1;
456                         return true;
457                 }
458         }
459
460         // If contracting with the delta tensor, let the delta do it
461         // (don't raise/lower delta indices)
462         if (is_a<tensdelta>(other->op(0)))
463                 return false;
464
465         // Try to contract first index
466         const idx *self_idx = &ex_to<idx>(self->op(1));
467         const idx *free_idx = &ex_to<idx>(self->op(2));
468         bool first_index_tried = false;
469         int sign = 1;
470
471 again:
472         if (self_idx->is_symbolic()) {
473                 for (size_t i=1; i<other->nops(); i++) {
474                         const idx &other_idx = ex_to<idx>(other->op(i));
475                         if (is_dummy_pair(*self_idx, other_idx)) {
476
477                                 // Contraction found, remove metric tensor and substitute
478                                 // index in second object (assign *self last because this
479                                 // invalidates free_idx)
480                                 *other = other->subs(other_idx == *free_idx);
481                                 *self = (static_cast<const spinidx *>(self_idx)->is_covariant() ? sign : -sign);
482                                 return true;
483                         }
484                 }
485         }
486
487         if (!first_index_tried) {
488
489                 // No contraction with first index found, try second index
490                 self_idx = &ex_to<idx>(self->op(2));
491                 free_idx = &ex_to<idx>(self->op(1));
492                 first_index_tried = true;
493                 sign = -sign;
494                 goto again;
495         }
496
497         return false;
498 }
499
500 /** Contraction of epsilon tensor with something else. */
501 bool tensepsilon::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
502 {
503         GINAC_ASSERT(is_a<indexed>(*self));
504         GINAC_ASSERT(is_a<indexed>(*other));
505         GINAC_ASSERT(is_a<tensepsilon>(self->op(0)));
506         size_t num = self->nops() - 1;
507
508         if (is_exactly_a<tensepsilon>(other->op(0)) && num+1 == other->nops()) {
509
510                 // Contraction of two epsilon tensors is a determinant
511                 bool variance = is_a<varidx>(self->op(1));
512                 matrix M(num, num);
513                 for (size_t i=0; i<num; i++) {
514                         for (size_t j=0; j<num; j++) {
515                                 if (minkowski)
516                                         M(i, j) = lorentz_g(self->op(i+1), other->op(j+1), pos_sig);
517                                 else if (variance)
518                                         M(i, j) = metric_tensor(self->op(i+1), other->op(j+1));
519                                 else
520                                         M(i, j) = delta_tensor(self->op(i+1), other->op(j+1));
521                         }
522                 }
523                 int sign = minkowski ? -1 : 1;
524                 *self = sign * M.determinant().simplify_indexed();
525                 *other = _ex1;
526                 return true;
527         }
528
529         return false;
530 }
531
532 //////////
533 // global functions
534 //////////
535
536 ex delta_tensor(const ex & i1, const ex & i2)
537 {
538         if (!is_a<idx>(i1) || !is_a<idx>(i2))
539                 throw(std::invalid_argument("indices of delta tensor must be of type idx"));
540
541         return indexed(tensdelta(), sy_symm(), i1, i2);
542 }
543
544 ex metric_tensor(const ex & i1, const ex & i2)
545 {
546         if (!is_a<varidx>(i1) || !is_a<varidx>(i2))
547                 throw(std::invalid_argument("indices of metric tensor must be of type varidx"));
548
549         return indexed(tensmetric(), sy_symm(), i1, i2);
550 }
551
552 ex lorentz_g(const ex & i1, const ex & i2, bool pos_sig)
553 {
554         if (!is_a<varidx>(i1) || !is_a<varidx>(i2))
555                 throw(std::invalid_argument("indices of metric tensor must be of type varidx"));
556
557         return indexed(minkmetric(pos_sig), sy_symm(), i1, i2);
558 }
559
560 ex spinor_metric(const ex & i1, const ex & i2)
561 {
562         if (!is_a<spinidx>(i1) || !is_a<spinidx>(i2))
563                 throw(std::invalid_argument("indices of spinor metric must be of type spinidx"));
564         if (!ex_to<idx>(i1).get_dim().is_equal(2) || !ex_to<idx>(i2).get_dim().is_equal(2))
565                 throw(std::runtime_error("index dimension for spinor metric must be 2"));
566
567         return indexed(spinmetric(), sy_anti(), i1, i2);
568 }
569
570 ex epsilon_tensor(const ex & i1, const ex & i2)
571 {
572         if (!is_a<idx>(i1) || !is_a<idx>(i2))
573                 throw(std::invalid_argument("indices of epsilon tensor must be of type idx"));
574
575         ex dim = ex_to<idx>(i1).get_dim();
576         if (!dim.is_equal(ex_to<idx>(i2).get_dim()))
577                 throw(std::invalid_argument("all indices of epsilon tensor must have the same dimension"));
578         if (!ex_to<idx>(i1).get_dim().is_equal(_ex2))
579                 throw(std::runtime_error("index dimension of epsilon tensor must match number of indices"));
580
581         return indexed(tensepsilon(), sy_anti(), i1, i2);
582 }
583
584 ex epsilon_tensor(const ex & i1, const ex & i2, const ex & i3)
585 {
586         if (!is_a<idx>(i1) || !is_a<idx>(i2) || !is_a<idx>(i3))
587                 throw(std::invalid_argument("indices of epsilon tensor must be of type idx"));
588
589         ex dim = ex_to<idx>(i1).get_dim();
590         if (!dim.is_equal(ex_to<idx>(i2).get_dim()) || !dim.is_equal(ex_to<idx>(i3).get_dim()))
591                 throw(std::invalid_argument("all indices of epsilon tensor must have the same dimension"));
592         if (!ex_to<idx>(i1).get_dim().is_equal(_ex3))
593                 throw(std::runtime_error("index dimension of epsilon tensor must match number of indices"));
594
595         return indexed(tensepsilon(), sy_anti(), i1, i2, i3);
596 }
597
598 ex lorentz_eps(const ex & i1, const ex & i2, const ex & i3, const ex & i4, bool pos_sig)
599 {
600         if (!is_a<varidx>(i1) || !is_a<varidx>(i2) || !is_a<varidx>(i3) || !is_a<varidx>(i4))
601                 throw(std::invalid_argument("indices of Lorentz epsilon tensor must be of type varidx"));
602
603         ex dim = ex_to<idx>(i1).get_dim();
604         if (!dim.is_equal(ex_to<idx>(i2).get_dim()) || !dim.is_equal(ex_to<idx>(i3).get_dim()) || !dim.is_equal(ex_to<idx>(i4).get_dim()))
605                 throw(std::invalid_argument("all indices of epsilon tensor must have the same dimension"));
606         if (!ex_to<idx>(i1).get_dim().is_equal(_ex4))
607                 throw(std::runtime_error("index dimension of epsilon tensor must match number of indices"));
608
609         return indexed(tensepsilon(true, pos_sig), sy_anti(), i1, i2, i3, i4);
610 }
611
612 } // namespace GiNaC