10 static ex expl_TR_diff2(
const ex & arg,
const symbol & s) {
11 auto ret = arg.diff(s);
12 if(!is_a<add>(ret)) ret = lst{ret};
14 for(
auto item : ret) {
15 if(!is_a<mul>(item)) res += TR(item);
28 static ex expl_TR_diff(
const ex & arg,
const symbol & s) {
29 auto ret = arg.diff(s);
30 auto nd = numer_denom(ret.normal());
31 auto num = collect_common_factors(nd.op(0));
32 if(!is_a<mul>(num))
return TR(num)/nd.op(1);
39 return c*TR(v)/nd.op(1);
60 return make_return_type_t<clifford>(
rl);
74 if(!is_a<DGamma>(other))
throw Error(
"DGamma::compare_same_type");
76 if (
rl != o.
rl)
return rl < o.
rl ? -1 : 1;
77 return pi.compare(o.
pi);
81 if(!is_a<DGamma>(other))
throw Error(
"DGamma::is_equal_same_type");
83 if (
rl != o.
rl)
return false;
84 return pi.is_equal(o.
pi);
95 else if(i==1)
return rl;
100 static ex ex_rl = numeric(
rl);
101 ensure_if_modifiable();
107 if(flags & status_flags::evaluated)
return *
this;
108 else if(is_zero(
pi) || is_zero(
pi-1) || is_zero(
pi-5) || is_zero(
pi-6) || is_zero(
pi-7))
return this->hold();
109 else if(!is_a<Vector>(
pi) && !is_a<Index>(
pi))
return GAS(
pi,
rl);
110 else return this->hold();
117 }
else if(is_zero(
pi-5) || is_zero(
pi-6) || is_zero(
pi-7)) {
119 if(is_a<numeric>(
pi)) c.s <<
pi;
120 else c.s <<
"." <<
pi;
123 c.s <<
"(" <<
"\u0263";
124 if(is_a<numeric>(
pi)) c.s <<
pi;
125 else c.s <<
"." <<
pi;
130 if(!is_a<numeric>(
pi)) c <<
"g_(" <<
rl <<
"," <<
pi <<
")";
131 else if(is_zero(
pi-1)) c <<
"gi_(" <<
rl <<
")";
132 else if(is_zero(
pi-5)) c <<
"g5_(" <<
rl <<
")";
133 else if(is_zero(
pi-6)) c <<
"g6_(" <<
rl <<
")";
134 else if(is_zero(
pi-7)) c <<
"g7_(" <<
rl <<
")";
135 else throw Error(
"DGamma::form_print unexpected region.");
143 if(is_a<Vector>(
pi)) c <<
"GSD";
145 c <<
"[" <<
pi <<
"]";
149 inherited::archive(n);
151 n.add_unsigned(
"rl",
rl);
155 inherited::read_archive(n);
156 n.find_unsigned(
"rl",
rl);
165 if(is_a<Index>(
pi) || is_a<Vector>(
pi))
return *
this;
166 else if(is_zero(
pi-5))
return (-1)*
DGamma(5,
rl);
170 throw Error(
"invalid Dirac Gamma Found.");
178 Index a(
"g5Idx"+to_string(i));
179 Index b(
"g5Idx"+to_string(i+1));
180 Index c(
"g5Idx"+to_string(i+2));
181 Index d(
"g5Idx"+to_string(i+3));
189 void TR_form_print(
const ex &arg,
const print_context &c0) {
191 c <<
"(" << arg <<
")";
193 void TR_fc_print(
const ex &arg,
const print_context &c0) {
194 auto c =
static_cast<const FCFormat &
>(c0);
195 c <<
"DiracTrace[" << arg <<
"]";
197 ex tr_conj(
const ex & e) {
198 return TR(e.conjugate());
201 void TTR_form_print(
const ex &arg,
const print_context &c0) {
202 auto c =
static_cast<const FormFormat &
>(c0);
203 if(!is_a<lst>(arg)) c <<
"TTR(" << arg <<
")";
206 for(
auto item : arg) {
207 if(first) { first=
false; c <<
"TTR(" << item; }
208 else c <<
"," << item;
213 void TTR_fc_print(
const ex &arg,
const print_context &c0) {
214 auto c =
static_cast<const FCFormat &
>(c0);
215 if(!is_a<lst>(arg)) c <<
"SUNTrace[SUNT[" << arg <<
"]]";
218 for(
auto item : arg) {
219 if(first) { first=
false; c <<
"SUNTrace[SUNT[" << item; }
220 else c <<
"," << item;
225 ex ttr_conj(
const ex & e) {
227 if(!is_a<lst>(e))
return TTR(e);
228 else argv = ex_to<lst>(e);
230 for(
auto it=argv.rbegin(); it!=argv.rend(); ++it)
as.append(*it);
236 conjugate_func(tr_conj).
237 print_func<FormFormat>(&TR_form_print).
238 print_func<FCFormat>(&TR_fc_print).
239 set_return_type(return_types::commutative).
240 expl_derivative_func(expl_TR_diff)
244 conjugate_func(ttr_conj).
245 print_func<FormFormat>(&TTR_form_print).
246 print_func<FCFormat>(&TTR_fc_print)
257 ex
GAS(
const ex &expr,
unsigned rl) {
258 if(is_zero(expr))
return 0;
259 else if(is_zero(expr-1))
return DGamma(1,rl);
260 else if(is_zero(expr-5))
return DGamma(5,rl);
261 else if(is_zero(expr-6))
return DGamma(6,rl);
262 else if(is_zero(expr-7))
return DGamma(7,rl);
264 ex tmp = expand(expr);
267 for(
auto item : tmp) ex_lst.append(item);
268 }
else ex_lst.append(tmp);
270 for(
auto item : ex_lst) {
272 if(is_a<mul>(item)) {
273 for(
auto ii : item) mul_lst.append(ii);
274 }
else mul_lst.append(item);
276 for(
auto ii : mul_lst) {
277 if(is_a<Vector>(ii)) {
278 if(is_a<DGamma>(g))
throw Error(
"Something Wrong with GAS @1, g="+
ex2str(g));
279 g =
DGamma(ex_to<Vector>(ii),rl);
280 }
else if(is_a<Index>(ii)) {
281 if(is_a<DGamma>(g))
throw Error(
"Something Wrong with GAS @2, g="+
ex2str(g));
282 g =
DGamma(ex_to<Index>(ii),rl);
287 if(!is_a<DGamma>(g))
throw Error(
"Something Wrong with GAS @3, g="+
ex2str(g));
#define IMPLEMENT_HAS(classname)
#define DEFAULT_CTOR(classname)
#define IMPLEMENT_ALL(classname)
class for Dirac Gamma object
bool match_same_type(const basic &other) const override
return_type_t return_type_tinfo() const override
ex derivative(const symbol &s) const override
void archive(archive_node &n) const override
void form_print(const FormFormat &c, unsigned level=0) const
void accept(GiNaC::visitor &v) const override
ex conjugate() const override
static GiNaC::registered_class_info & get_class_info_static()
void read_archive(const archive_node &n) override
static ex sigma(const ex &mu, const ex &nu)
size_t nops() const override
ex op(size_t i) const override
int compare_same_type(const GiNaC::basic &other) const override
void print(const print_dflt &c, unsigned level=0) const
static ex G5Eps(int i=0, int rl=0)
static bool has(const ex &e)
void fc_print(const FCFormat &c, unsigned level=0) const
const GiNaC::registered_class_info & get_class_info() const override
bool is_equal_same_type(const basic &other) const override
DGamma * duplicate() const override
ex & let_op(size_t i) override
const char * class_name() const override
class used to wrap error message
static bool has(const ex &e)
ex GAS(const ex &expr, unsigned rl)
function similar to GAD/GSD in FeynClac
string ex2str(const ex &expr)
convert ex to output string, the defalut printer format will be used
REGISTER_FUNCTION(GMat, do_not_evalf_params().print_func< FCFormat >(&GMat_fc_print).conjugate_func(mat_conj).set_return_type(return_types::commutative)) bool IsZero(const ex &e)
ex LC(ex pi1, ex pi2, ex pi3, ex pi4)
function similar to LCD in FeynCalc