HepLib
Namespaces | Typedefs | Functions | Variables
BASIC.cpp File Reference

Basic Functions, extend GiNaC, etc. More...

#include "BASIC.h"
#include "cln/cln.h"
#include <quadmath.h>
Include dependency graph for BASIC.cpp:

Go to the source code of this file.

Namespaces

 HepLib
 HepLib namespace.
 

Typedefs

typedef vector< pair< ex, ex > > HepLib::epvec_t
 
typedef pair< ex, epvec_t > HepLib::co_epvec_t
 

Functions

unsigned golden_ratio_hash (uintptr_t n)
 
exvector HepLib::GiNaC_Parallel (int ntotal, std::function< ex(int)> f, const string &key)
 GiNaC Parallel Evaluation using fork. More...
 
std::vector< std::string > HepLib::split (const std::string &s, char delimiter)
 split the string into serveral part, separated by the delimiter More...
 
string HepLib::now (bool use_date)
 date/time string More...
 
lst HepLib::gather_symbols (const ex &e)
 get all symbols from input expression More...
 
lst HepLib::gather_symbols (const exvector &ve)
 get all symbols from input expression More...
 
string HepLib::RunOS (const string &cmd)
 run symtem command and return the output as string More...
 
void HepLib::garRead (const string &garfn, map< string, ex > &resMap)
 garRead from file, and output in a map More...
 
ex HepLib::garRead (const string &garfn, const char *key)
 garRead from file, only the element w.r.t. key More...
 
ex HepLib::garRead (const string &garfn)
 garRead from file, only the element w.r.t. key "res", note inner check will be performed More...
 
void HepLib::garWrite (const string &garfn, const map< string, ex > &resMap)
 garWrite to write the string-key map to the archive More...
 
void HepLib::garWrite (const string &garfn, const ex &res)
 garWrite to write the expression to the archive, with key: "res", including a check key will be written More...
 
ex HepLib::str2ex (const string &expr, symtab stab)
 convert string to ex expression, using Parser internally More...
 
ex HepLib::str2ex (const string &expr)
 convert string to ex expression, using Parser internally More...
 
lst HepLib::str2lst (const string &expr, symtab stab)
 convert string to the lst, using Parser internally More...
 
lst HepLib::str2lst (const string &expr)
 convert string to the lst, using Parser internally More...
 
string HepLib::ex2str (const ex &expr)
 convert ex to output string, the defalut printer format will be used More...
 
string HepLib::ex2str (const exvector &expr)
 convert exvec to output string, the defalut printer format will be used More...
 
matrix HepLib::lst2mat (const lst &ls)
 convert 2Dim lst to matrix More...
 
string HepLib::ex2str (const exmap &expr)
 convert exmap to output string, the defalut printer format will be used More...
 
string HepLib::ex2str (const exset &expr)
 convert exset to output string, the defalut printer format will be used More...
 
string HepLib::file2str (string filename)
 read file content to string More...
 
void HepLib::str2file (const string &ostr, string filename)
 export string to a file More...
 
void HepLib::str2file (char *buff, FILE *fh)
 
vector< string > HepLib::file2strvec (string filename, bool skip_empty)
 read file content to string vector More...
 
ex HepLib::file2ex (string filename)
 read file content to ex More...
 
ex HepLib::file2ex (string filename, symtab st)
 read file content to ex More...
 
void HepLib::ex2file (const ex &expr, string filename)
 export expression file More...
 
void HepLib::ex2file (string filename, const ex &expr)
 export expression file More...
 
ex HepLib::q2ex (__float128 num)
 __float128 to ex More...
 
__float128 HepLib::ex2q (ex num)
 ex of numeric to __float128 More...
 
int HepLib::ex2int (ex num)
 ex to integer More...
 
lst HepLib::vec2lst (const exvector &ev)
 convert exvector to lst More...
 
exvector HepLib::lst2vec (const lst &alst)
 convert lst to exvector More...
 
lst HepLib::add2lst (const ex &expr)
 convert add to lst More...
 
lst HepLib::mul2lst (const ex &expr)
 convert mul to lst More...
 
lst HepLib::xlst (int bi, int ei)
 return a lst: x(bi), x(bi+1), ..., x(ei) More...
 
lst HepLib::xlst (int ei)
 return a lst: x(0), x(1), ..., x(ei) More...
 
ex HepLib::series_ex (ex const &expr_in, ex const &s0, int sn0)
 the series like Mathematica, include s^n More...
 
ex HepLib::series_ex (ex const &expr_in, symbol const &s0, int sn0)
 the series like Mathematica, include s^n More...
 
ex HepLib::diff_ex (ex const expr, ex const xp, unsigned nth, bool expand)
 the differential like Mathematica More...
 
co_epvec_t HepLib::power_expand_2 (const co_epvec_t &co_epv, int n)
 
pair< ex, epvec_t > HepLib::inner_expand_collect (ex const &expr_in, std::function< bool(const ex &)> has_func, int depth=0)
 
ex HepLib::expand_ex (ex const &expr_in, std::function< bool(const ex &)> has_func)
 the expand like Mathematica More...
 
ex HepLib::collect_ex (ex const &expr_in, std::function< bool(const ex &)> has_func, int opt)
 the collect function like Mathematica More...
 
lst HepLib::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}, ... } More...
 
ex HepLib::EvalF (ex expr)
 the nuerical evaluation, Digits=100 will be used More...
 
ex HepLib::EvalL (ex expr)
 
ex HepLib::EvalQ (ex expr)
 
ex HepLib::EvalMP (ex expr)
 
ex HepLib::NN (ex expr, int digits)
 the nuerical evaluation More...
 
bool HepLib::xPositive (ex const expr)
 check the expr is xPositive, i.e., each x-monomial item is postive More...
 
int HepLib::xSign (ex const expr)
 the always sign for expr More...
 
void HepLib::let_op_append (ex &ex_in, const ex item)
 append item into expression More...
 
void HepLib::let_op_prepend (ex &ex_in, const ex item)
 preppend item into expression More...
 
void HepLib::let_op_remove_last (ex &ex_in)
 remove last from expression More...
 
void HepLib::let_op_remove_first (ex &ex_in)
 remove first from expression More...
 
void HepLib::let_op_append (ex &ex_in, int index, ex const item)
 append item into index-th of expression More...
 
void HepLib::let_op_append (lst &ex_in, int index, ex const item)
 append item into index-th of expression More...
 
void HepLib::let_op_append (ex &ex_in, int index1, int index2, ex const item)
 append item into index1-th.index2-th of expression More...
 
void HepLib::let_op_append (lst &ex_in, int index1, int index2, ex const item)
 append item into index1-th.index2-th of expression More...
 
void HepLib::let_op_prepend (ex &ex_in, int index, ex const item)
 prepend item into index-th of expression More...
 
void HepLib::let_op_prepend (lst &ex_in, int index, ex const item)
 prepend item into index-th of expression More...
 
void HepLib::let_op_prepend (ex &ex_in, int index1, int index2, ex const item)
 prepend item into index1-th.index2-th of expression More...
 
void HepLib::let_op_prepend (lst &ex_in, int index1, int index2, ex const item)
 prepend item into index1-th.index2-th of expression More...
 
void HepLib::let_op_remove_last (ex &ex_in, int index)
 remove the last in index-th of expression More...
 
void HepLib::let_op_remove_last (lst &ex_in, int index)
 remove the last in index-th of expression More...
 
void HepLib::let_op_remove_last (ex &ex_in, int index1, int index2)
 remove the last in index1-th.index2-th of expression More...
 
void HepLib::let_op_remove_last (lst &ex_in, int index1, int index2)
 remove the last in index1-th.index2-th of expression More...
 
void HepLib::let_op_remove_first (ex &ex_in, int index)
 remove the first in index-th of expression More...
 
void HepLib::let_op_remove_first (lst &ex_in, int index)
 remove the first in index-th of expression More...
 
void HepLib::let_op_remove_first (ex &ex_in, int index1, int index2)
 remove the first in index1-th.index2-th of expression More...
 
void HepLib::let_op_remove_first (lst &ex_in, int index1, int index2)
 remove the first in index1-th.index2-th of expression More...
 
void HepLib::let_op (ex &ex_in, int index1, int index2, const ex item)
 update index1-th.index2-th of expression with item More...
 
void HepLib::let_op (lst &ex_in, int index1, int index2, const ex item)
 update index1-th.index2-th of expression with item More...
 
void HepLib::let_op (ex &ex_in, int index1, int index2, int index3, const ex item)
 update index1-th.index2-th.index3-th of expression with item More...
 
void HepLib::let_op (lst &ex_in, int index1, int index2, int index3, const ex item)
 update index1-th.index2-th.index3-th of expression with item More...
 
ex HepLib::get_op (const ex ex_in, int index1, int index2)
 return index1-th.index2-th of expression More...
 
ex HepLib::get_op (const lst ex_in, int index1, int index2)
 return index1-th.index2-th of expression More...
 
ex HepLib::get_op (const ex ex_in, int index1, int index2, int index3)
 return index1-th.index2-th.index3-th of expression More...
 
ex HepLib::get_op (const lst ex_in, int index1, int index2, int index3)
 return index1-th.index2-th.index3-th of expression More...
 
int HepLib::CpuCores ()
 return the cpu cores using OpenMP More...
 
ex HepLib::normal_fermat (const ex &expr, bool dfactor)
 return the normalizatied expression, using fermat_numer_denom More...
 
ex HepLib::collect_factors (const ex &expr)
 a wrapper for collect_common_factors, catch errors More...
 
ex HepLib::exfactor (const ex &expr, int opt)
 factorize a expression More...
 
ex HepLib::exexpand (const ex &expr, int opt)
 factorize a expression More...
 
ex HepLib::exnormal (const ex &expr, int opt)
 normalize a expression More...
 
ex HepLib::exnd (const ex &expr, int opt)
 num_den a expression More...
 
ex HepLib::form_eval (const ex &expr)
 
ex HepLib::inner_factor_form (const ex &expr)
 
ex HepLib::factor_form (const ex &expr, bool nd)
 factorize a expression using FORM More...
 
void HepLib::garWrite (const exvector &exv, string garfn)
 
void HepLib::garRead (exvector &exv, string garfn)
 
ex HepLib::add_collect_normal (const exvector &exv, ex const &pats, int opt)
 
ex HepLib::add_collect_normal (const exvector &exv, init_list const &pats, int opt)
 
ex HepLib::add_collect_normal (const exvector &exv, lst const &pats, int opt)
 
ex HepLib::add_collect_normal (const ex &e, ex const &pats, int opt)
 
ex HepLib::add_collect_normal (const ex &e, lst const &pats, int opt)
 
ex HepLib::add_collect_normal (const ex &e, init_list const &pats, int opt)
 
bool HepLib::has_w (const ex &e)
 
void HepLib::subs_w (exmap &repl)
 
void HepLib::subs_w (lst &repl)
 
void HepLib::ReShare (const ex &e)
 
void HepLib::ReShare (const lst &es)
 
void HepLib::ReShare (const ex &e1, const ex &e2)
 
void HepLib::ReShare (const ex &e1, const ex &e2, const ex &e3)
 
void HepLib::ReShare (const exvector &ev)
 
void HepLib::ReShare (const exvector &ev1, const exvector &ev2)
 
ex HepLib::nextprime (const ex &n)
 
ex HepLib::nextprime (int n)
 
ex HepLib::Rationalize (const ex &e, int dn)
 
void HepLib::set_precision (long prec, bool push)
 
void HepLib::reset_precision ()
 
long HepLib::get_precision ()
 
void HepLib::arg2map (int argc, char **argv, const char *optstring, std::map< char, std::string > &kv)
 
bool HepLib::has_symbol (const ex &e)
 

Variables

const char * HepLib::ErrColor = RED
 
const char * HepLib::WarnColor = MAGENTA
 
const char * HepLib::Color_HighLight = WHITE
 
std::stack< cln::float_format_t > HepLib::cln_prec_stack
 
std::stack< long > HepLib::digits_stack
 

Detailed Description

Basic Functions, extend GiNaC, etc.

Definition in file BASIC.cpp.

Function Documentation

◆ golden_ratio_hash()

unsigned golden_ratio_hash ( uintptr_t  n)
inline

Definition at line 9 of file BASIC.cpp.