]> www.ginac.de Git - ginac.git/blobdiff - ginac/tensor.cpp
- symbols can have a LaTeX name, e.g. symbol s("s", "\\sigma");
[ginac.git] / ginac / tensor.cpp
index b180ec9e9a7e6966cdabb06ddbdd686e201aa479..928c6568693ec6687d00569071f5293e9d8f44a6 100644 (file)
@@ -27,7 +27,9 @@
 #include "idx.h"
 #include "indexed.h"
 #include "relational.h"
+#include "lst.h"
 #include "numeric.h"
+#include "print.h"
 #include "archive.h"
 #include "utils.h"
 #include "debugmsg.h"
@@ -160,10 +162,10 @@ int tensepsilon::compare_same_type(const basic & other) const
                return inherited::compare_same_type(other);
 }
 
-DEFAULT_PRINT(tensdelta, "delta")
+DEFAULT_PRINT_LATEX(tensdelta, "delta", "\\delta")
 DEFAULT_PRINT(tensmetric, "g")
-DEFAULT_PRINT(minkmetric, "eta")
-DEFAULT_PRINT(tensepsilon, "eps")
+DEFAULT_PRINT_LATEX(minkmetric, "eta", "\\eta")
+DEFAULT_PRINT_LATEX(tensepsilon, "eps", "\\epsilon")
 
 /** Automatic symbolic evaluation of an indexed delta tensor. */
 ex tensdelta::eval_indexed(const basic & i) const
@@ -333,7 +335,7 @@ bool tensmetric::contract_with(exvector::iterator self, exvector::iterator other
 
        // If contracting with the delta tensor, let the delta do it
        // (don't raise/lower delta indices)
-       if (is_ex_exactly_of_type(other->op(0), tensdelta))
+       if (is_ex_of_type(other->op(0), tensdelta))
                return false;
 
        // Try to contract first index
@@ -438,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