8#include <ginac/ginac.h>
9#include <ginac/parser.h>
21#define DEFAULT_CTOR(classname) \
22classname::classname() { setflag(status_flags::evaluated | status_flags::expanded); }
24#define IMPLEMENT_HAS(classname) \
25bool classname::has(const ex &e) { \
26 for(const_preorder_iterator i = e.preorder_begin(); i != e.preorder_end(); ++i) if(is_a<classname>(*i)) return true; \
30#define IMPLEMENT_ALL(classname) \
31lst classname::all(const ex &e) { \
33 for(const_preorder_iterator i = e.preorder_begin(); i != e.preorder_end(); ++i) if(is_a<classname>(*i)) ret.append(*i); \
45 using namespace GiNaC;
49 extern unsigned nopat;
52 return e.subs(lst(sl));
56 for(
auto pi : ps)
if(expr.has(pi))
return true;
60 for(
auto pi : ps)
if(!expr.has(pi))
return false;
65 for(
auto pi : ps)
if(expr.is_equal(pi))
return true;
70 for(
auto pi : ps)
if(expr.match(pi))
return true;
74 for(
auto pi : ps)
if(!expr.match(pi))
return false;
79 #define RESET "\033[0m"
80 #define BLACK "\033[30m"
81 #define RED "\033[31m"
82 #define GREEN "\033[32m"
83 #define YELLOW "\033[33m"
84 #define BLUE "\033[34m"
85 #define MAGENTA "\033[35m"
86 #define CYAN "\033[36m"
87 #define WHITE "\033[37m"
88 #define BOLDBLACK "\033[1m\033[30m"
89 #define BOLDRED "\033[1m\033[31m"
90 #define BOLDGREEN "\033[1m\033[32m"
91 #define BOLDYELLOW "\033[1m\033[33m"
92 #define BOLDBLUE "\033[1m\033[34m"
93 #define BOLDMAGENTA "\033[1m\033[35m"
94 #define BOLDCYAN "\033[1m\033[36m"
95 #define BOLDWHITE "\033[1m\033[37m"
119 static GiNaC::registered_class_info reg_info;
127 template<
class B,
typename... Args>
friend B &
dynallocate(Args &&... args);
131 void accept(GiNaC::visitor & v)
const override;
132 const GiNaC::registered_class_info &
get_class_info()
const override;
140 explicit Symbol(
const string &s);
141 void archive(archive_node & n)
const override;
145 ex
eval()
const override;
146 ex
evalf()
const override;
147 ex
series(
const relational & s,
int order,
unsigned options = 0)
const override;
148 ex
subs(
const exmap & m,
unsigned options = 0)
const override {
return subs_one_level(m, options); }
159 unsigned get_domain()
const override {
return domain::positive; }
161 static bool has(
const ex &e);
162 static lst
all(
const ex &e);
163 static std::map<std::string, ex>
Table;
165 void set(
const ex & v)
const;
171 static void set(
const Symbol & s,
const ex & v);
172 static void set(
const string & str,
const ex & v);
174 static void unset(
const string &str);
176 static ex
set_all(
const ex & expr);
179 ex
derivative(
const symbol & s)
const override;
189 static GiNaC::registered_class_info reg_info;
197 template<
class B,
typename... Args>
friend B &
dynallocate(Args &&... args);
201 void accept(GiNaC::visitor & v)
const override;
202 const GiNaC::registered_class_info &
get_class_info()
const override;
211 void archive(archive_node & n)
const override;
214 unsigned get_domain()
const override {
return domain::complex; }
217 ex
eval()
const override;
218 ex
evalf()
const override;
219 ex
series(
const relational & s,
int order,
unsigned options = 0)
const override;
220 ex
subs(
const exmap & m,
unsigned options = 0)
const override {
return subs_one_level(m, options); }
231 static bool has(
const ex &e);
232 static lst
all(
const ex &e);
233 static std::map<std::string, ex>
Table;
237 ex
derivative(
const symbol & s)
const override;
248 const char *
what()
const throw ();
252 vector<std::
string>
split(const
string& s,
char delimiter);
260 template <
typename F>
static void map_inplace(lst &m, F f);
261 template <
typename F>
static lst map(
const lst &m, F f);
262 static ex sum(lst m);
265 template <
typename F>
267 for (
unsigned i = 0; i < m.nops(); i++) {
272 template <
typename F>
275 for (
unsigned i = 0; i < m.nops(); i++) {
284 string now(
bool use_date =
true);
289 return remove(fn.c_str())==0;
293 return (access(fn.c_str(),F_OK)!=-1);
297 return (map.find(key)!=map.end());
302 return (stat(dir.c_str(), &buffer)==0);
318 exvector
GiNaC_Parallel(
int ntotal, std::function<ex(
int)> f,
const string & key =
"");
323 string RunOS(
const string & cmd);
324 void garRead(
const string &garfn, map<string, ex> &resMap);
325 ex
garRead(
const string &garfn,
const char* key);
326 ex
garRead(
const string &garfn);
327 void garWrite(
const string &garfn,
const map<string, ex> &resMap);
328 inline void garWrite(
const map<string, ex> &resMap,
const string &garfn) {
garWrite(garfn,resMap); }
329 void garWrite(
const string &garfn,
const ex & res);
332 ex
str2ex(
const string &expr, symtab stab);
333 ex
str2ex(
const string &expr);
334 lst
str2lst(
const string &expr, symtab stab);
335 lst
str2lst(
const string &expr);
336 matrix
lst2mat(
const lst & ls);
338 void str2file(
const string & ostr,
string filename);
339 void str2file(
char * buff, FILE* f);
340 vector<string>
file2strvec(
string filename,
bool skip_empty=
false);
342 ex
file2ex(
string filename, symtab st);
344 void ex2file(
const ex &,
string filename);
345 void ex2file(
string filename,
const ex &);
346 string ex2str(
const ex &expr);
347 string ex2str(
const exvector &expr);
348 string ex2str(
const exmap &expr);
349 string ex2str(
const exset &expr);
350 inline string in2str(
int i) {
return to_string(i); }
353 lst
vec2lst(
const exvector & ev);
354 exvector
lst2vec(
const lst & alst);
358 lst
xlst(
int bi,
int ei);
375 void let_op_append(ex & ex_in,
int index1,
int index2,
const ex item);
376 void let_op_prepend(ex & ex_in,
int index1,
int index2,
const ex item);
379 void let_op_append(lst & ex_in,
int index1,
int index2,
const ex item);
380 void let_op_prepend(lst & ex_in,
int index1,
int index2,
const ex item);
384 void let_op(ex &ex_in,
int index1,
int index2,
const ex item);
385 void let_op(lst &ex_in,
int index1,
int index2,
const ex item);
386 void let_op(ex &ex_in,
int index1,
int index2,
int index3,
const ex item);
387 void let_op(lst &ex_in,
int index1,
int index2,
int index3,
const ex item);
389 ex
get_op(
const ex ex_in,
int index1,
int index2);
390 ex
get_op(
const lst ex_in,
int index1,
int index2);
391 ex
get_op(
const ex ex_in,
int index1,
int index2,
int index3);
392 ex
get_op(
const lst ex_in,
int index1,
int index2,
int index3);
397 ex
series_ex(ex
const & expr,
const symbol &s,
int sn);
398 ex
series_ex(ex
const & expr,
const ex &s,
int sn);
400 ex
expand_ex(
const ex &expr, std::function<
bool(
const ex &)>);
403 return expand_ex(expr, [](
const ex & e)->
bool{
return true; });
407 return expand_ex(expr, [pats](
const ex & e)->
bool {
408 for(
auto pat : pats) {
if(e.has(pat))
return true; }
414 return expand_ex(expr, [pat](
const ex & e)->
bool {
return e.has(pat); });
417 ex
collect_ex(
const ex &expr, std::function<
bool(
const ex &)>,
int opt=
o_none);
420 return collect_ex(expr, [pats](
const ex & e)->
bool {
421 for(
auto pat : pats) {
if(e.has(pat))
return true; }
427 return collect_ex(expr, [pats](
const ex & e)->
bool {
428 for(
auto pat : pats) {
if(e.has(pat))
return true; }
434 return collect_ex(expr, [pat](
const ex & e)->
bool {
return e.has(pat); }, opt);
437 lst
collect_lst(
const ex &expr, std::function<
bool(
const ex &)>,
int opt=
o_none);
440 return collect_lst(expr, [pats](
const ex & e)->
bool {
441 for(
auto pat : pats) {
if(e.has(pat))
return true; }
447 return collect_lst(expr, [pats](
const ex & e)->
bool {
448 for(
auto pat : pats) {
if(e.has(pat))
return true; }
454 return collect_lst(expr, [pat](
const ex & e)->
bool {
return e.has(pat); }, opt);
457 ex
diff_ex(ex
const expr, ex
const xp,
unsigned nth=1,
bool expand=
false);
480 ex
exnd(
const ex & expr,
int opt = 1);
498 int xSign(ex
const expr);
503 extern ex
w,
w0,
w1,
w2,
w3,
w4,
w5,
w6,
w7,
w8,
w9;
523 DECLARE_FUNCTION_1P(x)
524 DECLARE_FUNCTION_1P(y)
525 DECLARE_FUNCTION_1P(z)
529 class F1_SERIAL {
public:
static unsigned serial; };
530 template<
typename T1>
531 inline GiNaC::function F(
const T1 & p1) {
532 return GiNaC::function(F1_SERIAL::serial, ex(p1));
535 class F2_SERIAL {
public:
static unsigned serial; };
536 template<
typename T1,
typename T2>
537 inline GiNaC::function F(
const T1 & p1,
const T2 & p2) {
538 return GiNaC::function(F2_SERIAL::serial, ex(p1), ex(p2));
541 class WF1_SERIAL {
public:
static unsigned serial; };
542 template<
typename T1>
543 inline GiNaC::function WF(
const T1 & p1) {
544 return GiNaC::function(WF1_SERIAL::serial, ex(p1));
547 class WF2_SERIAL {
public:
static unsigned serial; };
548 template<
typename T1,
typename T2>
549 inline GiNaC::function WF(
const T1 & p1,
const T2 & p2) {
550 return GiNaC::function(WF2_SERIAL::serial, ex(p1), ex(p2));
553 class WF3_SERIAL {
public:
static unsigned serial; };
554 template<
typename T1,
typename T2,
typename T3>
555 inline GiNaC::function WF(
const T1 & p1,
const T2 & p2,
const T3 & p3) {
556 return GiNaC::function(WF3_SERIAL::serial, ex(p1), ex(p2), ex(p3));
559 class WF4_SERIAL {
public:
static unsigned serial; };
560 template<
typename T1,
typename T2,
typename T3,
typename T4>
561 inline GiNaC::function WF(
const T1 & p1,
const T2 & p2,
const T3 & p3,
const T4 & p4) {
562 return GiNaC::function(WF4_SERIAL::serial, ex(p1), ex(p2), ex(p3), ex(p4));
565 class WF5_SERIAL {
public:
static unsigned serial; };
566 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
567 inline GiNaC::function WF(
const T1 & p1,
const T2 & p2,
const T3 & p3,
const T4 & p4,
const T5 & p5) {
568 return GiNaC::function(WF5_SERIAL::serial, ex(p1), ex(p2), ex(p3), ex(p4), ex(p5));
571 class iWF1_SERIAL {
public:
static unsigned serial; };
572 template<
typename T1>
573 inline GiNaC::function iWF(
const T1 & p1) {
574 return GiNaC::function(iWF1_SERIAL::serial, ex(p1));
577 class iWF2_SERIAL {
public:
static unsigned serial; };
578 template<
typename T1,
typename T2>
579 inline GiNaC::function iWF(
const T1 & p1,
const T2 & p2) {
580 return GiNaC::function(iWF2_SERIAL::serial, ex(p1), ex(p2));
583 class iWF3_SERIAL {
public:
static unsigned serial; };
584 template<
typename T1,
typename T2,
typename T3>
585 inline GiNaC::function iWF(
const T1 & p1,
const T2 & p2,
const T3 & p3) {
586 return GiNaC::function(iWF3_SERIAL::serial, ex(p1), ex(p2), ex(p3));
589 class iWF4_SERIAL {
public:
static unsigned serial; };
590 template<
typename T1,
typename T2,
typename T3,
typename T4>
591 inline GiNaC::function iWF(
const T1 & p1,
const T2 & p2,
const T3 & p3,
const T4 & p4) {
592 return GiNaC::function(iWF4_SERIAL::serial, ex(p1), ex(p2), ex(p3), ex(p4));
595 class iWF5_SERIAL {
public:
static unsigned serial; };
596 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
597 inline GiNaC::function iWF(
const T1 & p1,
const T2 & p2,
const T3 & p3,
const T4 & p4,
const T5 & p5) {
598 return GiNaC::function(iWF5_SERIAL::serial, ex(p1), ex(p2), ex(p3), ex(p4), ex(p5));
605 for (
auto & it : GiNaC::function::get_registered_functions()) {
606 if (it.get_name() == name)
throw Error(
"Function named "+name+
" already exists!");
608 unsigned s = GiNaC::function::register_new(function_options(name,1).do_not_evalf_params());
609 return [s](
const ex &p1)->GiNaC::function {
return GiNaC::function(s,p1); };
612 inline std::function<GiNaC::function(
const ex &,
const ex &)>
GiNaC_Function_2(
const string name) {
613 for (
auto & it : GiNaC::function::get_registered_functions()) {
614 if (it.get_name() == name)
throw Error(
"Function named "+name+
" already exists!");
616 unsigned s = GiNaC::function::register_new(function_options(name,2).do_not_evalf_params());
617 return [s](
const ex &p1,
const ex &p2)->GiNaC::function {
return GiNaC::function(s,p1,p2); };
620 inline std::function<GiNaC::function(
const ex &,
const ex &,
const ex &)>
GiNaC_Function_3(
const string name) {
621 for (
auto & it : GiNaC::function::get_registered_functions()) {
622 if (it.get_name() == name)
throw Error(
"Function named "+name+
" already exists!");
624 unsigned s = GiNaC::function::register_new(function_options(name,3).do_not_evalf_params());
625 return [s](
const ex &p1,
const ex &p2,
const ex &p3)->GiNaC::function {
return GiNaC::function(s,p1,p2,p3); };
628 inline std::function<GiNaC::function(
const ex &,
const ex &,
const ex &,
const ex &)>
GiNaC_Function_4(
const string name) {
629 for (
auto & it : GiNaC::function::get_registered_functions()) {
630 if (it.get_name() == name)
throw Error(
"Function named "+name+
" already exists!");
632 unsigned s = GiNaC::function::register_new(function_options(name,4).do_not_evalf_params());
633 return [s](
const ex &p1,
const ex &p2,
const ex &p3,
const ex &p4)->GiNaC::function {
return GiNaC::function(s,p1,p2,p3,p4); };
636 inline std::function<GiNaC::function(
const ex &,
const ex &,
const ex &,
const ex &,
const ex &)>
GiNaC_Function_5(
const string name) {
637 for (
auto & it : GiNaC::function::get_registered_functions()) {
638 if (it.get_name() == name)
throw Error(
"Function named "+name+
" already exists!");
640 unsigned s = GiNaC::function::register_new(function_options(name,5).do_not_evalf_params());
641 return [s](
const ex &p1,
const ex &p2,
const ex &p3,
const ex &p4,
const ex &p5)->GiNaC::function {
return GiNaC::function(s,p1,p2,p3,p4,p5); };
644 inline std::function<GiNaC::function(
const ex &,
const ex &,
const ex &,
const ex &,
const ex &,
const ex &)>
GiNaC_Function_6(
const string name) {
645 for (
auto & it : GiNaC::function::get_registered_functions()) {
646 if (it.get_name() == name)
throw Error(
"Function named "+name+
" already exists!");
648 unsigned s = GiNaC::function::register_new(function_options(name,6).do_not_evalf_params());
649 return [s](
const ex &p1,
const ex &p2,
const ex &p3,
const ex &p4,
const ex &p5,
const ex &p6)->GiNaC::function {
return GiNaC::function(s,p1,p2,p3,p4,p5,p6); };
652 inline std::function<GiNaC::function(
const ex &,
const ex &,
const ex &,
const ex &,
const ex &,
const ex &,
const ex &)>
GiNaC_Function_7(
const string name) {
653 for (
auto & it : GiNaC::function::get_registered_functions()) {
654 if (it.get_name() == name)
throw Error(
"Function named "+name+
" already exists!");
656 unsigned s = GiNaC::function::register_new(function_options(name,7).do_not_evalf_params());
657 return [s](
const ex &p1,
const ex &p2,
const ex &p3,
const ex &p4,
const ex &p5,
const ex &p6,
const ex &p7)->GiNaC::function {
return GiNaC::function(s,p1,p2,p3,p4,p5,p6,p7); };
660 inline std::function<GiNaC::function(
const ex &,
const ex &,
const ex &,
const ex &,
const ex &,
const ex &,
const ex &,
const ex &)>
GiNaC_Function_8(
const string name) {
661 for (
auto & it : GiNaC::function::get_registered_functions()) {
662 if (it.get_name() == name)
throw Error(
"Function named "+name+
" already exists!");
664 unsigned s = GiNaC::function::register_new(function_options(name,8).do_not_evalf_params());
665 return [s](
const ex &p1,
const ex &p2,
const ex &p3,
const ex &p4,
const ex &p5,
const ex &p6,
const ex &p7,
const ex &p8)->GiNaC::function {
return GiNaC::function(s,p1,p2,p3,p4,p5,p6,p7,p8); };
668 inline std::function<GiNaC::function(
const ex &,
const ex &,
const ex &,
const ex &,
const ex &,
const ex &,
const ex &,
const ex &,
const ex &)>
GiNaC_Function_9(
const string name) {
669 for (
auto & it : GiNaC::function::get_registered_functions()) {
670 if (it.get_name() == name)
throw Error(
"Function named "+name+
" already exists!");
672 unsigned s = GiNaC::function::register_new(function_options(name,9).do_not_evalf_params());
673 return [s](
const ex &p1,
const ex &p2,
const ex &p3,
const ex &p4,
const ex &p5,
const ex &p6,
const ex &p7,
const ex &p8,
const ex &p9)->GiNaC::function {
return GiNaC::function(s,p1,p2,p3,p4,p5,p6,p7,p8,p9); };
681 ex operator()(
const ex &e);
683 static ex
subs(
const ex & expr,
const ex & pat, std::function<ex(
const ex &)> f);
685 std::function<ex(
const ex &,
MapFunction &)> Function;
696 ex Read(
const string & instr,
bool s2S=
true);
697 ex ReadFile(
string filename,
bool s2S=
true);
706 return is_a<GiNaC::function>(e) && ex_to<GiNaC::function>(e).get_name()==func_name;
708 inline bool isFunction(
const ex &e,
string func_name,
int nargs) {
709 return is_a<GiNaC::function>(e) && ex_to<GiNaC::function>(e).get_name()==func_name && (e.nops()-nargs)==0;
716 for(const_preorder_iterator i = expr.preorder_begin(); i != expr.preorder_end(); ++i) {
717 if(is_a<GiNaC::function>(*i))
return true;
723 inline void PreTree(
const ex & e, std::function<
void(
const ex &)> f) {
724 for(const_preorder_iterator i = e.preorder_begin(); i != e.preorder_end(); ++i) f(*i);
726 inline void PostTree(
const ex & e, std::function<
void(
const ex &)> f) {
727 for(const_postorder_iterator i = e.postorder_begin(); i != e.postorder_end(); ++i) f(*i);
739 void Combinations(
int n,
int m, std::function<
void(
const int*)> f);
740 void CombinationsR(
int n,
int m, std::function<
void(
const int*)> f);
741 void Permutations(
int n, std::function<
void(
const int*)> f);
742 void Permutations(
int n,
int m, std::function<
void(
const int*)> f);
743 void PermutationsR(
int n,
int m, std::function<
void(
const int*)> f);
745 bool isSorted(
int n,
const ex exs[]);
747 int ACSort(
int n, ex exs[]);
761 bool ex_less(
const ex &
a,
const ex &b);
762 void sort_lst(lst & ilst,
bool less=
true);
763 void sort_lst_by(lst & ilst,
int n,
bool less=
true);
764 void sort_vec(exvector & ivec,
bool less=
true);
765 void sort_vec_by(exvector & ivec,
int n,
bool less=
true);
770 inline void append_to(
const exvector & exv, lst & alst) {
for(
auto item : exv) alst.append(item); }
771 inline void append_to(
const lst & alst, exvector & exv) {
for(
auto item : alst) exv.push_back(item); }
772 inline lst
CoPat(
const ex & e, std::function<
bool(
const ex &)> f) {
776 if(f(item)) vv *= item;
780 }
else if(f(e))
return lst{1,e};
781 else return lst{e,1};
790 static GiNaC::registered_class_info reg_info;
792 static GiNaC::registered_class_info &get_class_info_static();
798 template<
class B,
typename... Args>
friend B &
dynallocate(Args &&... args);
802 void accept(GiNaC::visitor & v)
const override;
803 const GiNaC::registered_class_info &get_class_info()
const override;
804 GiNaC::registered_class_info &get_class_info()
override;
805 const char *class_name()
const override;
807 int compare_same_type(
const GiNaC::basic & other)
const override;
814 size_t nops()
const override;
815 ex op(
size_t i)
const override;
816 ex &
let_op(
size_t i)
override;
817 void print(
const print_dflt &c,
unsigned level = 0)
const;
818 void archive(archive_node & n)
const override;
819 void read_archive(
const archive_node& n)
override;
820 static bool has(
const ex &e);
821 static lst
all(
const ex &e);
833 static _init init_object;
848 string Sentinel =
"---EOF---";
849 void Init(
string fer_path=
"fer64");
851 string Execute(
string);
870 string Sentinel =
"---EOF---";
871 string Prompt =
"***EOF***";
872 void Init(
string form_path=
"form");
873 string Execute(
const string & script,
const string & out_var=
"[o]");
891 GINAC_DECLARE_PRINT_CONTEXT(
MMAFormat, print_dflt)
895 template<
class T>
const MMAFormat & operator << (
const T & v)
const {
899 const MMAFormat & operator << (
const basic & v)
const;
900 const MMAFormat & operator << (
const ex & v)
const;
901 const MMAFormat & operator << (
const lst & v)
const;
902 const MMAFormat & operator<<(std::ostream& (*v)(std::ostream&))
const;
903 const MMAFormat & operator << (
const matrix & v)
const;
904 const MMAFormat & operator << (
const exvector & v)
const;
905 const MMAFormat & operator << (
const exmap & v)
const;
906 const MMAFormat & operator << (
const exset & v)
const;
908 extern MMAFormat
mout;
910 void garWrite(
const exvector &exv,
string garfn);
912 void garRead(exvector &exv,
string garfn);
920 bool has_w(
const ex & e);
921 void subs_w(exmap & repl);
931 string Skip =
"[ID].run";
935 static string Next(
string sip,
string sport);
940 void ReShare(
const ex & e1,
const ex & e2);
941 void ReShare(
const ex & e1,
const ex & e2,
const ex & e3);
942 void ReShare(
const exvector & ev);
943 void ReShare(
const exvector & ev1,
const exvector & ev2);
948 numeric
mulInv(numeric
a, numeric b);
951 ex
Thiele(
const exvector & keys,
const exvector & values,
const ex &
d);
952 ex
Newton(
const exvector & keys,
const exvector & values,
const ex &
d,
const ex factor=1);
960 matrix
fermat_mul(
const matrix & m1,
const matrix & m2);
961 matrix
fermat_pow(
const matrix & mat_in,
int n);
963 void fermat_mat(
const matrix & mat_in,
const string & name);
967 void arg2map(
int argc,
char** argv,
const char *optstring, std::map<char,std::string> & kv);
971 std::string
get_env(
const std::string & name);
974 ex
chop(
const ex & e,
const ex & err);
978typedef void (*
RUN)(std::string dir_id);
void(* RUN)(std::string dir_id)
class used to wrap error message
const char * what() const
interface to communicate with Fermat program
class to wrap map_function of GiNaC
class to parse for string or file, helpful with Symbol class
virtual void visit(const Symbol &)=0
class extended to GiNaC symbol class, represent a positive symbol
static lst all(const ex &e)
ex series(const relational &s, int order, unsigned options=0) const override
void archive(archive_node &n) const override
Symbol archive.
ex imag_part() const override
Symbol * duplicate() const override
bool is_equal_same_type(const basic &other) const override
ex conjugate() const override
static ex set_all(const ex &expr)
const char * class_name() const override
static bool has(const ex &e)
ex subs(const exmap &m, unsigned options=0) const override
void read_archive(const archive_node &n) override
Symbol read_archive.
static GiNaC::registered_class_info & get_class_info_static()
ex derivative(const symbol &s) const override
unsigned calchash() const override
ex evalf() const override
void set(const ex &v) const
static std::map< std::string, ex > Table
friend B & dynallocate(Args &&... args)
unsigned get_domain() const override
void accept(GiNaC::visitor &v) const override
ex real_part() const override
int compare_same_type(const GiNaC::basic &other) const override
const GiNaC::registered_class_info & get_class_info() const override
virtual void visit(const XIntegral &)=0
XIntegral Class, preface to SecDec.
static lst all(const ex &e)
static bool has(const ex &e)
friend B & dynallocate(Args &&... args)
virtual void visit(const iSymbol &)=0
class extended to GiNaC symbol class, pure imaginary symbol
bool is_equal_same_type(const basic &other) const override
ex evalf() const override
static std::map< std::string, ex > Table
unsigned get_domain() const override
void archive(archive_node &n) const override
Symbol archive.
ex subs(const exmap &m, unsigned options=0) const override
iSymbol * duplicate() const override
ex real_part() const override
ex derivative(const symbol &s) const override
static GiNaC::registered_class_info & get_class_info_static()
ex conjugate() const override
static lst all(const ex &e)
const char * class_name() const override
ex series(const relational &s, int order, unsigned options=0) const override
void accept(GiNaC::visitor &v) const override
ex imag_part() const override
const GiNaC::registered_class_info & get_class_info() const override
int compare_same_type(const GiNaC::basic &other) const override
static bool has(const ex &e)
friend B & dynallocate(Args &&... args)
void read_archive(const archive_node &n) override
Symbol read_archive.
unsigned calchash() const override
static lst map(const lst &m, F f)
static void map_inplace(lst &m, F f)
ex expand_ex(ex const &expr_in, std::function< bool(const ex &)> has_func)
the expand like Mathematica
const char * Color_HighLight
ex exfactor(const ex &expr_in, int opt)
factorize a expression
ex collect_factors(const ex &expr)
a wrapper for collect_common_factors, catch errors
matrix fermat_Redrowech_Sparse(const matrix &mat)
void append_to(const exvector &exv, lst &alst)
bool ex_less(const ex &a, const ex &b)
void PostTree(const ex &e, std::function< void(const ex &)> f)
void arg2map(int argc, char **argv, const char *optstring, std::map< char, std::string > &kv)
__float128 ex2q(ex num)
ex of numeric to __float128
ex EvalF(ex expr)
the nuerical evaluation, Digits=100 will be used
lst str2lst(const string &expr, symtab stab)
convert string to the lst, using Parser internally
matrix fermat_mul(const matrix &m1, const matrix &m2)
ex exnd(const ex &expr, int opt)
num_den a expression
ex form_factor(const ex &expr, bool nd=true)
bool has_function(const ex &expr)
lst gather_symbols(const ex &e)
get all symbols from input expression
lst CoPat(const ex &e, std::function< bool(const ex &)> f)
void let_op_prepend(ex &ex_in, const ex item)
preppend item into expression
std::function< GiNaC::function(const ex &, const ex &, const ex &, const ex &)> GiNaC_Function_4(const string name)
std::function< GiNaC::function(const ex &, const ex &, const ex &)> GiNaC_Function_3(const string name)
bool match_any(ex expr, lst ps)
lst xlst(int bi, int ei)
return a lst: x(bi), x(bi+1), ..., x(ei)
int GiNaC_Parallel_Process
void let_op(ex &ex_in, int index1, int index2, const ex item)
update index1-th.index2-th of expression with item
std::function< GiNaC::function(const ex &)> GiNaC_Function_1(const string name)
std::initializer_list< ex > init_list
bool string_contain(const string &fstr, const string &mstr)
ex q2ex(__float128 num)
__float128 to ex
bool xPositive(ex const expr)
check the expr is xPositive, i.e., each x-monomial item is postive
void Combinations(int n, int m, std::function< void(const int *)> f)
void PreTree(const ex &e, std::function< void(const ex &)> f)
void ex2file(const ex &expr, string filename)
export expression file
ex normal_fermat(const ex &expr, bool dfactor)
return the normalizatied expression, using fermat_numer_denom
ex NN(ex expr, int digits)
the nuerical evaluation
map< string, bool > GiNaC_Parallel_RM
bool isSorted(const lst &exs)
bool is_equal_any(ex expr, lst ps)
std::function< GiNaC::function(const ex &, const ex &, const ex &, const ex &, const ex &, const ex &, const ex &, const ex &, const ex &)> GiNaC_Function_9(const string name)
ex factor_flint(const ex &e, bool nd=true)
map< ex, long long, ex_is_less > fermat_weight
bool has_all(ex expr, lst ps)
numeric RationalReconstruct(numeric a, numeric p)
ex Thiele(const exvector &keys, const exvector &values, const ex &d)
ex collect_ex(ex const &expr_in, std::function< bool(const ex &)> has_func, int opt)
the collect function like Mathematica
void garRead(const string &garfn, map< string, ex > &resMap)
garRead from file, and output in a map
map< string, int > GiNaC_Parallel_NB
std::function< GiNaC::function(const ex &, const ex &, const ex &, const ex &, const ex &, const ex &, const ex &, const ex &)> GiNaC_Function_8(const string name)
void ReShare(const ex &e)
bool file_exists(string fn)
ex factor_form(const ex &expr, bool nd)
factorize a expression using FORM
ex series_ex(ex const &expr_in, ex const &s0, int sn0)
the series like Mathematica, include s^n
bool string_start_with(const string &fstr, const string &sstr)
ex str2ex(const string &expr, symtab stab)
convert string to ex expression, using Parser internally
numeric ChineseRemainder(std::vector< numeric > a, std::vector< numeric > n)
bool key_exists(const exmap &map, const ex &key)
ex form_eval(const ex &expr)
void fermat_mat(const matrix &mat_in, const string &name)
string now(bool use_date)
date/time string
ex numer_denom_fermat(const ex &expr, bool dfactor=false)
return the numerator and denominator after normalization
bool has_any(ex expr, lst ps)
string RunOS(const string &cmd)
run symtem command and return the output as string
lst add2lst(const ex &expr)
convert add to lst
ex fermat_normal(const ex &expr, bool dfactor=false)
int CpuCores()
return the cpu cores using OpenMP
map< string, int > GiNaC_Parallel_NP
bool isFunction(const ex &e, string func_name)
map< string, int > GiNaC_Parallel_Verb
void CombinationsR(int n, int m, std::function< void(const int *)> f)
map< string, bool > GiNaC_Parallel_ReWR
exvector lst2vec(const lst &alst)
convert lst to exvector
ex get_op(const ex ex_in, int index1, int index2)
return index1-th.index2-th of expression
bool match_all(ex expr, lst ps)
vector< string > file2strvec(string filename, bool skip_empty)
read file content to string vector
matrix fermat_Redrowech(const matrix &mat)
ex file2ex(string filename)
read file content to ex
ex exnormal(const ex &expr, int opt)
normalize a expression
const int o_normal_fermat
std::function< GiNaC::function(const ex &, const ex &)> GiNaC_Function_2(const string name)
ex nextprime(const ex &n)
void Permutations(int n, std::function< void(const int *)> f)
ex normal_flint(const ex &expr, int opt=o_flint)
void sort_lst_by(lst &ilst, int n, bool less=true)
sort the list in less order, or the reverse
ex fermat_eval(const ex &expr)
return the numerator and denominator after normalization
ex fermat_Det(const matrix &mat)
lst mul2lst(const ex &expr)
convert mul to lst
matrix fermat_inv(const matrix &mat)
std::function< GiNaC::function(const ex &, const ex &, const ex &, const ex &, const ex &, const ex &)> GiNaC_Function_6(const string name)
std::function< GiNaC::function(const ex &, const ex &, const ex &, const ex &, const ex &, const ex &, const ex &)> GiNaC_Function_7(const string name)
string file2str(string filename)
read file content to string
std::function< GiNaC::function(const ex &, const ex &, const ex &, const ex &, const ex &)> GiNaC_Function_5(const string name)
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}, ... }
void sort_vec(exvector &ivec, bool less=true)
sort the list in less order, or the reverse
ex diff_ex(ex const expr, ex const xp, unsigned nth, bool expand)
the differential like Mathematica
void sort_lst(lst &ilst, bool less=true)
sort the list in less order, or the reverse
ex Rationalize(const ex &e, int dn)
bool file_remove(string fn)
void string_replace_all(string &str, const string &from, const string &to)
void garWrite(const string &garfn, const map< string, ex > &resMap)
garWrite to write the string-key map to the archive
void let_op_append(ex &ex_in, const ex item)
append item into expression
lst vec2lst(const exvector &ev)
convert exvector to lst
string ex2str(const ex &expr)
convert ex to output string, the defalut printer format will be used
void let_op_remove_first(ex &ex_in)
remove first from expression
matrix lst2mat(const lst &ls)
convert 2Dim lst to matrix
bool dir_exists(string dir)
long long node_number(const ex &expr, int level=0)
void str2file(const string &ostr, string filename)
export string to a file
bool string_end_with(const string &fstr, const string &estr)
void set_precision(long prec, bool push)
void sort_vec_by(exvector &ivec, int n, bool less=true)
sort the list in less order, or the reverse
ex add_collect_normal(const exvector &exv, ex const &pats, int opt)
ex fermat_Det_Sparse(const matrix &mat)
ex chop(const ex &expr, const ex &err)
map< string, string > GiNaC_Parallel_PRE
std::vector< std::string > split(const std::string &s, char delimiter)
split the string into serveral part, separated by the delimiter
int xSign(ex const expr)
the always sign for expr
exvector GiNaC_Parallel(int ntotal, std::function< ex(int)> f, const string &key)
GiNaC Parallel Evaluation using fork.
void let_op_remove_last(ex &ex_in)
remove last from expression
bool has_symbol(const ex &e)
void PermutationsR(int n, int m, std::function< void(const int *)> f)
string get_env(const string &name)
void string_trim(string &str)
ex numer_fermat(const ex &expr)
ex fermat_numer_denom(const ex &expr, bool dfactor=false)
numeric mulInv(numeric a, numeric b)
matrix fermat_pow(const matrix &mat_in, int n)
int ex2int(ex num)
ex to integer
ex subs(const ex &e, init_list sl)
ex Newton(const exvector &keys, const exvector &values, const ex &d, const ex factor=1)