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);
96 else if(i==1)
return rl;
101 static ex ex_rl = numeric(
rl);
102 ensure_if_modifiable();
108 if(flags & status_flags::evaluated)
return *
this;
109 else if(is_zero(
pi) || is_zero(
pi-1) || is_zero(
pi-5) || is_zero(
pi-6) || is_zero(
pi-7))
return this->hold();
110 else if(!is_a<Vector>(
pi) && !is_a<Index>(
pi))
return GAS(
pi,
rl);
111 else return this->hold();
118 }
else if(is_zero(
pi-5) || is_zero(
pi-6) || is_zero(
pi-7)) {
120 if(is_a<numeric>(
pi)) c.s <<
pi;
121 else c.s <<
"." <<
pi;
124 c.s <<
"(" <<
"\u0263";
125 if(is_a<numeric>(
pi)) c.s <<
pi;
126 else c.s <<
"." <<
pi;
131 if(!is_a<numeric>(
pi)) c <<
"g_(" <<
rl <<
"," <<
pi <<
")";
132 else if(is_zero(
pi-1)) c <<
"gi_(" <<
rl <<
")";
133 else if(is_zero(
pi-5)) c <<
"g5_(" <<
rl <<
")";
134 else if(is_zero(
pi-6)) c <<
"g6_(" <<
rl <<
")";
135 else if(is_zero(
pi-7)) c <<
"g7_(" <<
rl <<
")";
136 else throw Error(
"DGamma::form_print unexpected region.");
144 if(is_a<Vector>(
pi)) c <<
"GSD";
146 c <<
"[" <<
pi <<
"]";
150 inherited::archive(n);
152 n.add_unsigned(
"rl",
rl);
156 inherited::read_archive(n);
157 n.find_unsigned(
"rl",
rl);
166 if(is_a<Index>(
pi) || is_a<Vector>(
pi))
return *
this;
167 else if(is_zero(
pi-5))
return (-1)*
DGamma(5,
rl);
171 throw Error(
"invalid Dirac Gamma Found.");
178 void TR_form_print(
const ex &arg,
const print_context &c0) {
180 c <<
"(" << arg <<
")";
182 void TR_fc_print(
const ex &arg,
const print_context &c0) {
183 auto c =
static_cast<const FCFormat &
>(c0);
184 c <<
"DiracTrace[" << arg <<
"]";
186 ex tr_conj(
const ex & e) {
187 return TR(e.conjugate());
190 void TTR_form_print(
const ex &arg,
const print_context &c0) {
191 auto c =
static_cast<const FormFormat &
>(c0);
192 if(!is_a<lst>(arg)) c <<
"TTR(" << arg <<
")";
195 for(
auto item : arg) {
196 if(first) { first=
false; c <<
"TTR(" << item; }
197 else c <<
"," << item;
202 void TTR_fc_print(
const ex &arg,
const print_context &c0) {
203 auto c =
static_cast<const FCFormat &
>(c0);
204 if(!is_a<lst>(arg)) c <<
"SUNTrace[SUNT[" << arg <<
"]]";
207 for(
auto item : arg) {
208 if(first) { first=
false; c <<
"SUNTrace[SUNT[" << item; }
209 else c <<
"," << item;
214 ex ttr_conj(
const ex & e) {
216 if(!is_a<lst>(e))
return TTR(e);
217 else argv = ex_to<lst>(e);
219 for(
auto it=argv.rbegin(); it!=argv.rend(); ++it)
as.append(*it);
225 conjugate_func(tr_conj).
226 print_func<FormFormat>(&TR_form_print).
227 print_func<FCFormat>(&TR_fc_print).
228 set_return_type(return_types::commutative).
229 expl_derivative_func(expl_TR_diff)
233 conjugate_func(ttr_conj).
234 print_func<FormFormat>(&TTR_form_print).
235 print_func<FCFormat>(&TTR_fc_print)
246 ex
GAS(
const ex &expr,
unsigned rl) {
247 if(is_zero(expr))
return 0;
248 else if(is_zero(expr-1))
return DGamma(1,rl);
249 else if(is_zero(expr-5))
return DGamma(5,rl);
250 else if(is_zero(expr-6))
return DGamma(6,rl);
251 else if(is_zero(expr-7))
return DGamma(7,rl);
253 ex tmp = expand(expr);
256 for(
auto item : tmp) ex_lst.append(item);
257 }
else ex_lst.append(tmp);
259 for(
auto item : ex_lst) {
261 if(is_a<mul>(item)) {
262 for(
auto ii : item) mul_lst.append(ii);
263 }
else mul_lst.append(item);
265 for(
auto ii : mul_lst) {
266 if(is_a<Vector>(ii)) {
267 if(is_a<DGamma>(g))
throw Error(
"Something Wrong with GAS @1, g="+
ex2str(g));
268 g =
DGamma(ex_to<Vector>(ii),rl);
269 }
else if(is_a<Index>(ii)) {
270 if(is_a<DGamma>(g))
throw Error(
"Something Wrong with GAS @2, g="+
ex2str(g));
271 g =
DGamma(ex_to<Index>(ii),rl);
276 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
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 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)
do_not_evalf_params().expl_derivative_func(zd1D).derivative_func(zp1D)) REGISTER_FUNCTION(FTX
ex GAS(const ex &expr, unsigned rl)
function similar to GAD/GSD in FeynClac
REGISTER_FUNCTION(Matrix, do_not_evalf_params().print_func< FCFormat >(&Matrix_fc_print).conjugate_func(mat_conj).set_return_type(return_types::commutative)) bool IsZero(const ex &e)
string ex2str(const ex &expr)
convert ex to output string, the defalut printer format will be used