X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Ffunction.pl;h=d75e8f645ebf3e359d565067837b31ba60d7a174;hp=80f9c5e5aaa8bb65065e7fc2c7c60cd6421b8efc;hb=2dcbb3a4955e294d62b45c3db8bdccb7d6fdf833;hpb=d448856f20cb58f939ddbf636e7f72e3599b1468 diff --git a/ginac/function.pl b/ginac/function.pl index 80f9c5e5..d75e8f64 100755 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -80,7 +80,6 @@ $constructors_implementation=generate( function::function(unsigned ser, ${SEQ1}) : exprseq(${SEQ2}), serial(ser) { - debugmsg(\"function ctor from unsigned,${N}*ex\",LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_function; } END_OF_CONSTRUCTORS_IMPLEMENTATION @@ -165,7 +164,7 @@ $interface=<(VAR)) { \\ - automatic_typecheck=false; \\ -} else - -#define TYPECHECK_INTEGER(VAR) \\ -if (!(VAR).info(GiNaC::info_flags::integer)) { \\ - automatic_typecheck=false; \\ -} else - -#define END_TYPECHECK(RV) \\ -{} \\ -if (!automatic_typecheck) { \\ - return RV.hold(); \\ -} - namespace GiNaC { class function; @@ -240,6 +217,13 @@ $typedef_derivative_funcp $typedef_series_funcp // end of generated lines +// Alternatively, an exvector may be passed into the static function, instead +// of individual ex objects. Then, the number of arguments is not limited. +typedef ex (* eval_funcp_exvector)(const exvector &); +typedef ex (* evalf_funcp_exvector)(const exvector &); +typedef ex (* derivative_funcp_exvector)(const exvector &, unsigned); +typedef ex (* series_funcp_exvector)(const exvector &, const relational &, int, unsigned); + class function_options { friend class function; @@ -257,6 +241,11 @@ $evalf_func_interface $derivative_func_interface $series_func_interface // end of generated lines + function_options & eval_func(eval_funcp_exvector e); + function_options & evalf_func(evalf_funcp_exvector ef); + function_options & derivative_func(derivative_funcp_exvector d); + function_options & series_func(series_funcp_exvector s); + function_options & set_return_type(unsigned rt, unsigned rtt=0); function_options & do_not_evalf_params(void); function_options & remember(unsigned size, unsigned assoc_size=0, @@ -290,6 +279,11 @@ protected: unsigned remember_assoc_size; unsigned remember_strategy; + bool eval_use_exvector_args; + bool evalf_use_exvector_args; + bool derivative_use_exvector_args; + bool series_use_exvector_args; + unsigned functions_with_same_name; ex symtree; @@ -326,9 +320,6 @@ $constructors_interface public: void print(const print_context & c, unsigned level = 0) const; unsigned precedence(void) const {return 70;} - int degree(const ex & s) const; - int ldegree(const ex & s) const; - ex coeff(const ex & s, int n = 1) const; ex expand(unsigned options=0) const; ex eval(int level=0) const; ex evalf(int level=0) const; @@ -354,10 +345,11 @@ protected: void store_remember_table(ex const & result) const; public: static unsigned register_new(function_options const & opt); + static unsigned current_serial; static unsigned find_function(const std::string &name, unsigned nparams); unsigned get_serial(void) const {return serial;} std::string get_name(void) const; - + // member variables protected: @@ -373,7 +365,7 @@ template<> inline bool is_exactly_a(const basic & obj) } #define is_ex_the_function(OBJ, FUNCNAME) \\ - (is_exactly_a(OBJ) && ex_to(OBJ).get_serial() == function_index_##FUNCNAME) + (GiNaC::is_exactly_a(OBJ) && GiNaC::ex_to(OBJ).get_serial() == function_index_##FUNCNAME) } // namespace GiNaC @@ -391,7 +383,7 @@ $implementation=< #include #include #include @@ -422,7 +415,6 @@ $implementation=<(s)) ? 1 : 0; -} - -int function::ldegree(const ex & s) const -{ - return is_equal(ex_to(s)) ? 1 : 0; -} - -ex function::coeff(const ex & s, int n) const -{ - if (is_equal(ex_to(s))) - return n==1 ? _ex1() : _ex0(); - else - return n==0 ? ex(*this) : _ex0(); -} - ex function::eval(int level) const { GINAC_ASSERT(serial