]> www.ginac.de Git - ginac.git/blobdiff - ginac/function.pl
- expressions can now be read from streams; the input expression can contain
[ginac.git] / ginac / function.pl
index bb6c974f6f83ee6b6634cec5b5c14f28d0962a16..31893b2685e46991b685b0c4095bb270612c6706 100755 (executable)
@@ -498,6 +498,7 @@ protected:
     void store_remember_table(ex const & result) const;
 public:
     static unsigned register_new(function_options const & opt);
+    static unsigned find_function(const string &name, unsigned nparams);
     unsigned getserial(void) const {return serial;}
     
 // member variables
@@ -1114,6 +1115,21 @@ unsigned function::register_new(function_options const & opt)
     return registered_functions().size()-1;
 }
 
+/** Find serial number of function by name and number of parameters.
+ *  Throws exception if function was not found. */
+unsigned function::find_function(const string &name, unsigned nparams)
+{
+    vector<function_options>::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end();
+    unsigned serial = 0;
+    while (i != end) {
+        if (i->get_name() == name && i->get_nparams() == nparams)
+            return serial;
+        i++;
+        serial++;
+    }
+    throw (std::runtime_error("no function '" + name + "' with " + ToString(nparams) + " parameters defined"));
+}
+
 //////////
 // static member variables
 //////////