17 void Eps::accept(GiNaC::visitor & v)
const {
if (
visitor *p =
dynamic_cast<visitor *
>(&v)) p->visit(*
this);
else inherited::accept(v); }
33 pis.resize(
vs.size()+is.size());
35 for(
auto vi :
vs)
pis[i++] = vi;
36 for(
auto ii : is)
pis[i++] = ii;
41 for(
int i=0; i<n; i++)
pis[i] = pis0[i];
45 if(!is_a<Eps>(other))
throw Error(
"Eps::compare_same_type");
46 const Eps &o =
static_cast<const Eps &
>(other);
48 int no = o.
pis.size();
49 if(n!=no)
return n>no ? 1 : -1;
50 for(
int i=0; i<n; i++) {
51 auto c =
pis[i].compare(o.
pis[i]);
58 if(!is_a<Eps>(other))
throw Error(
"Eps::is_equal_same_type");
59 const Eps &o =
static_cast<const Eps &
>(other);
61 int no = o.
pis.size();
62 if(n!=no)
return false;
63 for(
int i=0; i<n; i++) {
64 if(!
pis[i].is_equal(o.
pis[i]))
return false;
70 if(flags & status_flags::evaluated)
return *
this;
75 for(
int i=0; i<4; i++) {
76 if(!is_a<Vector>(
pis[i]) && !is_a<Index>(
pis[i])) ok =
false;
77 else if(is_a<Vector>(
pis[i]) && ii!=4) ok =
false;
78 else if(is_a<Index>(
pis[i]) && ii==4) ii = i;
83 const ex* pis_a =
pis.data();
87 for(
int i=0; i<4; i++) pis2[i] =
pis[i];
89 int ac2 =
ACSort(4-ii,pis2+ii);
90 if(ac1 * ac2==0)
return 0;
91 return ac1 * ac2 *
LC(pis2[0],pis2[1],pis2[2],pis2[3]);
93 }
else return this->hold();
96 void Eps::print(
const print_dflt &c,
unsigned level)
const {
98 c.s <<
"\u03B5" <<
"(";
99 for(
int i=0; i<n-1; i++) c.s <<
pis[i] <<
",";
100 c.s <<
pis[n-1] <<
")";
114 if(n==4) c <<
"(i_*";
116 for(
int i=0; i<n-1; i++) c <<
pis[i] <<
",";
117 c <<
pis[n-1] <<
")";
126 for(
int i=3; i>=0; i--) {
127 if(is_a<Vector>(
pis[i]) && first) {
134 else if(!first || !is_a<Vector>(
pis[i-1])) c <<
",";
145 ensure_if_modifiable();
150 inherited::archive(n);
152 n.add_ex(
"size", nn);
153 for(
int i=0; i<nn; i++) n.add_ex(
"pis"+to_string(i),
pis[i]);
157 inherited::read_archive(n);
159 n.find_ex(
"size", nex);
160 int nn = ex_to<numeric>(nex).to_int();
161 if(
pis.size()!=nn)
pis.resize(nn);
162 for(
int i=0; i<nn; i++) {
163 n.find_ex(
"pis"+to_string(i),
pis[i]);
179 ex
LC(ex pi1, ex pi2, ex pi3, ex pi4) {
181 lst pis = lst {pi1, pi2, pi3, pi4};
183 if(!is_a<Vector>(pi) && !is_a<Index>(pi)) {
193 for(
int i=0; i<4; i++) {
194 if(is_a<Vector>(pis.op(i))) {
195 vs.push_back(ex_to<Vector>(pis.op(i)));
196 sign *= pow(-1, is.size());
197 }
else is.push_back(ex_to<Index>(pis.op(i)));
199 return sign*
Eps(
vs, is);
202 for(
int i=0; i<4; i++) {
203 auto pi =
collect_lst(pis.op(i), [](
const ex & e)->bool{return Index::has(e) || Vector::has(e);});
204 for(
auto item : pi) {
205 if(!is_a<Vector>(item.op(1)) && !is_a<Index>(item.op(1))) {
206 cout <<
"pi = " << pi << endl;
207 throw Error(
"LC Error: there is no Index or Vector.");
214 for(
auto i0 : pis.op(0))
215 for(
auto i1 : pis.op(1))
216 for(
auto i2 : pis.op(2))
217 for(
auto i3 : pis.op(3)) {
218 res += i0.op(0)*i1.op(0)*i2.op(0)*i3.op(0) *
LC(i0.op(1), i1.op(1), i2.op(1), i3.op(1));
#define IMPLEMENT_HAS(classname)
#define DEFAULT_CTOR(classname)
#define IMPLEMENT_ALL(classname)
class for Levi-Civita object https://onlinelibrary.wiley.com/doi/pdf/10.1002/9783527630097....
const char * class_name() const override
int compare_same_type(const GiNaC::basic &other) const override
void fc_print(const FCFormat &c, unsigned level=0) const
bool is_equal_same_type(const basic &other) const override
ex op(size_t i) const override
void form_print(const FormFormat &c, unsigned level=0) const
Eps in FORM format https://onlinelibrary.wiley.com/doi/pdf/10.1002/9783527630097.app3 to make Tr(g5,...
Eps * duplicate() const override
ex derivative(const symbol &s) const override
void accept(GiNaC::visitor &v) const override
void print(const print_dflt &c, unsigned level=0) const
ex & let_op(size_t i) override
void archive(archive_node &n) const override
size_t nops() const override
static GiNaC::registered_class_info & get_class_info_static()
void read_archive(const archive_node &n) override
const GiNaC::registered_class_info & get_class_info() const override
class used to wrap error message
bool isSorted(const lst &exs)
lst collect_lst(ex const &expr_in, std::function< bool(const ex &)> has_func, int opt)
the collect function like Mathematica, reture the lst { {c1,v1}, {c2,v2}, ... }
ex LC(ex pi1, ex pi2, ex pi3, ex pi4)
function similar to LCD in FeynCalc