X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Ffunction.pl;h=318e46c19bda4143f4f77908f19928de6cbdf203;hp=1f944f1a4f9c74a07dc13bb815c34f1dec61a65f;hb=c734f9bb6a1ce0aad913aa19a56542d84d86c60d;hpb=6d7bf9ee5a7ce05cb3a23dae664e781d7325d7b8 diff --git a/ginac/function.pl b/ginac/function.pl index 1f944f1a..318e46c1 100755 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -1,4 +1,24 @@ -$maxargs=13; +# This perl script automatically generates function.h and function.cpp + +# function.pl options: \$maxargs=${maxargs} +# +# GiNaC Copyright (C) 1999-2004 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +$maxargs=14; sub generate_seq { my ($seq_template,$n)=@_; @@ -40,6 +60,7 @@ $declare_function_macro = generate( <<'END_OF_DECLARE_FUNCTION_MACRO','typename T${N}','const T${N} & p${N}','GiNaC::ex(p${N})'); #define DECLARE_FUNCTION_${N}P(NAME) \\ class NAME##_SERIAL { public: static unsigned serial; }; \\ +const unsigned NAME##_NPARAMS = ${N}; \\ template<${SEQ1}> const GiNaC::function NAME(${SEQ2}) { \\ return GiNaC::function(NAME##_SERIAL::serial, ${SEQ3}); \\ } @@ -54,6 +75,10 @@ $typedef_evalf_funcp=generate( 'typedef ex (* evalf_funcp_${N})(${SEQ1});'."\n", 'const ex &','',''); +$typedef_conjugate_funcp=generate( +'typedef ex (* conjugate_funcp_${N})(${SEQ1});'."\n", +'const ex &','',''); + $typedef_derivative_funcp=generate( 'typedef ex (* derivative_funcp_${N})(${SEQ1}, unsigned);'."\n", 'const ex &','',''); @@ -70,6 +95,8 @@ $eval_func_interface=generate(' function_options & eval_func(eval_funcp_${N} $evalf_func_interface=generate(' function_options & evalf_func(evalf_funcp_${N} ef);'."\n",'','',''); +$conjugate_func_interface=generate(' function_options & conjugate_func(conjugate_funcp_${N} d);'."\n",'','',''); + $derivative_func_interface=generate(' function_options & derivative_func(derivative_funcp_${N} d);'."\n",'','',''); $series_func_interface=generate(' function_options & series_func(series_funcp_${N} s);'."\n",'','',''); @@ -110,6 +137,12 @@ $evalf_switch_statement=generate( return ((evalf_funcp_${N})(opt.evalf_f))(${SEQ1}); END_OF_EVALF_SWITCH_STATEMENT +$conjugate_switch_statement=generate( + <<'END_OF_DIFF_SWITCH_STATEMENT','seq[${N}-1]','',''); + case ${N}: + return ((conjugate_funcp_${N})(opt.conjugate_f))(${SEQ1}); +END_OF_DIFF_SWITCH_STATEMENT + $diff_switch_statement=generate( <<'END_OF_DIFF_SWITCH_STATEMENT','seq[${N}-1]','',''); case ${N}: @@ -154,6 +187,16 @@ function_options & function_options::evalf_func(evalf_funcp_${N} ef) } END_OF_EVALF_FUNC_IMPLEMENTATION +$conjugate_func_implementation=generate( + <<'END_OF_CONJUGATE_FUNC_IMPLEMENTATION','','',''); +function_options & function_options::conjugate_func(conjugate_funcp_${N} c) +{ + test_and_set_nparams(${N}); + conjugate_f = conjugate_funcp(c); + return *this; +} +END_OF_CONJUGATE_FUNC_IMPLEMENTATION + $derivative_func_implementation=generate( <<'END_OF_DERIVATIVE_FUNC_IMPLEMENTATION','','',''); function_options & function_options::derivative_func(derivative_funcp_${N} d) @@ -184,7 +227,7 @@ $interface=< print_dispatch_table; @@ -317,6 +369,7 @@ protected: bool eval_use_exvector_args; bool evalf_use_exvector_args; + bool conjugate_use_exvector_args; bool derivative_use_exvector_args; bool series_use_exvector_args; bool print_use_exvector_args; @@ -370,6 +423,7 @@ public: ex series(const relational & r, int order, unsigned options = 0) const; ex thiscontainer(const exvector & v) const; ex thiscontainer(std::auto_ptr vp) const; + ex conjugate() const; protected: ex derivative(const symbol & s) const; bool is_equal_same_type(const basic & other) const; @@ -433,7 +487,7 @@ $implementation=<