#include "idx.h"
#include "ncmul.h"
#include "symbol.h"
+#include "numeric.h" // for I
#include "print.h"
#include "archive.h"
#include "debugmsg.h"
return ti == (TINFO_clifford + rl);
}
-ex dirac_trace(const ex & e, unsigned char rl)
+ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
{
if (is_ex_of_type(e, clifford)) {
if (ex_to_clifford(e).get_representation_label() == rl
&& is_ex_of_type(e.op(0), diracone))
- return _ex4();
+ return trONE;
else
return _ex0();
// Trace of sum = sum of traces
ex sum = _ex0();
for (unsigned i=0; i<e.nops(); i++)
- sum += dirac_trace(e.op(i), rl);
+ sum += dirac_trace(e.op(i), rl, trONE);
return sum;
} else if (is_ex_exactly_of_type(e, mul)) {
const ex &o = e.op(i);
unsigned ti = o.return_type_tinfo();
if (is_clifford_tinfo(o.return_type_tinfo(), rl))
- prod *= dirac_trace(o, rl);
+ prod *= dirac_trace(o, rl, trONE);
else
prod *= o;
}
// Expand product, if necessary
ex e_expanded = e.expand();
if (!is_ex_of_type(e_expanded, ncmul))
- return dirac_trace(e_expanded, rl);
+ return dirac_trace(e_expanded, rl, trONE);
// gamma5 gets moved to the front so this check is enough
bool has_gamma5 = is_ex_of_type(e.op(0).op(0), diracgamma5);
return _ex0();
// Tr gamma5 S_2k =
- // epsilon0123.mu1.mu2.mu3.mu4 * Tr gamma.mu1 gamma.mu2 gamma.mu3 gamma.mu4 S_2k
+ // I/4! * epsilon0123.mu1.mu2.mu3.mu4 * Tr gamma.mu1 gamma.mu2 gamma.mu3 gamma.mu4 S_2k
ex dim = ex_to_idx(e.op(1).op(1)).get_dim();
varidx mu1((new symbol)->setflag(status_flags::dynallocated), dim),
mu2((new symbol)->setflag(status_flags::dynallocated), dim),
v.push_back(e.op(i));
return (eps0123(mu1.toggle_variance(), mu2.toggle_variance(), mu3.toggle_variance(), mu4.toggle_variance()) *
- dirac_trace(ncmul(v), rl)).simplify_indexed() / 24;
+ dirac_trace(ncmul(v), rl, trONE)).simplify_indexed() * I / 24;
} else { // no gamma5
// Tr gamma.mu gamma.nu = 4 g.mu.nu
if (num == 2)
- return 4 * lorentz_g(e.op(0).op(1), e.op(1).op(1));
+ return trONE * lorentz_g(e.op(0).op(1), e.op(1).op(1));
// Traces of 4 or more gammas are computed recursively:
// Tr gamma.mu1 gamma.mu2 ... gamma.mun =
continue;
v[j++] = e.op(n);
}
- result += sign * lorentz_g(ix1, e.op(i).op(1)) * dirac_trace(ncmul(v), rl);
+ result += sign * lorentz_g(ix1, e.op(i).op(1)) * dirac_trace(ncmul(v), rl, trONE);
sign = -sign;
}
return result;
* In particular, the functional is not always cyclic in D != 4 dimensions
* when gamma5 is involved.
*
- * @param rl Representation label */
-ex dirac_trace(const ex & e, unsigned char rl = 0);
+ * @param e Expression to take the trace of
+ * @param rl Representation label
+ * @param trONE Expression to be returned as the trace of the unit matrix */
+ex dirac_trace(const ex & e, unsigned char rl = 0, const ex & trONE = 4);
} // namespace GiNaC