$declare_function_macro_no_namespace=generate(
<<'END_OF_DECLARE_FUNCTION_MACRO_NO_NAMESPACE','ex const & p${N}','p${N}');
#define DECLARE_FUNCTION_${N}P(NAME) \\
-extern unsigned function_index_##NAME; \\
+extern const unsigned function_index_##NAME; \\
inline function NAME(${SEQ1}) { \\
return function(function_index_##NAME, ${SEQ2}); \\
}
$series_switch_statement=generate(
<<'END_OF_SERIES_SWITCH_STATEMENT','seq[${N}-1]','');
case ${N}:
- return ((series_funcp_${N})(registered_functions()[serial].s))(${SEQ1},s,point,order);
+ try {
+ res = ((series_funcp_${N})(registered_functions()[serial].s))(${SEQ1},s,point,order);
+ } catch (do_taylor) {
+ res = basic::series(s, point, order);
+ }
+ return res;
break;
END_OF_SERIES_SWITCH_STATEMENT
* Please do not modify it directly, edit the perl script instead!
* function.pl options: \$maxargs=${maxargs}
*
- * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#ifndef NO_GINAC_NAMESPACE
#define REGISTER_FUNCTION(NAME,E,EF,D,S) \\
-
const unsigned function_index_##NAME=GiNaC::function::register_new(#NAME,E,EF,D,S);
#else // ndef NO_GINAC_NAMESPACE
+#define REGISTER_FUNCTION(NAME,E,EF,D,S) \\
const unsigned function_index_##NAME=function::register_new(#NAME,E,EF,D,S);
#endif // ndef NO_GINAC_NAMESPACE
and user defined functions */
class function : public exprseq
{
+ GINAC_DECLARE_REGISTERED_CLASS(function, exprseq)
+
// CINT has a linking problem
friend void ginsh_get_ginac_functions(void);
* Please do not modify it directly, edit the perl script instead!
* function.pl options: \$maxargs=${maxargs}
*
- * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "function.h"
#include "ex.h"
+#include "archive.h"
+#include "utils.h"
#include "debugmsg.h"
#ifndef NO_GINAC_NAMESPACE
namespace GiNaC {
#endif // ndef NO_GINAC_NAMESPACE
+GINAC_IMPLEMENT_REGISTERED_CLASS(function, exprseq)
+
//////////
// default constructor, destructor, copy constructor assignment operator and helpers
//////////
tinfo_key = TINFO_function;
}
+//////////
+// archiving
+//////////
+
+/** Construct object from archive_node. */
+function::function(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+{
+ debugmsg("function constructor from archive_node", LOGLEVEL_CONSTRUCT);
+
+ // Find serial number by function name
+ string s;
+ if (n.find_string("name", s)) {
+ unsigned int ser = 0;
+ vector<registered_function_info>::const_iterator i = registered_functions().begin(), iend = registered_functions().end();
+ while (i != iend) {
+ if (s == i->name) {
+ serial = ser;
+ return;
+ }
+ i++; ser++;
+ }
+ throw (std::runtime_error("unknown function '" + s + "' in archive"));
+ } else
+ throw (std::runtime_error("unnamed function in archive"));
+}
+
+/** Unarchive the object. */
+ex function::unarchive(const archive_node &n, const lst &sym_lst)
+{
+ return (new function(n, sym_lst))->setflag(status_flags::dynallocated);
+}
+
+/** Archive the object. */
+void function::archive(archive_node &n) const
+{
+ inherited::archive(n);
+ GINAC_ASSERT(serial < registered_functions().size());
+ n.add_string("name", registered_functions()[serial].name);
+}
+
//////////
// functions overriding virtual functions from bases classes
//////////
<< ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
<< ", flags=" << flags
<< ", nops=" << nops() << endl;
- for (int i=0; i<nops(); ++i) {
+ for (unsigned i=0; i<nops(); ++i) {
seq[i].printtree(os,indent+delta_indent);
}
os << string(indent+delta_indent,' ') << "=====" << endl;
if (registered_functions()[serial].s==0) {
return basic::series(s, point, order);
}
+ ex res;
switch (registered_functions()[serial].nparams) {
// the following lines have been generated for max. ${maxargs} parameters
${series_switch_statement}