]> www.ginac.de Git - ginac.git/blobdiff - ginac/tensor.cpp
- dirac_trace() handles arbitrary expressions (even unexpanded), including
[ginac.git] / ginac / tensor.cpp
index b53d6f7d0edb519a8ddee3ed6f5bd02855547971..d16bbfce4b7949b85359f926767673c5f66c839f 100644 (file)
@@ -29,6 +29,7 @@
 #include "relational.h"
 #include "lst.h"
 #include "numeric.h"
+#include "print.h"
 #include "archive.h"
 #include "utils.h"
 #include "debugmsg.h"
@@ -166,18 +167,6 @@ DEFAULT_PRINT(tensmetric, "g")
 DEFAULT_PRINT(minkmetric, "eta")
 DEFAULT_PRINT(tensepsilon, "eps")
 
-ex tensor::subs(const lst & ls, const lst & lr) const
-{
-       GINAC_ASSERT(ls.nops() == lr.nops());
-
-       for (unsigned i=0; i<ls.nops(); i++) {
-               if (is_ex_of_type(ls.op(i), tensor) &&
-                   compare_same_type(ex_to_tensor(ls.op(i)))==0)
-                       return lr.op(i);
-       }
-       return *this;
-}
-
 /** Automatic symbolic evaluation of an indexed delta tensor. */
 ex tensdelta::eval_indexed(const basic & i) const
 {
@@ -451,4 +440,16 @@ ex lorentz_eps(const ex & i1, const ex & i2, const ex & i3, const ex & i4, bool
        return indexed(tensepsilon(true, pos_sig), indexed::antisymmetric, i1, i2, i3, i4);
 }
 
+ex eps0123(const ex & i1, const ex & i2, const ex & i3, const ex & i4, bool pos_sig)
+{
+       if (!is_ex_of_type(i1, varidx) || !is_ex_of_type(i2, varidx) || !is_ex_of_type(i3, varidx) || !is_ex_of_type(i4, varidx))
+               throw(std::invalid_argument("indices of epsilon tensor must be of type varidx"));
+
+       ex dim = ex_to_idx(i1).get_dim();
+       if (dim.is_equal(4))
+               return lorentz_eps(i1, i2, i3, i4, pos_sig);
+       else
+               return indexed(tensepsilon(true, pos_sig), indexed::antisymmetric, i1, i2, i3, i4);
+}
+
 } // namespace GiNaC