]> 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 caa4175c3cc269b77d6619a654c5a8bd783a78f7..31893b2685e46991b685b0c4095bb270612c6706 100755 (executable)
@@ -1,5 +1,3 @@
-#!/usr/bin/perl -w
-
 $maxargs=13;
 
 sub generate_seq {
@@ -155,7 +153,7 @@ $typedef_derivative_funcp=generate(
 'const ex &','');
 
 $typedef_series_funcp=generate(
-'typedef ex (* series_funcp_${N})(${SEQ1}, const symbol &, const ex &, int);'."\n",
+'typedef ex (* series_funcp_${N})(${SEQ1}, const relational &, int);'."\n",
 'const ex &','');
 
 $eval_func_interface=generate('    function_options & eval_func(eval_funcp_${N} e);'."\n",'','');
@@ -205,9 +203,9 @@ $series_switch_statement=generate(
     <<'END_OF_SERIES_SWITCH_STATEMENT','seq[${N}-1]','');
     case ${N}:
         try {
-            res = ((series_funcp_${N})(registered_functions()[serial].series_f))(${SEQ1},s,point,order);
+            res = ((series_funcp_${N})(registered_functions()[serial].series_f))(${SEQ1},r,order);
         } catch (do_taylor) {
-            res = basic::series(s, point, order);
+            res = basic::series(r, order);
         }
         return res;
         break;
@@ -479,7 +477,7 @@ public:
     ex expand(unsigned options=0) const;
     ex eval(int level=0) const;
     ex evalf(int level=0) const;
-    ex series(const symbol & s, const ex & point, int order) const;
+    ex series(const relational & r, int order) const;
     ex thisexprseq(const exvector & v) const;
     ex thisexprseq(exvector * vp) const;
 protected:
@@ -500,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
@@ -947,12 +946,12 @@ ex function::thisexprseq(exvector * vp) const
 
 /** Implementation of ex::series for functions.
  *  \@see ex::series */
-ex function::series(const symbol & s, const ex & point, int order) const
+ex function::series(const relational & r, int order) const
 {
     GINAC_ASSERT(serial<registered_functions().size());
 
     if (registered_functions()[serial].series_f==0) {
-        return basic::series(s, point, order);
+        return basic::series(r, order);
     }
     ex res;
     switch (registered_functions()[serial].nparams) {
@@ -1116,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
 //////////