X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fcolor.cpp;h=e36c1cbe9796effef77d085d228bb4f5be614894;hp=f8150c77481251dc24c746637ca0e1fc05558035;hb=43e0a8f5ca5e1c48cef5daaf014acdbca4e44568;hpb=d81773c9ebc817764485203f4892607a98667d48 diff --git a/ginac/color.cpp b/ginac/color.cpp index f8150c77..e36c1cbe 100644 --- a/ginac/color.cpp +++ b/ginac/color.cpp @@ -29,6 +29,7 @@ #include "ncmul.h" #include "numeric.h" #include "power.h" // for sqrt() +#include "symbol.h" #include "print.h" #include "archive.h" #include "debugmsg.h" @@ -409,4 +410,90 @@ ex color_h(const ex & a, const ex & b, const ex & c) return color_d(a, b, c) + I * color_f(a, b, c); } +/** Check whether a given tinfo key (as returned by return_type_tinfo() + * is that of a color object with the specified representation label. */ +static bool is_color_tinfo(unsigned ti, unsigned char rl) +{ + return ti == (TINFO_color + rl); +} + +ex color_trace(const ex & e, unsigned char rl) +{ + if (is_ex_of_type(e, color)) { + + if (ex_to_color(e).get_representation_label() == rl + && is_ex_of_type(e.op(0), su3one)) + return _ex3(); + else + return _ex0(); + + } else if (is_ex_exactly_of_type(e, add)) { + + // Trace of sum = sum of traces + ex sum = _ex0(); + for (unsigned i=0; isetflag(status_flags::dynallocated), 8); + + exvector v1; + v1.reserve(num - 2); + for (int i=0; i