function::function(unsigned ser, const exvector & v, bool discardable)
: exprseq(v,discardable), serial(ser)
{
+ if ( ser >= registered_functions().size() ) {
+ throw std::runtime_error("function does not exist");
+ }
}
function::function(unsigned ser, std::auto_ptr<exvector> vp)
Autogen definitions ginacfcns;
-function = { name = "log"; };
-function = { name = "exp"; };
-function = { name = "sin"; };
-function = { name = "cos"; };
-function = { name = "tan"; };
-function = { name = "asin"; };
-function = { name = "acos"; };
-function = { name = "atan"; };
-
-function = { name = "sinh"; };
-function = { name = "cosh"; };
-function = { name = "tanh"; };
-function = { name = "asinh"; };
-function = { name = "acosh"; };
-function = { name = "atanh"; };
-
-function = {
- name = "atan2";
- args = 2;
-};
-
-function = {
- name = "Li2";
- comment = "Dilogarithm";
-};
-
-function = {
- name = "Li3";
- comment = "Trilogarithm";
-};
-
-function = {
- name = "zetaderiv";
- comment = "Derivatives of Riemann's Zeta-function";
- args = 2;
-};
-
-function = {
- name = "Li";
- args = 2;
- comment = "Polylogarithm and multiple polylogarithm";
-};
-
-function = {
- name = "S";
- args = 3;
- comment = "Nielsen's generalized polylogarithm";
-};
-
-function = {
- name = "H";
- args = 2;
- comment = "Harmonic polylogarithm";
-};
-
-function = { name = "lgamma"; };
-function = { name = "tgamma"; };
-
-function = {
- name = "beta";
- args = 2;
- comment = "Beta-function";
-};
-
-function = { name = "factorial"; };
-
-function = {
- name = "binomial";
- args = 2;
-};
-
-function = {
- name = "Order";
- comment = "Order term function (for truncated power series)";
-};
-
/* Thease are not functions, but anyway ... */
function = { name = "sqrt"; };
static bool initialized = false;
static prototype_table reader;
if (!initialized) {
+ [+ FOR function +]
+ reader[make_pair("[+ (get "name") +]", [+
+ (if (exist? "args") (get "args") "1")
+ +])] = [+ (get "name") +]_reader;[+
+ ENDFOR +]
try {
for ( unsigned ser=0; ; ++ser ) {
GiNaC::function f(ser);
Parse_error_("no function \"" << name << "\" with " <<
args.size() << " arguments");
}
- ex ret = GiNaC::function(reinterpret_cast<unsigned>(reader->second), args);
- return ret;
+ // dirty hack to distinguish between serial numbers of functions and real
+ // pointers.
+ ex ret;
+ try {
+ ret = GiNaC::function(reinterpret_cast<unsigned>(reader->second), args);
+ }
+ catch ( std::runtime_error ) {
+ ret = reader->second(args);
+ }
+ return ret;
}
/// paren_expr: '(' expression ')'