X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Ftensor.cpp;h=d16bbfce4b7949b85359f926767673c5f66c839f;hp=ed6ad9dc4fbe373ac590d40b6ab48e64d424cbf2;hb=43e0a8f5ca5e1c48cef5daaf014acdbca4e44568;hpb=9c91319253425e66f9b6feb9e7036f841bc55e84 diff --git a/ginac/tensor.cpp b/ginac/tensor.cpp index ed6ad9dc..d16bbfce 100644 --- a/ginac/tensor.cpp +++ b/ginac/tensor.cpp @@ -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" @@ -179,6 +181,15 @@ ex tensdelta::eval_indexed(const basic & i) const if (is_dummy_pair(i1, i2)) return i1.get_dim(); + // Numeric evaluation + if (static_cast(i).all_index_values_are(info_flags::integer)) { + int n1 = ex_to_numeric(i1.get_value()).to_int(), n2 = ex_to_numeric(i2.get_value()).to_int(); + if (n1 == n2) + return _ex1(); + else + return _ex0(); + } + // No further simplifications return i.hold(); } @@ -324,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 @@ -429,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