From 866b3eb23253a272788d8791b1ed023e63674d50 Mon Sep 17 00:00:00 2001 From: Jens Vollinga Date: Sun, 9 Aug 2009 23:38:48 +0200 Subject: [PATCH] Added get_builtin_reader() that parses only the builtin GiNaC functions and pow, sqrt, and power. --- ginac/parser/default_reader.tpl | 53 +++++++++++++++++++++++++++++++++ ginac/parser/parse_context.h | 8 ++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/ginac/parser/default_reader.tpl b/ginac/parser/default_reader.tpl index 81f89bf4..ae36dde0 100644 --- a/ginac/parser/default_reader.tpl +++ b/ginac/parser/default_reader.tpl @@ -89,4 +89,57 @@ const prototype_table& get_default_reader() return reader; } +const prototype_table& get_builtin_reader() +{ + using std::make_pair; + 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 +] + enum { + log, + exp, + sin, + cos, + tan, + asin, + acos, + atan, + sinh, + cosh, + tanh, + asinh, + acosh, + atanh, + atan2, + Li2, + Li3, + zetaderiv, + Li, + S, + H, + lgamma, + tgamma, + beta, + factorial, + binomial, + Order, + NFUNCTIONS + }; + std::vector::const_iterator it = + registered_functions_hack::get_registered_functions().begin(); + unsigned serial = 0; + for ( ; serialget_name(), it->get_nparams()); + reader[proto] = encode_serial_as_reader_func(serial); + } + initialized = true; + } + return reader; +} + } // namespace GiNaC diff --git a/ginac/parser/parse_context.h b/ginac/parser/parse_context.h index 81b2cd15..1145a871 100644 --- a/ginac/parser/parse_context.h +++ b/ginac/parser/parse_context.h @@ -93,9 +93,15 @@ typedef std::map prototype_table; /** * Default prototype table. * - * It supports most of builtin GiNaC functions. + * It supports all defined GiNaC functions and "pow", "sqrt", and "power". */ extern const prototype_table& get_default_reader(); +/** + * Builtin prototype table. + * + * It supports only the builtin GiNaC functions and "pow", "sqrt", and "power". + */ +extern const prototype_table& get_builtin_reader(); } // namespace GiNaC -- 2.44.0