8 #include <ginac/ginac.h>
9 #include <ginac/parser.h>
21 #define DEFAULT_CTOR(classname) \
22 classname::classname() { setflag(status_flags::evaluated | status_flags::expanded); }
24 #define IMPLEMENT_HAS(classname) \
25 bool 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) \
31 lst 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"
116 static GiNaC::registered_class_info reg_info;
118 static GiNaC::registered_class_info &get_class_info_static();
124 template<
class B,
typename... Args>
friend B &
dynallocate(Args &&... args);
127 Symbol * duplicate()
const override;
128 void accept(GiNaC::visitor & v)
const override;
129 const GiNaC::registered_class_info &get_class_info()
const override;
130 GiNaC::registered_class_info &get_class_info()
override;
131 const char *class_name()
const override;
133 int compare_same_type(
const GiNaC::basic & other)
const override;
137 explicit Symbol(
const string &s);
138 void archive(archive_node & n)
const override;
139 void read_archive(
const archive_node& n)
override;
142 ex eval()
const override;
143 ex evalf()
const override;
144 ex series(
const relational & s,
int order,
unsigned options = 0)
const override;
145 ex
subs(
const exmap & m,
unsigned options = 0)
const override {
return subs_one_level(m, options); }
151 ex conjugate()
const override;
152 ex real_part()
const override;
153 ex imag_part()
const override;
154 void set_name(
string n);
156 unsigned get_domain()
const override {
return domain::positive; }
158 static bool has(
const ex &e);
159 static lst
all(
const ex &e);
160 static std::map<std::string, ex>
Table;
162 void set(
const ex & v)
const;
168 static void set(
const Symbol & s,
const ex & v);
169 static void set(
const string & str,
const ex & v);
170 static void unset(
const Symbol &s);
171 static void unset(
const string &str);
172 static void unset_all();
173 static ex set_all(
const ex & expr);
175 unsigned calchash()
const override;
176 ex derivative(
const symbol & s)
const override;
177 bool is_equal_same_type(
const basic & other)
const override;
186 static GiNaC::registered_class_info reg_info;
188 static GiNaC::registered_class_info &get_class_info_static();
194 template<
class B,
typename... Args>
friend B &
dynallocate(Args &&... args);
197 iSymbol * duplicate()
const override;
198 void accept(GiNaC::visitor & v)
const override;
199 const GiNaC::registered_class_info &get_class_info()
const override;
200 GiNaC::registered_class_info &get_class_info()
override;
201 const char *class_name()
const override;
203 int compare_same_type(
const GiNaC::basic & other)
const override;
208 void archive(archive_node & n)
const override;
209 void read_archive(
const archive_node& n)
override;
211 unsigned get_domain()
const override {
return domain::complex; }
214 ex eval()
const override;
215 ex evalf()
const override;
216 ex series(
const relational & s,
int order,
unsigned options = 0)
const override;
217 ex
subs(
const exmap & m,
unsigned options = 0)
const override {
return subs_one_level(m, options); }
223 ex conjugate()
const override;
224 ex real_part()
const override;
225 ex imag_part()
const override;
226 void set_name(
string n);
228 static bool has(
const ex &e);
229 static lst
all(
const ex &e);
230 static std::map<std::string, ex>
Table;
233 unsigned calchash()
const override;
234 ex derivative(
const symbol & s)
const override;
235 bool is_equal_same_type(
const basic & other)
const override;
245 const char * what()
const throw ();
249 vector<std::
string>
split(const
string& s,
char delimiter);
257 template <
typename F>
static void map_inplace(lst &m, F f);
258 template <
typename F>
static lst map(
const lst &m, F f);
259 static ex sum(lst m);
262 template <
typename F>
264 for (
unsigned i = 0; i < m.nops(); i++) {
265 m.let_op(i) = f(m.op(i));
269 template <
typename F>
272 for (
unsigned i = 0; i < m.nops(); i++) {
273 r.let_op(i) = f(m.op(i));
281 string now(
bool use_date =
true);
286 return remove(fn.c_str())==0;
290 return (access(fn.c_str(),F_OK)!=-1);
294 return (map.find(key)!=map.end());
299 return (stat(dir.c_str(), &buffer)==0);
314 exvector
GiNaC_Parallel(
int ntotal, std::function<ex(
int)> f,
const string & key =
"");
319 string RunOS(
const string & cmd);
320 void garRead(
const string &garfn, map<string, ex> &resMap);
321 ex
garRead(
const string &garfn,
const char* key);
322 ex
garRead(
const string &garfn);
323 void garWrite(
const string &garfn,
const map<string, ex> &resMap);
324 inline void garWrite(
const map<string, ex> &resMap,
const string &garfn) {
garWrite(garfn,resMap); }
325 void garWrite(
const string &garfn,
const ex & res);
328 ex
str2ex(
const string &expr, symtab stab);
329 ex
str2ex(
const string &expr);
330 lst
str2lst(
const string &expr, symtab stab);
331 lst
str2lst(
const string &expr);
332 matrix
lst2mat(
const lst & ls);
334 void str2file(
const string & ostr,
string filename);
335 void str2file(
char * buff, FILE* f);
336 vector<string>
file2strvec(
string filename,
bool skip_empty=
false);
338 ex
file2ex(
string filename, symtab st);
340 void ex2file(
const ex &,
string filename);
341 void ex2file(
string filename,
const ex &);
342 string ex2str(
const ex &expr);
343 string ex2str(
const exvector &expr);
344 string ex2str(
const exmap &expr);
345 string ex2str(
const exset &expr);
346 inline string in2str(
int i) {
return to_string(i); }
349 lst
vec2lst(
const exvector & ev);
350 exvector
lst2vec(
const lst & alst);
354 lst
xlst(
int bi,
int ei);
371 void let_op_append(ex & ex_in,
int index1,
int index2,
const ex item);
372 void let_op_prepend(ex & ex_in,
int index1,
int index2,
const ex item);
375 void let_op_append(lst & ex_in,
int index1,
int index2,
const ex item);
376 void let_op_prepend(lst & ex_in,
int index1,
int index2,
const ex item);
380 void let_op(ex &ex_in,
int index1,
int index2,
const ex item);
381 void let_op(lst &ex_in,
int index1,
int index2,
const ex item);
382 void let_op(ex &ex_in,
int index1,
int index2,
int index3,
const ex item);
383 void let_op(lst &ex_in,
int index1,
int index2,
int index3,
const ex item);
385 ex
get_op(
const ex ex_in,
int index1,
int index2);
386 ex
get_op(
const lst ex_in,
int index1,
int index2);
387 ex
get_op(
const ex ex_in,
int index1,
int index2,
int index3);
388 ex
get_op(
const lst ex_in,
int index1,
int index2,
int index3);
393 ex
series_ex(ex
const & expr,
const symbol &s,
int sn);
394 ex
series_ex(ex
const & expr,
const ex &s,
int sn);
396 ex
expand_ex(
const ex &expr, std::function<
bool(
const ex &)>);
399 return expand_ex(expr, [](
const ex & e)->
bool{
return true; });
403 return expand_ex(expr, [pats](
const ex & e)->
bool {
404 for(
auto pat : pats) {
if(e.has(pat))
return true; }
410 return expand_ex(expr, [pat](
const ex & e)->
bool {
return e.has(pat); });
413 ex
collect_ex(
const ex &expr, std::function<
bool(
const ex &)>,
int opt=
o_none);
416 return collect_ex(expr, [pats](
const ex & e)->
bool {
417 for(
auto pat : pats) {
if(e.has(pat))
return true; }
423 return collect_ex(expr, [pats](
const ex & e)->
bool {
424 for(
auto pat : pats) {
if(e.has(pat))
return true; }
430 return collect_ex(expr, [pat](
const ex & e)->
bool {
return e.has(pat); }, opt);
433 lst
collect_lst(
const ex &expr, std::function<
bool(
const ex &)>,
int opt=
o_none);
436 return collect_lst(expr, [pats](
const ex & e)->
bool {
437 for(
auto pat : pats) {
if(e.has(pat))
return true; }
443 return collect_lst(expr, [pats](
const ex & e)->
bool {
444 for(
auto pat : pats) {
if(e.has(pat))
return true; }
450 return collect_lst(expr, [pat](
const ex & e)->
bool {
return e.has(pat); }, opt);
453 ex
diff_ex(ex
const expr, ex
const xp,
unsigned nth=1,
bool expand=
false);
476 ex
exnd(
const ex & expr,
int opt = 1);
494 int xSign(ex
const expr);
499 extern ex
w,
w0,
w1,
w2,
w3,
w4,
w5,
w6,
w7,
w8,
w9;
519 DECLARE_FUNCTION_1P(x)
520 DECLARE_FUNCTION_1P(y)
521 DECLARE_FUNCTION_1P(z)
525 class F1_SERIAL {
public:
static unsigned serial; };
526 template<
typename T1>
527 inline GiNaC::function F(
const T1 & p1) {
528 return GiNaC::function(F1_SERIAL::serial, ex(p1));
531 class F2_SERIAL {
public:
static unsigned serial; };
532 template<
typename T1,
typename T2>
533 inline GiNaC::function F(
const T1 & p1,
const T2 & p2) {
534 return GiNaC::function(F2_SERIAL::serial, ex(p1), ex(p2));
537 class WF1_SERIAL {
public:
static unsigned serial; };
538 template<
typename T1>
539 inline GiNaC::function WF(
const T1 & p1) {
540 return GiNaC::function(WF1_SERIAL::serial, ex(p1));
543 class WF2_SERIAL {
public:
static unsigned serial; };
544 template<
typename T1,
typename T2>
545 inline GiNaC::function WF(
const T1 & p1,
const T2 & p2) {
546 return GiNaC::function(WF2_SERIAL::serial, ex(p1), ex(p2));
549 class WF3_SERIAL {
public:
static unsigned serial; };
550 template<
typename T1,
typename T2,
typename T3>
551 inline GiNaC::function WF(
const T1 & p1,
const T2 & p2,
const T3 & p3) {
552 return GiNaC::function(WF3_SERIAL::serial, ex(p1), ex(p2), ex(p3));
555 class WF4_SERIAL {
public:
static unsigned serial; };
556 template<
typename T1,
typename T2,
typename T3,
typename T4>
557 inline GiNaC::function WF(
const T1 & p1,
const T2 & p2,
const T3 & p3,
const T4 & p4) {
558 return GiNaC::function(WF4_SERIAL::serial, ex(p1), ex(p2), ex(p3), ex(p4));
561 class WF5_SERIAL {
public:
static unsigned serial; };
562 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
563 inline GiNaC::function WF(
const T1 & p1,
const T2 & p2,
const T3 & p3,
const T4 & p4,
const T5 & p5) {
564 return GiNaC::function(WF5_SERIAL::serial, ex(p1), ex(p2), ex(p3), ex(p4), ex(p5));
567 class iWF1_SERIAL {
public:
static unsigned serial; };
568 template<
typename T1>
569 inline GiNaC::function iWF(
const T1 & p1) {
570 return GiNaC::function(iWF1_SERIAL::serial, ex(p1));
573 class iWF2_SERIAL {
public:
static unsigned serial; };
574 template<
typename T1,
typename T2>
575 inline GiNaC::function iWF(
const T1 & p1,
const T2 & p2) {
576 return GiNaC::function(iWF2_SERIAL::serial, ex(p1), ex(p2));
579 class iWF3_SERIAL {
public:
static unsigned serial; };
580 template<
typename T1,
typename T2,
typename T3>
581 inline GiNaC::function iWF(
const T1 & p1,
const T2 & p2,
const T3 & p3) {
582 return GiNaC::function(iWF3_SERIAL::serial, ex(p1), ex(p2), ex(p3));
585 class iWF4_SERIAL {
public:
static unsigned serial; };
586 template<
typename T1,
typename T2,
typename T3,
typename T4>
587 inline GiNaC::function iWF(
const T1 & p1,
const T2 & p2,
const T3 & p3,
const T4 & p4) {
588 return GiNaC::function(iWF4_SERIAL::serial, ex(p1), ex(p2), ex(p3), ex(p4));
591 class iWF5_SERIAL {
public:
static unsigned serial; };
592 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
593 inline GiNaC::function iWF(
const T1 & p1,
const T2 & p2,
const T3 & p3,
const T4 & p4,
const T5 & p5) {
594 return GiNaC::function(iWF5_SERIAL::serial, ex(p1), ex(p2), ex(p3), ex(p4), ex(p5));
601 for (
auto & it : GiNaC::function::get_registered_functions()) {
602 if (it.get_name() == name)
throw Error(
"Function named "+name+
" already exists!");
604 unsigned s = GiNaC::function::register_new(function_options(name,1).
do_not_evalf_params());
605 return [s](
const ex &p1)->GiNaC::function {
return GiNaC::function(s,p1); };
607 inline std::function<GiNaC::function(
const ex &,
const ex &)>
GiNaC_Function_2(
const string name) {
608 for (
auto & it : GiNaC::function::get_registered_functions()) {
609 if (it.get_name() == name)
throw Error(
"Function named "+name+
" already exists!");
611 unsigned s = GiNaC::function::register_new(function_options(name,2).
do_not_evalf_params());
612 return [s](
const ex &p1,
const ex &p2)->GiNaC::function {
return GiNaC::function(s,p1,p2); };
614 inline std::function<GiNaC::function(
const ex &,
const ex &,
const ex &)>
GiNaC_Function_3(
const string name) {
615 for (
auto & it : GiNaC::function::get_registered_functions()) {
616 if (it.get_name() == name)
throw Error(
"Function named "+name+
" already exists!");
618 unsigned s = GiNaC::function::register_new(function_options(name,3).
do_not_evalf_params());
619 return [s](
const ex &p1,
const ex &p2,
const ex &p3)->GiNaC::function {
return GiNaC::function(s,p1,p2,p3); };
621 inline std::function<GiNaC::function(
const ex &,
const ex &,
const ex &,
const ex &)>
GiNaC_Function_4(
const string name) {
622 for (
auto & it : GiNaC::function::get_registered_functions()) {
623 if (it.get_name() == name)
throw Error(
"Function named "+name+
" already exists!");
625 unsigned s = GiNaC::function::register_new(function_options(name,4).
do_not_evalf_params());
626 return [s](
const ex &p1,
const ex &p2,
const ex &p3,
const ex &p4)->GiNaC::function {
return GiNaC::function(s,p1,p2,p4); };
634 ex operator()(
const ex &e);
636 static ex
subs(
const ex & expr,
const ex & pat, std::function<ex(
const ex &)> f);
638 std::function<ex(
const ex &,
MapFunction &)> Function;
649 ex Read(
const string & instr,
bool s2S=
true);
650 ex ReadFile(
string filename,
bool s2S=
true);
659 return is_a<GiNaC::function>(e) && ex_to<GiNaC::function>(e).get_name()==func_name;
661 inline bool isFunction(
const ex &e,
string func_name,
int nargs) {
662 return is_a<GiNaC::function>(e) && ex_to<GiNaC::function>(e).get_name()==func_name && (e.nops()-nargs)==0;
669 for(const_preorder_iterator i = expr.preorder_begin(); i != expr.preorder_end(); ++i) {
670 if(is_a<GiNaC::function>(*i))
return true;
676 inline void PreTree(
const ex & e, std::function<
void(
const ex &)> f) {
677 for(const_preorder_iterator i = e.preorder_begin(); i != e.preorder_end(); ++i) f(*i);
679 inline void PostTree(
const ex & e, std::function<
void(
const ex &)> f) {
680 for(const_postorder_iterator i = e.postorder_begin(); i != e.postorder_end(); ++i) f(*i);
692 void Combinations(
int n,
int m, std::function<
void(
const int*)> f);
693 void CombinationsR(
int n,
int m, std::function<
void(
const int*)> f);
694 void Permutations(
int n, std::function<
void(
const int*)> f);
695 void Permutations(
int n,
int m, std::function<
void(
const int*)> f);
696 void PermutationsR(
int n,
int m, std::function<
void(
const int*)> f);
698 bool isSorted(
int n,
const ex exs[]);
700 int ACSort(
int n, ex exs[]);
714 bool ex_less(
const ex &
a,
const ex &b);
715 void sort_lst(lst & ilst,
bool less=
true);
716 void sort_lst_by(lst & ilst,
int n,
bool less=
true);
717 void sort_vec(exvector & ivec,
bool less=
true);
718 void sort_vec_by(exvector & ivec,
int n,
bool less=
true);
723 inline void append_to(
const exvector & exv, lst & alst) {
for(
auto item : exv) alst.append(item); }
724 inline void append_to(
const lst & alst, exvector & exv) {
for(
auto item : alst) exv.push_back(item); }
725 inline lst
CoPat(
const ex & e, std::function<
bool(
const ex &)> f) {
729 if(f(item)) vv *= item;
733 }
else if(f(e))
return lst{1,e};
734 else return lst{e,1};
743 static GiNaC::registered_class_info reg_info;
745 static GiNaC::registered_class_info &get_class_info_static();
751 template<
class B,
typename... Args>
friend B &
dynallocate(Args &&... args);
755 void accept(GiNaC::visitor & v)
const override;
756 const GiNaC::registered_class_info &get_class_info()
const override;
757 GiNaC::registered_class_info &get_class_info()
override;
758 const char *class_name()
const override;
760 int compare_same_type(
const GiNaC::basic & other)
const override;
767 size_t nops()
const override;
768 ex op(
size_t i)
const override;
769 ex &
let_op(
size_t i)
override;
770 void print(
const print_dflt &c,
unsigned level = 0)
const;
771 void archive(archive_node & n)
const override;
772 void read_archive(
const archive_node& n)
override;
773 static bool has(
const ex &e);
774 static lst
all(
const ex &e);
786 static _init init_object;
801 string Sentinel =
"---EOF---";
802 void Init(
string fer_path=
"fer64");
804 string Execute(
string);
823 string Sentinel =
"---EOF---";
824 string Prompt =
"***EOF***";
825 void Init(
string form_path=
"form");
826 string Execute(
const string & script,
const string & out_var=
"[o]");
844 GINAC_DECLARE_PRINT_CONTEXT(
MMAFormat, print_dflt)
848 template<
class T>
const MMAFormat & operator << (
const T & v)
const {
852 const MMAFormat & operator << (
const basic & v)
const;
853 const MMAFormat & operator << (
const ex & v)
const;
854 const MMAFormat & operator << (
const lst & v)
const;
855 const MMAFormat & operator<<(std::ostream& (*v)(std::ostream&))
const;
856 const MMAFormat & operator << (
const matrix & v)
const;
857 const MMAFormat & operator << (
const exvector & v)
const;
858 const MMAFormat & operator << (
const exmap & v)
const;
859 const MMAFormat & operator << (
const exset & v)
const;
861 extern MMAFormat
mout;
863 void garWrite(
const exvector &exv,
string garfn);
865 void garRead(exvector &exv,
string garfn);
873 bool has_w(
const ex & e);
874 void subs_w(exmap & repl);
884 string Skip =
"[ID].run";
888 static string Next(
string sip,
string sport);
893 void ReShare(
const ex & e1,
const ex & e2);
894 void ReShare(
const ex & e1,
const ex & e2,
const ex & e3);
895 void ReShare(
const exvector & ev);
896 void ReShare(
const exvector & ev1,
const exvector & ev2);
901 numeric
mulInv(numeric
a, numeric b);
904 ex
Thiele(
const exvector & keys,
const exvector & values,
const ex &
d);
905 ex
Newton(
const exvector & keys,
const exvector & values,
const ex &
d,
const ex factor=1);
913 matrix
fermat_mul(
const matrix & m1,
const matrix & m2);
914 matrix
fermat_pow(
const matrix & mat_in,
int n);
916 void fermat_mat(
const matrix & mat_in,
const string & name);
920 void arg2map(
int argc,
char** argv,
const char *optstring, std::map<char,std::string> & kv);
923 typedef void (*
RUN)(std::string dir_id);
void(* RUN)(std::string dir_id)
class used to wrap error message
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)
static bool has(const ex &e)
ex subs(const exmap &m, unsigned options=0) const override
friend B & dynallocate(Args &&... args)
static std::map< std::string, ex > Table
unsigned get_domain() const override
virtual void visit(const XIntegral &)=0
XIntegral Class, preface to SecDec.
static lst all(const ex &e)
friend B & dynallocate(Args &&... args)
static bool has(const ex &e)
virtual void visit(const iSymbol &)=0
class extended to GiNaC symbol class, pure imaginary symbol
static std::map< std::string, ex > Table
unsigned get_domain() const override
ex subs(const exmap &m, unsigned options=0) const override
friend B & dynallocate(Args &&... args)
static lst all(const ex &e)
static bool has(const ex &e)
static lst map(const lst &m, F f)
static void map_inplace(lst &m, F f)
do_not_evalf_params().expl_derivative_func(zd1D).derivative_func(zp1D)) REGISTER_FUNCTION(FTX
ex expand_ex(ex const &expr_in, std::function< bool(const ex &)> has_func)
the expand like Mathematica
const char * Color_HighLight
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
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::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)
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
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)
std::function< GiNaC::function(const ex &, const ex &)> GiNaC_Function_2(const string 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
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)
string file2str(string filename)
read file content to string
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
ex exfactor(const ex &expr, int opt)
factorize a 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)
std::function< GiNaC::function(const ex &)> GiNaC_Function_1(const string name)
map< string, string > GiNaC_Parallel_PRE
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
std::vector< std::string > split(const std::string &s, char delimiter)
split the string into serveral part, separated by the delimiter
bool has_symbol(const ex &e)
void PermutationsR(int n, int m, std::function< void(const int *)> f)
void string_trim(string &str)
ex numer_fermat(const ex &expr)
std::function< GiNaC::function(const ex &, const ex &, const ex &, const ex &)> GiNaC_Function_4(const string name)
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)
std::function< GiNaC::function(const ex &, const ex &, const ex &)> GiNaC_Function_3(const string name)
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)