-#!/usr/bin/perl -w
-
$maxargs=13;
sub generate_seq {
'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",'','');
<<'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;
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:
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
#include "function.h"
#include "ex.h"
+#include "lst.h"
#include "archive.h"
#include "inifcns.h"
#include "utils.h"
/** 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) {
{
ex result;
- if (serial==function_index_Order) {
+ if (serial == function_index_Order) {
// Order Term function only differentiates the argument
return Order(seq[0].diff(s));
+ } else if (serial == function_index_Derivative) {
+ // Inert derivative performs chain rule on the first argument only, and
+ // adds differentiation parameter to list (second argument)
+ GINAC_ASSERT(is_ex_exactly_of_type(seq[0], function));
+ GINAC_ASSERT(is_ex_exactly_of_type(seq[1], function));
+ ex fcn = seq[0];
+ ex arg_diff;
+ for (unsigned i=0; i!=fcn.nops(); i++) {
+ arg_diff = fcn.op(i).diff(s);
+ if (!arg_diff.is_zero()) {
+ lst new_lst = ex_to_lst(seq[1]);
+ new_lst.append(i);
+ result += arg_diff * Derivative(fcn, new_lst);
+ }
+ }
} else {
// Chain rule
ex arg_diff;
GINAC_ASSERT(serial<registered_functions().size());
if (registered_functions()[serial].derivative_f==0) {
- return Derivative(*this, diff_param);
+ return Derivative(*this, lst(diff_param));
}
switch (registered_functions()[serial].nparams) {
// the following lines have been generated for max. ${maxargs} parameters
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
//////////