GiNaC  1.6.2
function.cpp
Go to the documentation of this file.
00001 
00005 /*
00006  *  This file was generated automatically by function.pl.
00007  *  Please do not modify it directly, edit the perl script instead!
00008  *  function.pl options: $maxargs=14
00009  *
00010  *  GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany
00011  *
00012  *  This program is free software; you can redistribute it and/or modify
00013  *  it under the terms of the GNU General Public License as published by
00014  *  the Free Software Foundation; either version 2 of the License, or
00015  *  (at your option) any later version.
00016  *
00017  *  This program is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *  GNU General Public License for more details.
00021  *
00022  *  You should have received a copy of the GNU General Public License
00023  *  along with this program; if not, write to the Free Software
00024  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00025  */
00026 
00027 #include "function.h"
00028 #include "operators.h"
00029 #include "fderivative.h"
00030 #include "ex.h"
00031 #include "lst.h"
00032 #include "symmetry.h"
00033 #include "print.h"
00034 #include "power.h"
00035 #include "archive.h"
00036 #include "inifcns.h"
00037 #include "tostring.h"
00038 #include "utils.h"
00039 #include "hash_seed.h"
00040 #include "remember.h"
00041 
00042 #include <iostream>
00043 #include <limits>
00044 #include <list>
00045 #include <stdexcept>
00046 #include <string>
00047 
00048 namespace GiNaC {
00049 
00051 // helper class function_options
00053 
00054 function_options::function_options()
00055 {
00056     initialize();
00057 }
00058 
00059 function_options::function_options(std::string const & n, std::string const & tn)
00060 {
00061     initialize();
00062     set_name(n, tn);
00063 }
00064 
00065 function_options::function_options(std::string const & n, unsigned np)
00066 {
00067     initialize();
00068     set_name(n, std::string());
00069     nparams = np;
00070 }
00071 
00072 function_options::~function_options()
00073 {
00074     // nothing to clean up at the moment
00075 }
00076 
00077 void function_options::initialize()
00078 {
00079     set_name("unnamed_function", "\\mbox{unnamed}");
00080     nparams = 0;
00081     eval_f = evalf_f = real_part_f = imag_part_f = conjugate_f = derivative_f
00082         = power_f = series_f = 0;
00083     evalf_params_first = true;
00084     use_return_type = false;
00085     eval_use_exvector_args = false;
00086     evalf_use_exvector_args = false;
00087     conjugate_use_exvector_args = false;
00088     real_part_use_exvector_args = false;
00089     imag_part_use_exvector_args = false;
00090     derivative_use_exvector_args = false;
00091     power_use_exvector_args = false;
00092     series_use_exvector_args = false;
00093     print_use_exvector_args = false;
00094     use_remember = false;
00095     functions_with_same_name = 1;
00096     symtree = 0;
00097 }
00098 
00099 function_options & function_options::set_name(std::string const & n,
00100                                               std::string const & tn)
00101 {
00102     name = n;
00103     if (tn==std::string())
00104         TeX_name = "\\mbox{"+name+"}";
00105     else
00106         TeX_name = tn;
00107     return *this;
00108 }
00109 
00110 function_options & function_options::latex_name(std::string const & tn)
00111 {
00112     TeX_name = tn;
00113     return *this;
00114 }
00115 
00116 // the following lines have been generated for max. 14 parameters
00117 function_options & function_options::eval_func(eval_funcp_1 e)
00118 {
00119     test_and_set_nparams(1);
00120     eval_f = eval_funcp(e);
00121     return *this;
00122 }
00123 function_options & function_options::eval_func(eval_funcp_2 e)
00124 {
00125     test_and_set_nparams(2);
00126     eval_f = eval_funcp(e);
00127     return *this;
00128 }
00129 function_options & function_options::eval_func(eval_funcp_3 e)
00130 {
00131     test_and_set_nparams(3);
00132     eval_f = eval_funcp(e);
00133     return *this;
00134 }
00135 function_options & function_options::eval_func(eval_funcp_4 e)
00136 {
00137     test_and_set_nparams(4);
00138     eval_f = eval_funcp(e);
00139     return *this;
00140 }
00141 function_options & function_options::eval_func(eval_funcp_5 e)
00142 {
00143     test_and_set_nparams(5);
00144     eval_f = eval_funcp(e);
00145     return *this;
00146 }
00147 function_options & function_options::eval_func(eval_funcp_6 e)
00148 {
00149     test_and_set_nparams(6);
00150     eval_f = eval_funcp(e);
00151     return *this;
00152 }
00153 function_options & function_options::eval_func(eval_funcp_7 e)
00154 {
00155     test_and_set_nparams(7);
00156     eval_f = eval_funcp(e);
00157     return *this;
00158 }
00159 function_options & function_options::eval_func(eval_funcp_8 e)
00160 {
00161     test_and_set_nparams(8);
00162     eval_f = eval_funcp(e);
00163     return *this;
00164 }
00165 function_options & function_options::eval_func(eval_funcp_9 e)
00166 {
00167     test_and_set_nparams(9);
00168     eval_f = eval_funcp(e);
00169     return *this;
00170 }
00171 function_options & function_options::eval_func(eval_funcp_10 e)
00172 {
00173     test_and_set_nparams(10);
00174     eval_f = eval_funcp(e);
00175     return *this;
00176 }
00177 function_options & function_options::eval_func(eval_funcp_11 e)
00178 {
00179     test_and_set_nparams(11);
00180     eval_f = eval_funcp(e);
00181     return *this;
00182 }
00183 function_options & function_options::eval_func(eval_funcp_12 e)
00184 {
00185     test_and_set_nparams(12);
00186     eval_f = eval_funcp(e);
00187     return *this;
00188 }
00189 function_options & function_options::eval_func(eval_funcp_13 e)
00190 {
00191     test_and_set_nparams(13);
00192     eval_f = eval_funcp(e);
00193     return *this;
00194 }
00195 function_options & function_options::eval_func(eval_funcp_14 e)
00196 {
00197     test_and_set_nparams(14);
00198     eval_f = eval_funcp(e);
00199     return *this;
00200 }
00201 
00202 function_options & function_options::evalf_func(evalf_funcp_1 ef)
00203 {
00204     test_and_set_nparams(1);
00205     evalf_f = evalf_funcp(ef);
00206     return *this;
00207 }
00208 function_options & function_options::evalf_func(evalf_funcp_2 ef)
00209 {
00210     test_and_set_nparams(2);
00211     evalf_f = evalf_funcp(ef);
00212     return *this;
00213 }
00214 function_options & function_options::evalf_func(evalf_funcp_3 ef)
00215 {
00216     test_and_set_nparams(3);
00217     evalf_f = evalf_funcp(ef);
00218     return *this;
00219 }
00220 function_options & function_options::evalf_func(evalf_funcp_4 ef)
00221 {
00222     test_and_set_nparams(4);
00223     evalf_f = evalf_funcp(ef);
00224     return *this;
00225 }
00226 function_options & function_options::evalf_func(evalf_funcp_5 ef)
00227 {
00228     test_and_set_nparams(5);
00229     evalf_f = evalf_funcp(ef);
00230     return *this;
00231 }
00232 function_options & function_options::evalf_func(evalf_funcp_6 ef)
00233 {
00234     test_and_set_nparams(6);
00235     evalf_f = evalf_funcp(ef);
00236     return *this;
00237 }
00238 function_options & function_options::evalf_func(evalf_funcp_7 ef)
00239 {
00240     test_and_set_nparams(7);
00241     evalf_f = evalf_funcp(ef);
00242     return *this;
00243 }
00244 function_options & function_options::evalf_func(evalf_funcp_8 ef)
00245 {
00246     test_and_set_nparams(8);
00247     evalf_f = evalf_funcp(ef);
00248     return *this;
00249 }
00250 function_options & function_options::evalf_func(evalf_funcp_9 ef)
00251 {
00252     test_and_set_nparams(9);
00253     evalf_f = evalf_funcp(ef);
00254     return *this;
00255 }
00256 function_options & function_options::evalf_func(evalf_funcp_10 ef)
00257 {
00258     test_and_set_nparams(10);
00259     evalf_f = evalf_funcp(ef);
00260     return *this;
00261 }
00262 function_options & function_options::evalf_func(evalf_funcp_11 ef)
00263 {
00264     test_and_set_nparams(11);
00265     evalf_f = evalf_funcp(ef);
00266     return *this;
00267 }
00268 function_options & function_options::evalf_func(evalf_funcp_12 ef)
00269 {
00270     test_and_set_nparams(12);
00271     evalf_f = evalf_funcp(ef);
00272     return *this;
00273 }
00274 function_options & function_options::evalf_func(evalf_funcp_13 ef)
00275 {
00276     test_and_set_nparams(13);
00277     evalf_f = evalf_funcp(ef);
00278     return *this;
00279 }
00280 function_options & function_options::evalf_func(evalf_funcp_14 ef)
00281 {
00282     test_and_set_nparams(14);
00283     evalf_f = evalf_funcp(ef);
00284     return *this;
00285 }
00286 
00287 function_options & function_options::conjugate_func(conjugate_funcp_1 c)
00288 {
00289     test_and_set_nparams(1);
00290     conjugate_f = conjugate_funcp(c);
00291     return *this;
00292 }
00293 function_options & function_options::conjugate_func(conjugate_funcp_2 c)
00294 {
00295     test_and_set_nparams(2);
00296     conjugate_f = conjugate_funcp(c);
00297     return *this;
00298 }
00299 function_options & function_options::conjugate_func(conjugate_funcp_3 c)
00300 {
00301     test_and_set_nparams(3);
00302     conjugate_f = conjugate_funcp(c);
00303     return *this;
00304 }
00305 function_options & function_options::conjugate_func(conjugate_funcp_4 c)
00306 {
00307     test_and_set_nparams(4);
00308     conjugate_f = conjugate_funcp(c);
00309     return *this;
00310 }
00311 function_options & function_options::conjugate_func(conjugate_funcp_5 c)
00312 {
00313     test_and_set_nparams(5);
00314     conjugate_f = conjugate_funcp(c);
00315     return *this;
00316 }
00317 function_options & function_options::conjugate_func(conjugate_funcp_6 c)
00318 {
00319     test_and_set_nparams(6);
00320     conjugate_f = conjugate_funcp(c);
00321     return *this;
00322 }
00323 function_options & function_options::conjugate_func(conjugate_funcp_7 c)
00324 {
00325     test_and_set_nparams(7);
00326     conjugate_f = conjugate_funcp(c);
00327     return *this;
00328 }
00329 function_options & function_options::conjugate_func(conjugate_funcp_8 c)
00330 {
00331     test_and_set_nparams(8);
00332     conjugate_f = conjugate_funcp(c);
00333     return *this;
00334 }
00335 function_options & function_options::conjugate_func(conjugate_funcp_9 c)
00336 {
00337     test_and_set_nparams(9);
00338     conjugate_f = conjugate_funcp(c);
00339     return *this;
00340 }
00341 function_options & function_options::conjugate_func(conjugate_funcp_10 c)
00342 {
00343     test_and_set_nparams(10);
00344     conjugate_f = conjugate_funcp(c);
00345     return *this;
00346 }
00347 function_options & function_options::conjugate_func(conjugate_funcp_11 c)
00348 {
00349     test_and_set_nparams(11);
00350     conjugate_f = conjugate_funcp(c);
00351     return *this;
00352 }
00353 function_options & function_options::conjugate_func(conjugate_funcp_12 c)
00354 {
00355     test_and_set_nparams(12);
00356     conjugate_f = conjugate_funcp(c);
00357     return *this;
00358 }
00359 function_options & function_options::conjugate_func(conjugate_funcp_13 c)
00360 {
00361     test_and_set_nparams(13);
00362     conjugate_f = conjugate_funcp(c);
00363     return *this;
00364 }
00365 function_options & function_options::conjugate_func(conjugate_funcp_14 c)
00366 {
00367     test_and_set_nparams(14);
00368     conjugate_f = conjugate_funcp(c);
00369     return *this;
00370 }
00371 
00372 function_options & function_options::real_part_func(real_part_funcp_1 c)
00373 {
00374     test_and_set_nparams(1);
00375     real_part_f = real_part_funcp(c);
00376     return *this;
00377 }
00378 function_options & function_options::real_part_func(real_part_funcp_2 c)
00379 {
00380     test_and_set_nparams(2);
00381     real_part_f = real_part_funcp(c);
00382     return *this;
00383 }
00384 function_options & function_options::real_part_func(real_part_funcp_3 c)
00385 {
00386     test_and_set_nparams(3);
00387     real_part_f = real_part_funcp(c);
00388     return *this;
00389 }
00390 function_options & function_options::real_part_func(real_part_funcp_4 c)
00391 {
00392     test_and_set_nparams(4);
00393     real_part_f = real_part_funcp(c);
00394     return *this;
00395 }
00396 function_options & function_options::real_part_func(real_part_funcp_5 c)
00397 {
00398     test_and_set_nparams(5);
00399     real_part_f = real_part_funcp(c);
00400     return *this;
00401 }
00402 function_options & function_options::real_part_func(real_part_funcp_6 c)
00403 {
00404     test_and_set_nparams(6);
00405     real_part_f = real_part_funcp(c);
00406     return *this;
00407 }
00408 function_options & function_options::real_part_func(real_part_funcp_7 c)
00409 {
00410     test_and_set_nparams(7);
00411     real_part_f = real_part_funcp(c);
00412     return *this;
00413 }
00414 function_options & function_options::real_part_func(real_part_funcp_8 c)
00415 {
00416     test_and_set_nparams(8);
00417     real_part_f = real_part_funcp(c);
00418     return *this;
00419 }
00420 function_options & function_options::real_part_func(real_part_funcp_9 c)
00421 {
00422     test_and_set_nparams(9);
00423     real_part_f = real_part_funcp(c);
00424     return *this;
00425 }
00426 function_options & function_options::real_part_func(real_part_funcp_10 c)
00427 {
00428     test_and_set_nparams(10);
00429     real_part_f = real_part_funcp(c);
00430     return *this;
00431 }
00432 function_options & function_options::real_part_func(real_part_funcp_11 c)
00433 {
00434     test_and_set_nparams(11);
00435     real_part_f = real_part_funcp(c);
00436     return *this;
00437 }
00438 function_options & function_options::real_part_func(real_part_funcp_12 c)
00439 {
00440     test_and_set_nparams(12);
00441     real_part_f = real_part_funcp(c);
00442     return *this;
00443 }
00444 function_options & function_options::real_part_func(real_part_funcp_13 c)
00445 {
00446     test_and_set_nparams(13);
00447     real_part_f = real_part_funcp(c);
00448     return *this;
00449 }
00450 function_options & function_options::real_part_func(real_part_funcp_14 c)
00451 {
00452     test_and_set_nparams(14);
00453     real_part_f = real_part_funcp(c);
00454     return *this;
00455 }
00456 
00457 function_options & function_options::imag_part_func(imag_part_funcp_1 c)
00458 {
00459     test_and_set_nparams(1);
00460     imag_part_f = imag_part_funcp(c);
00461     return *this;
00462 }
00463 function_options & function_options::imag_part_func(imag_part_funcp_2 c)
00464 {
00465     test_and_set_nparams(2);
00466     imag_part_f = imag_part_funcp(c);
00467     return *this;
00468 }
00469 function_options & function_options::imag_part_func(imag_part_funcp_3 c)
00470 {
00471     test_and_set_nparams(3);
00472     imag_part_f = imag_part_funcp(c);
00473     return *this;
00474 }
00475 function_options & function_options::imag_part_func(imag_part_funcp_4 c)
00476 {
00477     test_and_set_nparams(4);
00478     imag_part_f = imag_part_funcp(c);
00479     return *this;
00480 }
00481 function_options & function_options::imag_part_func(imag_part_funcp_5 c)
00482 {
00483     test_and_set_nparams(5);
00484     imag_part_f = imag_part_funcp(c);
00485     return *this;
00486 }
00487 function_options & function_options::imag_part_func(imag_part_funcp_6 c)
00488 {
00489     test_and_set_nparams(6);
00490     imag_part_f = imag_part_funcp(c);
00491     return *this;
00492 }
00493 function_options & function_options::imag_part_func(imag_part_funcp_7 c)
00494 {
00495     test_and_set_nparams(7);
00496     imag_part_f = imag_part_funcp(c);
00497     return *this;
00498 }
00499 function_options & function_options::imag_part_func(imag_part_funcp_8 c)
00500 {
00501     test_and_set_nparams(8);
00502     imag_part_f = imag_part_funcp(c);
00503     return *this;
00504 }
00505 function_options & function_options::imag_part_func(imag_part_funcp_9 c)
00506 {
00507     test_and_set_nparams(9);
00508     imag_part_f = imag_part_funcp(c);
00509     return *this;
00510 }
00511 function_options & function_options::imag_part_func(imag_part_funcp_10 c)
00512 {
00513     test_and_set_nparams(10);
00514     imag_part_f = imag_part_funcp(c);
00515     return *this;
00516 }
00517 function_options & function_options::imag_part_func(imag_part_funcp_11 c)
00518 {
00519     test_and_set_nparams(11);
00520     imag_part_f = imag_part_funcp(c);
00521     return *this;
00522 }
00523 function_options & function_options::imag_part_func(imag_part_funcp_12 c)
00524 {
00525     test_and_set_nparams(12);
00526     imag_part_f = imag_part_funcp(c);
00527     return *this;
00528 }
00529 function_options & function_options::imag_part_func(imag_part_funcp_13 c)
00530 {
00531     test_and_set_nparams(13);
00532     imag_part_f = imag_part_funcp(c);
00533     return *this;
00534 }
00535 function_options & function_options::imag_part_func(imag_part_funcp_14 c)
00536 {
00537     test_and_set_nparams(14);
00538     imag_part_f = imag_part_funcp(c);
00539     return *this;
00540 }
00541 
00542 function_options & function_options::derivative_func(derivative_funcp_1 d)
00543 {
00544     test_and_set_nparams(1);
00545     derivative_f = derivative_funcp(d);
00546     return *this;
00547 }
00548 function_options & function_options::derivative_func(derivative_funcp_2 d)
00549 {
00550     test_and_set_nparams(2);
00551     derivative_f = derivative_funcp(d);
00552     return *this;
00553 }
00554 function_options & function_options::derivative_func(derivative_funcp_3 d)
00555 {
00556     test_and_set_nparams(3);
00557     derivative_f = derivative_funcp(d);
00558     return *this;
00559 }
00560 function_options & function_options::derivative_func(derivative_funcp_4 d)
00561 {
00562     test_and_set_nparams(4);
00563     derivative_f = derivative_funcp(d);
00564     return *this;
00565 }
00566 function_options & function_options::derivative_func(derivative_funcp_5 d)
00567 {
00568     test_and_set_nparams(5);
00569     derivative_f = derivative_funcp(d);
00570     return *this;
00571 }
00572 function_options & function_options::derivative_func(derivative_funcp_6 d)
00573 {
00574     test_and_set_nparams(6);
00575     derivative_f = derivative_funcp(d);
00576     return *this;
00577 }
00578 function_options & function_options::derivative_func(derivative_funcp_7 d)
00579 {
00580     test_and_set_nparams(7);
00581     derivative_f = derivative_funcp(d);
00582     return *this;
00583 }
00584 function_options & function_options::derivative_func(derivative_funcp_8 d)
00585 {
00586     test_and_set_nparams(8);
00587     derivative_f = derivative_funcp(d);
00588     return *this;
00589 }
00590 function_options & function_options::derivative_func(derivative_funcp_9 d)
00591 {
00592     test_and_set_nparams(9);
00593     derivative_f = derivative_funcp(d);
00594     return *this;
00595 }
00596 function_options & function_options::derivative_func(derivative_funcp_10 d)
00597 {
00598     test_and_set_nparams(10);
00599     derivative_f = derivative_funcp(d);
00600     return *this;
00601 }
00602 function_options & function_options::derivative_func(derivative_funcp_11 d)
00603 {
00604     test_and_set_nparams(11);
00605     derivative_f = derivative_funcp(d);
00606     return *this;
00607 }
00608 function_options & function_options::derivative_func(derivative_funcp_12 d)
00609 {
00610     test_and_set_nparams(12);
00611     derivative_f = derivative_funcp(d);
00612     return *this;
00613 }
00614 function_options & function_options::derivative_func(derivative_funcp_13 d)
00615 {
00616     test_and_set_nparams(13);
00617     derivative_f = derivative_funcp(d);
00618     return *this;
00619 }
00620 function_options & function_options::derivative_func(derivative_funcp_14 d)
00621 {
00622     test_and_set_nparams(14);
00623     derivative_f = derivative_funcp(d);
00624     return *this;
00625 }
00626 
00627 function_options & function_options::power_func(power_funcp_1 d)
00628 {
00629     test_and_set_nparams(1);
00630     power_f = power_funcp(d);
00631     return *this;
00632 }
00633 function_options & function_options::power_func(power_funcp_2 d)
00634 {
00635     test_and_set_nparams(2);
00636     power_f = power_funcp(d);
00637     return *this;
00638 }
00639 function_options & function_options::power_func(power_funcp_3 d)
00640 {
00641     test_and_set_nparams(3);
00642     power_f = power_funcp(d);
00643     return *this;
00644 }
00645 function_options & function_options::power_func(power_funcp_4 d)
00646 {
00647     test_and_set_nparams(4);
00648     power_f = power_funcp(d);
00649     return *this;
00650 }
00651 function_options & function_options::power_func(power_funcp_5 d)
00652 {
00653     test_and_set_nparams(5);
00654     power_f = power_funcp(d);
00655     return *this;
00656 }
00657 function_options & function_options::power_func(power_funcp_6 d)
00658 {
00659     test_and_set_nparams(6);
00660     power_f = power_funcp(d);
00661     return *this;
00662 }
00663 function_options & function_options::power_func(power_funcp_7 d)
00664 {
00665     test_and_set_nparams(7);
00666     power_f = power_funcp(d);
00667     return *this;
00668 }
00669 function_options & function_options::power_func(power_funcp_8 d)
00670 {
00671     test_and_set_nparams(8);
00672     power_f = power_funcp(d);
00673     return *this;
00674 }
00675 function_options & function_options::power_func(power_funcp_9 d)
00676 {
00677     test_and_set_nparams(9);
00678     power_f = power_funcp(d);
00679     return *this;
00680 }
00681 function_options & function_options::power_func(power_funcp_10 d)
00682 {
00683     test_and_set_nparams(10);
00684     power_f = power_funcp(d);
00685     return *this;
00686 }
00687 function_options & function_options::power_func(power_funcp_11 d)
00688 {
00689     test_and_set_nparams(11);
00690     power_f = power_funcp(d);
00691     return *this;
00692 }
00693 function_options & function_options::power_func(power_funcp_12 d)
00694 {
00695     test_and_set_nparams(12);
00696     power_f = power_funcp(d);
00697     return *this;
00698 }
00699 function_options & function_options::power_func(power_funcp_13 d)
00700 {
00701     test_and_set_nparams(13);
00702     power_f = power_funcp(d);
00703     return *this;
00704 }
00705 function_options & function_options::power_func(power_funcp_14 d)
00706 {
00707     test_and_set_nparams(14);
00708     power_f = power_funcp(d);
00709     return *this;
00710 }
00711 
00712 function_options & function_options::series_func(series_funcp_1 s)
00713 {
00714     test_and_set_nparams(1);
00715     series_f = series_funcp(s);
00716     return *this;
00717 }
00718 function_options & function_options::series_func(series_funcp_2 s)
00719 {
00720     test_and_set_nparams(2);
00721     series_f = series_funcp(s);
00722     return *this;
00723 }
00724 function_options & function_options::series_func(series_funcp_3 s)
00725 {
00726     test_and_set_nparams(3);
00727     series_f = series_funcp(s);
00728     return *this;
00729 }
00730 function_options & function_options::series_func(series_funcp_4 s)
00731 {
00732     test_and_set_nparams(4);
00733     series_f = series_funcp(s);
00734     return *this;
00735 }
00736 function_options & function_options::series_func(series_funcp_5 s)
00737 {
00738     test_and_set_nparams(5);
00739     series_f = series_funcp(s);
00740     return *this;
00741 }
00742 function_options & function_options::series_func(series_funcp_6 s)
00743 {
00744     test_and_set_nparams(6);
00745     series_f = series_funcp(s);
00746     return *this;
00747 }
00748 function_options & function_options::series_func(series_funcp_7 s)
00749 {
00750     test_and_set_nparams(7);
00751     series_f = series_funcp(s);
00752     return *this;
00753 }
00754 function_options & function_options::series_func(series_funcp_8 s)
00755 {
00756     test_and_set_nparams(8);
00757     series_f = series_funcp(s);
00758     return *this;
00759 }
00760 function_options & function_options::series_func(series_funcp_9 s)
00761 {
00762     test_and_set_nparams(9);
00763     series_f = series_funcp(s);
00764     return *this;
00765 }
00766 function_options & function_options::series_func(series_funcp_10 s)
00767 {
00768     test_and_set_nparams(10);
00769     series_f = series_funcp(s);
00770     return *this;
00771 }
00772 function_options & function_options::series_func(series_funcp_11 s)
00773 {
00774     test_and_set_nparams(11);
00775     series_f = series_funcp(s);
00776     return *this;
00777 }
00778 function_options & function_options::series_func(series_funcp_12 s)
00779 {
00780     test_and_set_nparams(12);
00781     series_f = series_funcp(s);
00782     return *this;
00783 }
00784 function_options & function_options::series_func(series_funcp_13 s)
00785 {
00786     test_and_set_nparams(13);
00787     series_f = series_funcp(s);
00788     return *this;
00789 }
00790 function_options & function_options::series_func(series_funcp_14 s)
00791 {
00792     test_and_set_nparams(14);
00793     series_f = series_funcp(s);
00794     return *this;
00795 }
00796 
00797 // end of generated lines
00798 
00799 function_options& function_options::eval_func(eval_funcp_exvector e)
00800 {
00801     eval_use_exvector_args = true;
00802     eval_f = eval_funcp(e);
00803     return *this;
00804 }
00805 function_options& function_options::evalf_func(evalf_funcp_exvector ef)
00806 {
00807     evalf_use_exvector_args = true;
00808     evalf_f = evalf_funcp(ef);
00809     return *this;
00810 }
00811 function_options& function_options::conjugate_func(conjugate_funcp_exvector c)
00812 {
00813     conjugate_use_exvector_args = true;
00814     conjugate_f = conjugate_funcp(c);
00815     return *this;
00816 }
00817 function_options& function_options::real_part_func(real_part_funcp_exvector c)
00818 {
00819     real_part_use_exvector_args = true;
00820     real_part_f = real_part_funcp(c);
00821     return *this;
00822 }
00823 function_options& function_options::imag_part_func(imag_part_funcp_exvector c)
00824 {
00825     imag_part_use_exvector_args = true;
00826     imag_part_f = imag_part_funcp(c);
00827     return *this;
00828 }
00829 
00830 function_options& function_options::derivative_func(derivative_funcp_exvector d)
00831 {
00832     derivative_use_exvector_args = true;
00833     derivative_f = derivative_funcp(d);
00834     return *this;
00835 }
00836 function_options& function_options::power_func(power_funcp_exvector d)
00837 {
00838     power_use_exvector_args = true;
00839     power_f = power_funcp(d);
00840     return *this;
00841 }
00842 function_options& function_options::series_func(series_funcp_exvector s)
00843 {
00844     series_use_exvector_args = true;
00845     series_f = series_funcp(s);
00846     return *this;
00847 }
00848 
00849 function_options & function_options::set_return_type(unsigned rt, const return_type_t* rtt)
00850 {
00851     use_return_type = true;
00852     return_type = rt;
00853     if (rtt != 0)
00854         return_type_tinfo = *rtt;
00855     else
00856         return_type_tinfo = make_return_type_t<function>();
00857     return *this;
00858 }
00859 
00860 function_options & function_options::do_not_evalf_params()
00861 {
00862     evalf_params_first = false;
00863     return *this;
00864 }
00865 
00866 function_options & function_options::remember(unsigned size,
00867                                               unsigned assoc_size,
00868                                               unsigned strategy)
00869 {
00870     use_remember = true;
00871     remember_size = size;
00872     remember_assoc_size = assoc_size;
00873     remember_strategy = strategy;
00874     return *this;
00875 }
00876 
00877 function_options & function_options::overloaded(unsigned o)
00878 {
00879     functions_with_same_name = o;
00880     return *this;
00881 }
00882 
00883 function_options & function_options::set_symmetry(const symmetry & s)
00884 {
00885     symtree = s;
00886     return *this;
00887 }
00888     
00889 void function_options::test_and_set_nparams(unsigned n)
00890 {
00891     if (nparams==0) {
00892         nparams = n;
00893     } else if (nparams!=n) {
00894         // we do not throw an exception here because this code is
00895         // usually executed before main(), so the exception could not
00896         // be caught anyhow
00897         std::cerr << "WARNING: " << name << "(): number of parameters ("
00898                   << n << ") differs from number set before (" 
00899                   << nparams << ")" << std::endl;
00900     }
00901 }
00902 
00903 void function_options::set_print_func(unsigned id, print_funcp f)
00904 {
00905     if (id >= print_dispatch_table.size())
00906         print_dispatch_table.resize(id + 1);
00907     print_dispatch_table[id] = f;
00908 }
00909 
00911 unsigned function::current_serial = 0;
00912 
00913 
00914 GINAC_IMPLEMENT_REGISTERED_CLASS(function, exprseq)
00915 
00916 
00917 // default constructor
00919 
00920 // public
00921 
00922 function::function() : serial(0)
00923 {
00924 }
00925 
00927 // other constructors
00929 
00930 // public
00931 
00932 function::function(unsigned ser) : serial(ser)
00933 {
00934 }
00935 
00936 // the following lines have been generated for max. 14 parameters
00937 function::function(unsigned ser, const ex & param1)
00938     : exprseq(param1), serial(ser)
00939 {
00940 }
00941 function::function(unsigned ser, const ex & param1, const ex & param2)
00942     : exprseq(param1, param2), serial(ser)
00943 {
00944 }
00945 function::function(unsigned ser, const ex & param1, const ex & param2, const ex & param3)
00946     : exprseq(param1, param2, param3), serial(ser)
00947 {
00948 }
00949 function::function(unsigned ser, const ex & param1, const ex & param2, const ex & param3, const ex & param4)
00950     : exprseq(param1, param2, param3, param4), serial(ser)
00951 {
00952 }
00953 function::function(unsigned ser, const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5)
00954     : exprseq(param1, param2, param3, param4, param5), serial(ser)
00955 {
00956 }
00957 function::function(unsigned ser, const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6)
00958     : exprseq(param1, param2, param3, param4, param5, param6), serial(ser)
00959 {
00960 }
00961 function::function(unsigned ser, const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7)
00962     : exprseq(param1, param2, param3, param4, param5, param6, param7), serial(ser)
00963 {
00964 }
00965 function::function(unsigned ser, const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8)
00966     : exprseq(param1, param2, param3, param4, param5, param6, param7, param8), serial(ser)
00967 {
00968 }
00969 function::function(unsigned ser, const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9)
00970     : exprseq(param1, param2, param3, param4, param5, param6, param7, param8, param9), serial(ser)
00971 {
00972 }
00973 function::function(unsigned ser, const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9, const ex & param10)
00974     : exprseq(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10), serial(ser)
00975 {
00976 }
00977 function::function(unsigned ser, const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9, const ex & param10, const ex & param11)
00978     : exprseq(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11), serial(ser)
00979 {
00980 }
00981 function::function(unsigned ser, const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9, const ex & param10, const ex & param11, const ex & param12)
00982     : exprseq(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12), serial(ser)
00983 {
00984 }
00985 function::function(unsigned ser, const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9, const ex & param10, const ex & param11, const ex & param12, const ex & param13)
00986     : exprseq(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13), serial(ser)
00987 {
00988 }
00989 function::function(unsigned ser, const ex & param1, const ex & param2, const ex & param3, const ex & param4, const ex & param5, const ex & param6, const ex & param7, const ex & param8, const ex & param9, const ex & param10, const ex & param11, const ex & param12, const ex & param13, const ex & param14)
00990     : exprseq(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14), serial(ser)
00991 {
00992 }
00993 
00994 // end of generated lines
00995 
00996 function::function(unsigned ser, const exprseq & es) : exprseq(es), serial(ser)
00997 {
00998 
00999     // Force re-evaluation even if the exprseq was already evaluated
01000     // (the exprseq copy constructor copies the flags)
01001     clearflag(status_flags::evaluated);
01002 }
01003 
01004 function::function(unsigned ser, const exvector & v, bool discardable) 
01005   : exprseq(v,discardable), serial(ser)
01006 {
01007     if ( ser >= registered_functions().size() ) {
01008         throw std::runtime_error("function does not exist");
01009     }
01010 }
01011 
01012 function::function(unsigned ser, std::auto_ptr<exvector> vp) 
01013   : exprseq(vp), serial(ser)
01014 {
01015 }
01016 
01018 // archiving
01020 
01022 void function::read_archive(const archive_node& n, lst& sym_lst)
01023 {
01024     inherited::read_archive(n, sym_lst);
01025     // Find serial number by function name
01026     std::string s;
01027     if (n.find_string("name", s)) {
01028         unsigned int ser = 0;
01029         std::vector<function_options>::const_iterator i = registered_functions().begin(), iend = registered_functions().end();
01030         while (i != iend) {
01031             if (s == i->name) {
01032                 serial = ser;
01033                 return;
01034             }
01035             ++i; ++ser;
01036         }
01037         throw (std::runtime_error("unknown function '" + s + "' in archive"));
01038     } else
01039         throw (std::runtime_error("unnamed function in archive"));
01040 }
01041 
01043 void function::archive(archive_node &n) const
01044 {
01045     inherited::archive(n);
01046     GINAC_ASSERT(serial < registered_functions().size());
01047     n.add_string("name", registered_functions()[serial].name);
01048 }
01049 
01050 GINAC_BIND_UNARCHIVER(function);
01051 
01053 // functions overriding virtual functions from base classes
01055 
01056 // public
01057 
01058 void function::print(const print_context & c, unsigned level) const
01059 {
01060     GINAC_ASSERT(serial<registered_functions().size());
01061     const function_options &opt = registered_functions()[serial];
01062     const std::vector<print_funcp> &pdt = opt.print_dispatch_table;
01063 
01064     // Dynamically dispatch on print_context type
01065     const print_context_class_info *pc_info = &c.get_class_info();
01066 
01067 next_context:
01068     unsigned id = pc_info->options.get_id();
01069     if (id >= pdt.size() || pdt[id] == NULL) {
01070 
01071         // Method not found, try parent print_context class
01072         const print_context_class_info *parent_pc_info = pc_info->get_parent();
01073         if (parent_pc_info) {
01074             pc_info = parent_pc_info;
01075             goto next_context;
01076         }
01077 
01078         // Method still not found, use default output
01079         if (is_a<print_tree>(c)) {
01080 
01081             c.s << std::string(level, ' ') << class_name() << " "
01082                 << opt.name << " @" << this
01083                 << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
01084                 << ", nops=" << nops()
01085                 << std::endl;
01086             unsigned delta_indent = static_cast<const print_tree &>(c).delta_indent;
01087             for (size_t i=0; i<seq.size(); ++i)
01088                 seq[i].print(c, level + delta_indent);
01089             c.s << std::string(level + delta_indent, ' ') << "=====" << std::endl;
01090 
01091         } else if (is_a<print_csrc>(c)) {
01092 
01093             // Print function name in lowercase
01094             std::string lname = opt.name;
01095             size_t num = lname.size();
01096             for (size_t i=0; i<num; i++)
01097                 lname[i] = tolower(lname[i]);
01098             c.s << lname;
01099             printseq(c, '(', ',', ')', exprseq::precedence(), function::precedence());
01100 
01101         } else if (is_a<print_latex>(c)) {
01102             c.s << opt.TeX_name;
01103             printseq(c, '(', ',', ')', exprseq::precedence(), function::precedence());
01104         } else {
01105             c.s << opt.name;
01106             printseq(c, '(', ',', ')', exprseq::precedence(), function::precedence());
01107         }
01108 
01109     } else {
01110 
01111         // Method found, call it
01112         current_serial = serial;
01113         if (opt.print_use_exvector_args)
01114             ((print_funcp_exvector)pdt[id])(seq, c);
01115         else switch (opt.nparams) {
01116             // the following lines have been generated for max. 14 parameters
01117         case 1:
01118             ((print_funcp_1)(pdt[id]))(seq[1-1], c);
01119             break;
01120         case 2:
01121             ((print_funcp_2)(pdt[id]))(seq[1-1], seq[2-1], c);
01122             break;
01123         case 3:
01124             ((print_funcp_3)(pdt[id]))(seq[1-1], seq[2-1], seq[3-1], c);
01125             break;
01126         case 4:
01127             ((print_funcp_4)(pdt[id]))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], c);
01128             break;
01129         case 5:
01130             ((print_funcp_5)(pdt[id]))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], c);
01131             break;
01132         case 6:
01133             ((print_funcp_6)(pdt[id]))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], c);
01134             break;
01135         case 7:
01136             ((print_funcp_7)(pdt[id]))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], c);
01137             break;
01138         case 8:
01139             ((print_funcp_8)(pdt[id]))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], c);
01140             break;
01141         case 9:
01142             ((print_funcp_9)(pdt[id]))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], c);
01143             break;
01144         case 10:
01145             ((print_funcp_10)(pdt[id]))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], c);
01146             break;
01147         case 11:
01148             ((print_funcp_11)(pdt[id]))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], c);
01149             break;
01150         case 12:
01151             ((print_funcp_12)(pdt[id]))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], c);
01152             break;
01153         case 13:
01154             ((print_funcp_13)(pdt[id]))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1], c);
01155             break;
01156         case 14:
01157             ((print_funcp_14)(pdt[id]))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1], seq[14-1], c);
01158             break;
01159 
01160             // end of generated lines
01161         default:
01162             throw(std::logic_error("function::print(): invalid nparams"));
01163         }
01164     }
01165 }
01166 
01167 ex function::expand(unsigned options) const
01168 {
01169     // Only expand arguments when asked to do so
01170     if (options & expand_options::expand_function_args)
01171         return inherited::expand(options);
01172     else
01173         return (options == 0) ? setflag(status_flags::expanded) : *this;
01174 }
01175 
01176 ex function::eval(int level) const
01177 {
01178     if (level>1) {
01179         // first evaluate children, then we will end up here again
01180         return function(serial,evalchildren(level));
01181     }
01182 
01183     GINAC_ASSERT(serial<registered_functions().size());
01184     const function_options &opt = registered_functions()[serial];
01185 
01186     // Canonicalize argument order according to the symmetry properties
01187     if (seq.size() > 1 && !(opt.symtree.is_zero())) {
01188         exvector v = seq;
01189         GINAC_ASSERT(is_a<symmetry>(opt.symtree));
01190         int sig = canonicalize(v.begin(), ex_to<symmetry>(opt.symtree));
01191         if (sig != std::numeric_limits<int>::max()) {
01192             // Something has changed while sorting arguments, more evaluations later
01193             if (sig == 0)
01194                 return _ex0;
01195             return ex(sig) * thiscontainer(v);
01196         }
01197     }
01198 
01199     if (opt.eval_f==0) {
01200         return this->hold();
01201     }
01202 
01203     bool use_remember = opt.use_remember;
01204     ex eval_result;
01205     if (use_remember && lookup_remember_table(eval_result)) {
01206         return eval_result;
01207     }
01208     current_serial = serial;
01209     if (opt.eval_use_exvector_args)
01210         eval_result = ((eval_funcp_exvector)(opt.eval_f))(seq);
01211     else
01212     switch (opt.nparams) {
01213         // the following lines have been generated for max. 14 parameters
01214     case 1:
01215         eval_result = ((eval_funcp_1)(opt.eval_f))(seq[1-1]);
01216         break;
01217     case 2:
01218         eval_result = ((eval_funcp_2)(opt.eval_f))(seq[1-1], seq[2-1]);
01219         break;
01220     case 3:
01221         eval_result = ((eval_funcp_3)(opt.eval_f))(seq[1-1], seq[2-1], seq[3-1]);
01222         break;
01223     case 4:
01224         eval_result = ((eval_funcp_4)(opt.eval_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1]);
01225         break;
01226     case 5:
01227         eval_result = ((eval_funcp_5)(opt.eval_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1]);
01228         break;
01229     case 6:
01230         eval_result = ((eval_funcp_6)(opt.eval_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1]);
01231         break;
01232     case 7:
01233         eval_result = ((eval_funcp_7)(opt.eval_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1]);
01234         break;
01235     case 8:
01236         eval_result = ((eval_funcp_8)(opt.eval_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1]);
01237         break;
01238     case 9:
01239         eval_result = ((eval_funcp_9)(opt.eval_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1]);
01240         break;
01241     case 10:
01242         eval_result = ((eval_funcp_10)(opt.eval_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1]);
01243         break;
01244     case 11:
01245         eval_result = ((eval_funcp_11)(opt.eval_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1]);
01246         break;
01247     case 12:
01248         eval_result = ((eval_funcp_12)(opt.eval_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1]);
01249         break;
01250     case 13:
01251         eval_result = ((eval_funcp_13)(opt.eval_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1]);
01252         break;
01253     case 14:
01254         eval_result = ((eval_funcp_14)(opt.eval_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1], seq[14-1]);
01255         break;
01256 
01257         // end of generated lines
01258     default:
01259         throw(std::logic_error("function::eval(): invalid nparams"));
01260     }
01261     if (use_remember) {
01262         store_remember_table(eval_result);
01263     }
01264     return eval_result;
01265 }
01266 
01267 ex function::evalf(int level) const
01268 {
01269     GINAC_ASSERT(serial<registered_functions().size());
01270     const function_options &opt = registered_functions()[serial];
01271 
01272     // Evaluate children first
01273     exvector eseq;
01274     if (level == 1 || !(opt.evalf_params_first))
01275         eseq = seq;
01276     else if (level == -max_recursion_level)
01277         throw(std::runtime_error("max recursion level reached"));
01278     else {
01279         eseq.reserve(seq.size());
01280         --level;
01281         exvector::const_iterator it = seq.begin(), itend = seq.end();
01282         while (it != itend) {
01283             eseq.push_back(it->evalf(level));
01284             ++it;
01285         }
01286     }
01287 
01288     if (opt.evalf_f==0) {
01289         return function(serial,eseq).hold();
01290     }
01291     current_serial = serial;
01292     if (opt.evalf_use_exvector_args)
01293         return ((evalf_funcp_exvector)(opt.evalf_f))(seq);
01294     switch (opt.nparams) {
01295         // the following lines have been generated for max. 14 parameters
01296     case 1:
01297         return ((evalf_funcp_1)(opt.evalf_f))(eseq[1-1]);
01298     case 2:
01299         return ((evalf_funcp_2)(opt.evalf_f))(eseq[1-1], eseq[2-1]);
01300     case 3:
01301         return ((evalf_funcp_3)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1]);
01302     case 4:
01303         return ((evalf_funcp_4)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1], eseq[4-1]);
01304     case 5:
01305         return ((evalf_funcp_5)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1], eseq[4-1], eseq[5-1]);
01306     case 6:
01307         return ((evalf_funcp_6)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1], eseq[4-1], eseq[5-1], eseq[6-1]);
01308     case 7:
01309         return ((evalf_funcp_7)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1], eseq[4-1], eseq[5-1], eseq[6-1], eseq[7-1]);
01310     case 8:
01311         return ((evalf_funcp_8)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1], eseq[4-1], eseq[5-1], eseq[6-1], eseq[7-1], eseq[8-1]);
01312     case 9:
01313         return ((evalf_funcp_9)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1], eseq[4-1], eseq[5-1], eseq[6-1], eseq[7-1], eseq[8-1], eseq[9-1]);
01314     case 10:
01315         return ((evalf_funcp_10)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1], eseq[4-1], eseq[5-1], eseq[6-1], eseq[7-1], eseq[8-1], eseq[9-1], eseq[10-1]);
01316     case 11:
01317         return ((evalf_funcp_11)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1], eseq[4-1], eseq[5-1], eseq[6-1], eseq[7-1], eseq[8-1], eseq[9-1], eseq[10-1], eseq[11-1]);
01318     case 12:
01319         return ((evalf_funcp_12)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1], eseq[4-1], eseq[5-1], eseq[6-1], eseq[7-1], eseq[8-1], eseq[9-1], eseq[10-1], eseq[11-1], eseq[12-1]);
01320     case 13:
01321         return ((evalf_funcp_13)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1], eseq[4-1], eseq[5-1], eseq[6-1], eseq[7-1], eseq[8-1], eseq[9-1], eseq[10-1], eseq[11-1], eseq[12-1], eseq[13-1]);
01322     case 14:
01323         return ((evalf_funcp_14)(opt.evalf_f))(eseq[1-1], eseq[2-1], eseq[3-1], eseq[4-1], eseq[5-1], eseq[6-1], eseq[7-1], eseq[8-1], eseq[9-1], eseq[10-1], eseq[11-1], eseq[12-1], eseq[13-1], eseq[14-1]);
01324 
01325         // end of generated lines
01326     }
01327     throw(std::logic_error("function::evalf(): invalid nparams"));
01328 }
01329 
01333 ex function::eval_ncmul(const exvector & v) const
01334 {
01335     // If this function is called then the list of arguments is non-empty
01336     // and the first argument is non-commutative, see  function::return_type()
01337     return seq.begin()->eval_ncmul(v);
01338 }
01339 
01340 unsigned function::calchash() const
01341 {
01342     unsigned v = golden_ratio_hash(make_hash_seed(typeid(*this)) ^ serial);
01343     for (size_t i=0; i<nops(); i++) {
01344         v = rotate_left(v);
01345         v ^= this->op(i).gethash();
01346     }
01347 
01348     if (flags & status_flags::evaluated) {
01349         setflag(status_flags::hash_calculated);
01350         hashvalue = v;
01351     }
01352     return v;
01353 }
01354 
01355 ex function::thiscontainer(const exvector & v) const
01356 {
01357     return function(serial, v);
01358 }
01359 
01360 ex function::thiscontainer(std::auto_ptr<exvector> vp) const
01361 {
01362     return function(serial, vp);
01363 }
01364 
01367 ex function::series(const relational & r, int order, unsigned options) const
01368 {
01369     GINAC_ASSERT(serial<registered_functions().size());
01370     const function_options &opt = registered_functions()[serial];
01371 
01372     if (opt.series_f==0) {
01373         return basic::series(r, order);
01374     }
01375     ex res;
01376     current_serial = serial;
01377     if (opt.series_use_exvector_args) {
01378         try {
01379             res = ((series_funcp_exvector)(opt.series_f))(seq, r, order, options);
01380         } catch (do_taylor) {
01381             res = basic::series(r, order, options);
01382         }
01383         return res;
01384     }
01385     switch (opt.nparams) {
01386         // the following lines have been generated for max. 14 parameters
01387     case 1:
01388         try {
01389             res = ((series_funcp_1)(opt.series_f))(seq[1-1],r,order,options);
01390         } catch (do_taylor) {
01391             res = basic::series(r, order, options);
01392         }
01393         return res;
01394     case 2:
01395         try {
01396             res = ((series_funcp_2)(opt.series_f))(seq[1-1], seq[2-1],r,order,options);
01397         } catch (do_taylor) {
01398             res = basic::series(r, order, options);
01399         }
01400         return res;
01401     case 3:
01402         try {
01403             res = ((series_funcp_3)(opt.series_f))(seq[1-1], seq[2-1], seq[3-1],r,order,options);
01404         } catch (do_taylor) {
01405             res = basic::series(r, order, options);
01406         }
01407         return res;
01408     case 4:
01409         try {
01410             res = ((series_funcp_4)(opt.series_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1],r,order,options);
01411         } catch (do_taylor) {
01412             res = basic::series(r, order, options);
01413         }
01414         return res;
01415     case 5:
01416         try {
01417             res = ((series_funcp_5)(opt.series_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1],r,order,options);
01418         } catch (do_taylor) {
01419             res = basic::series(r, order, options);
01420         }
01421         return res;
01422     case 6:
01423         try {
01424             res = ((series_funcp_6)(opt.series_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1],r,order,options);
01425         } catch (do_taylor) {
01426             res = basic::series(r, order, options);
01427         }
01428         return res;
01429     case 7:
01430         try {
01431             res = ((series_funcp_7)(opt.series_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1],r,order,options);
01432         } catch (do_taylor) {
01433             res = basic::series(r, order, options);
01434         }
01435         return res;
01436     case 8:
01437         try {
01438             res = ((series_funcp_8)(opt.series_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1],r,order,options);
01439         } catch (do_taylor) {
01440             res = basic::series(r, order, options);
01441         }
01442         return res;
01443     case 9:
01444         try {
01445             res = ((series_funcp_9)(opt.series_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1],r,order,options);
01446         } catch (do_taylor) {
01447             res = basic::series(r, order, options);
01448         }
01449         return res;
01450     case 10:
01451         try {
01452             res = ((series_funcp_10)(opt.series_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1],r,order,options);
01453         } catch (do_taylor) {
01454             res = basic::series(r, order, options);
01455         }
01456         return res;
01457     case 11:
01458         try {
01459             res = ((series_funcp_11)(opt.series_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1],r,order,options);
01460         } catch (do_taylor) {
01461             res = basic::series(r, order, options);
01462         }
01463         return res;
01464     case 12:
01465         try {
01466             res = ((series_funcp_12)(opt.series_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1],r,order,options);
01467         } catch (do_taylor) {
01468             res = basic::series(r, order, options);
01469         }
01470         return res;
01471     case 13:
01472         try {
01473             res = ((series_funcp_13)(opt.series_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1],r,order,options);
01474         } catch (do_taylor) {
01475             res = basic::series(r, order, options);
01476         }
01477         return res;
01478     case 14:
01479         try {
01480             res = ((series_funcp_14)(opt.series_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1], seq[14-1],r,order,options);
01481         } catch (do_taylor) {
01482             res = basic::series(r, order, options);
01483         }
01484         return res;
01485 
01486         // end of generated lines
01487     }
01488     throw(std::logic_error("function::series(): invalid nparams"));
01489 }
01490 
01492 ex function::conjugate() const
01493 {
01494     GINAC_ASSERT(serial<registered_functions().size());
01495     const function_options & opt = registered_functions()[serial];
01496 
01497     if (opt.conjugate_f==0) {
01498         return conjugate_function(*this).hold();
01499     }
01500 
01501     if (opt.conjugate_use_exvector_args) {
01502         return ((conjugate_funcp_exvector)(opt.conjugate_f))(seq);
01503     }
01504 
01505     switch (opt.nparams) {
01506         // the following lines have been generated for max. 14 parameters
01507     case 1:
01508         return ((conjugate_funcp_1)(opt.conjugate_f))(seq[1-1]);
01509     case 2:
01510         return ((conjugate_funcp_2)(opt.conjugate_f))(seq[1-1], seq[2-1]);
01511     case 3:
01512         return ((conjugate_funcp_3)(opt.conjugate_f))(seq[1-1], seq[2-1], seq[3-1]);
01513     case 4:
01514         return ((conjugate_funcp_4)(opt.conjugate_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1]);
01515     case 5:
01516         return ((conjugate_funcp_5)(opt.conjugate_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1]);
01517     case 6:
01518         return ((conjugate_funcp_6)(opt.conjugate_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1]);
01519     case 7:
01520         return ((conjugate_funcp_7)(opt.conjugate_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1]);
01521     case 8:
01522         return ((conjugate_funcp_8)(opt.conjugate_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1]);
01523     case 9:
01524         return ((conjugate_funcp_9)(opt.conjugate_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1]);
01525     case 10:
01526         return ((conjugate_funcp_10)(opt.conjugate_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1]);
01527     case 11:
01528         return ((conjugate_funcp_11)(opt.conjugate_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1]);
01529     case 12:
01530         return ((conjugate_funcp_12)(opt.conjugate_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1]);
01531     case 13:
01532         return ((conjugate_funcp_13)(opt.conjugate_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1]);
01533     case 14:
01534         return ((conjugate_funcp_14)(opt.conjugate_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1], seq[14-1]);
01535 
01536         // end of generated lines
01537     }
01538     throw(std::logic_error("function::conjugate(): invalid nparams"));
01539 }
01540 
01542 ex function::real_part() const
01543 {
01544     GINAC_ASSERT(serial<registered_functions().size());
01545     const function_options & opt = registered_functions()[serial];
01546 
01547     if (opt.real_part_f==0)
01548         return basic::real_part();
01549 
01550     if (opt.real_part_use_exvector_args)
01551         return ((real_part_funcp_exvector)(opt.real_part_f))(seq);
01552 
01553     switch (opt.nparams) {
01554         // the following lines have been generated for max. 14 parameters
01555     case 1:
01556         return ((real_part_funcp_1)(opt.real_part_f))(seq[1-1]);
01557     case 2:
01558         return ((real_part_funcp_2)(opt.real_part_f))(seq[1-1], seq[2-1]);
01559     case 3:
01560         return ((real_part_funcp_3)(opt.real_part_f))(seq[1-1], seq[2-1], seq[3-1]);
01561     case 4:
01562         return ((real_part_funcp_4)(opt.real_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1]);
01563     case 5:
01564         return ((real_part_funcp_5)(opt.real_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1]);
01565     case 6:
01566         return ((real_part_funcp_6)(opt.real_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1]);
01567     case 7:
01568         return ((real_part_funcp_7)(opt.real_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1]);
01569     case 8:
01570         return ((real_part_funcp_8)(opt.real_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1]);
01571     case 9:
01572         return ((real_part_funcp_9)(opt.real_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1]);
01573     case 10:
01574         return ((real_part_funcp_10)(opt.real_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1]);
01575     case 11:
01576         return ((real_part_funcp_11)(opt.real_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1]);
01577     case 12:
01578         return ((real_part_funcp_12)(opt.real_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1]);
01579     case 13:
01580         return ((real_part_funcp_13)(opt.real_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1]);
01581     case 14:
01582         return ((real_part_funcp_14)(opt.real_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1], seq[14-1]);
01583 
01584         // end of generated lines
01585     }
01586     throw(std::logic_error("function::real_part(): invalid nparams"));
01587 }
01588 
01590 ex function::imag_part() const
01591 {
01592     GINAC_ASSERT(serial<registered_functions().size());
01593     const function_options & opt = registered_functions()[serial];
01594 
01595     if (opt.imag_part_f==0)
01596         return basic::imag_part();
01597 
01598     if (opt.imag_part_use_exvector_args)
01599         return ((imag_part_funcp_exvector)(opt.imag_part_f))(seq);
01600 
01601     switch (opt.nparams) {
01602         // the following lines have been generated for max. 14 parameters
01603     case 1:
01604         return ((imag_part_funcp_1)(opt.imag_part_f))(seq[1-1]);
01605     case 2:
01606         return ((imag_part_funcp_2)(opt.imag_part_f))(seq[1-1], seq[2-1]);
01607     case 3:
01608         return ((imag_part_funcp_3)(opt.imag_part_f))(seq[1-1], seq[2-1], seq[3-1]);
01609     case 4:
01610         return ((imag_part_funcp_4)(opt.imag_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1]);
01611     case 5:
01612         return ((imag_part_funcp_5)(opt.imag_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1]);
01613     case 6:
01614         return ((imag_part_funcp_6)(opt.imag_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1]);
01615     case 7:
01616         return ((imag_part_funcp_7)(opt.imag_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1]);
01617     case 8:
01618         return ((imag_part_funcp_8)(opt.imag_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1]);
01619     case 9:
01620         return ((imag_part_funcp_9)(opt.imag_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1]);
01621     case 10:
01622         return ((imag_part_funcp_10)(opt.imag_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1]);
01623     case 11:
01624         return ((imag_part_funcp_11)(opt.imag_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1]);
01625     case 12:
01626         return ((imag_part_funcp_12)(opt.imag_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1]);
01627     case 13:
01628         return ((imag_part_funcp_13)(opt.imag_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1]);
01629     case 14:
01630         return ((imag_part_funcp_14)(opt.imag_part_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1], seq[14-1]);
01631 
01632         // end of generated lines
01633     }
01634     throw(std::logic_error("function::imag_part(): invalid nparams"));
01635 }
01636 
01637 // protected
01638 
01642 ex function::derivative(const symbol & s) const
01643 {
01644     ex result;
01645 
01646     if (serial == Order_SERIAL::serial) {
01647         // Order Term function only differentiates the argument
01648         return Order(seq[0].diff(s));
01649     } else {
01650         // Chain rule
01651         ex arg_diff;
01652         size_t num = seq.size();
01653         for (size_t i=0; i<num; i++) {
01654             arg_diff = seq[i].diff(s);
01655             // We apply the chain rule only when it makes sense.  This is not
01656             // just for performance reasons but also to allow functions to
01657             // throw when differentiated with respect to one of its arguments
01658             // without running into trouble with our automatic full
01659             // differentiation:
01660             if (!arg_diff.is_zero())
01661                 result += pderivative(i)*arg_diff;
01662         }
01663     }
01664     return result;
01665 }
01666 
01667 int function::compare_same_type(const basic & other) const
01668 {
01669     GINAC_ASSERT(is_a<function>(other));
01670     const function & o = static_cast<const function &>(other);
01671 
01672     if (serial != o.serial)
01673         return serial < o.serial ? -1 : 1;
01674     else
01675         return exprseq::compare_same_type(o);
01676 }
01677 
01678 bool function::is_equal_same_type(const basic & other) const
01679 {
01680     GINAC_ASSERT(is_a<function>(other));
01681     const function & o = static_cast<const function &>(other);
01682 
01683     if (serial != o.serial)
01684         return false;
01685     else
01686         return exprseq::is_equal_same_type(o);
01687 }
01688 
01689 bool function::match_same_type(const basic & other) const
01690 {
01691     GINAC_ASSERT(is_a<function>(other));
01692     const function & o = static_cast<const function &>(other);
01693 
01694     return serial == o.serial;
01695 }
01696 
01697 unsigned function::return_type() const
01698 {
01699     GINAC_ASSERT(serial<registered_functions().size());
01700     const function_options &opt = registered_functions()[serial];
01701 
01702     if (opt.use_return_type) {
01703         // Return type was explicitly specified
01704         return opt.return_type;
01705     } else {
01706         // Default behavior is to use the return type of the first
01707         // argument. Thus, exp() of a matrix behaves like a matrix, etc.
01708         if (seq.empty())
01709             return return_types::commutative;
01710         else
01711             return seq.begin()->return_type();
01712     }
01713 }
01714 
01715 return_type_t function::return_type_tinfo() const
01716 {
01717     GINAC_ASSERT(serial<registered_functions().size());
01718     const function_options &opt = registered_functions()[serial];
01719 
01720     if (opt.use_return_type) {
01721         // Return type was explicitly specified
01722         return opt.return_type_tinfo;
01723     } else {
01724         // Default behavior is to use the return type of the first
01725         // argument. Thus, exp() of a matrix behaves like a matrix, etc.
01726         if (seq.empty())
01727             return make_return_type_t<function>();
01728         else
01729             return seq.begin()->return_type_tinfo();
01730     }
01731 }
01732 
01734 // new virtual functions which can be overridden by derived classes
01736 
01737 // none
01738 
01740 // non-virtual functions in this class
01742 
01743 // protected
01744 
01745 ex function::pderivative(unsigned diff_param) const // partial differentiation
01746 {
01747     GINAC_ASSERT(serial<registered_functions().size());
01748     const function_options &opt = registered_functions()[serial];
01749     
01750     // No derivative defined? Then return abstract derivative object
01751     if (opt.derivative_f == NULL)
01752         return fderivative(serial, diff_param, seq);
01753 
01754     current_serial = serial;
01755     if (opt.derivative_use_exvector_args)
01756         return ((derivative_funcp_exvector)(opt.derivative_f))(seq, diff_param);
01757     switch (opt.nparams) {
01758         // the following lines have been generated for max. 14 parameters
01759     case 1:
01760         return ((derivative_funcp_1)(opt.derivative_f))(seq[1-1],diff_param);
01761     case 2:
01762         return ((derivative_funcp_2)(opt.derivative_f))(seq[1-1], seq[2-1],diff_param);
01763     case 3:
01764         return ((derivative_funcp_3)(opt.derivative_f))(seq[1-1], seq[2-1], seq[3-1],diff_param);
01765     case 4:
01766         return ((derivative_funcp_4)(opt.derivative_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1],diff_param);
01767     case 5:
01768         return ((derivative_funcp_5)(opt.derivative_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1],diff_param);
01769     case 6:
01770         return ((derivative_funcp_6)(opt.derivative_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1],diff_param);
01771     case 7:
01772         return ((derivative_funcp_7)(opt.derivative_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1],diff_param);
01773     case 8:
01774         return ((derivative_funcp_8)(opt.derivative_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1],diff_param);
01775     case 9:
01776         return ((derivative_funcp_9)(opt.derivative_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1],diff_param);
01777     case 10:
01778         return ((derivative_funcp_10)(opt.derivative_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1],diff_param);
01779     case 11:
01780         return ((derivative_funcp_11)(opt.derivative_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1],diff_param);
01781     case 12:
01782         return ((derivative_funcp_12)(opt.derivative_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1],diff_param);
01783     case 13:
01784         return ((derivative_funcp_13)(opt.derivative_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1],diff_param);
01785     case 14:
01786         return ((derivative_funcp_14)(opt.derivative_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1], seq[14-1],diff_param);
01787 
01788         // end of generated lines
01789     }
01790     throw(std::logic_error("function::pderivative(): no diff function defined"));
01791 }
01792 
01793 ex function::power(const ex & power_param) const // power of function
01794 {
01795     GINAC_ASSERT(serial<registered_functions().size());
01796     const function_options &opt = registered_functions()[serial];
01797     
01798     // No derivative defined? Then return abstract derivative object
01799     if (opt.power_f == NULL)
01800         return (new GiNaC::power(*this, power_param))->setflag(status_flags::dynallocated |
01801                                                                status_flags::evaluated);
01802 
01803     current_serial = serial;
01804     if (opt.power_use_exvector_args)
01805         return ((power_funcp_exvector)(opt.power_f))(seq,  power_param);
01806     switch (opt.nparams) {
01807         // the following lines have been generated for max. 14 parameters
01808     case 1:
01809         return ((power_funcp_1)(opt.power_f))(seq[1-1],power_param);
01810     case 2:
01811         return ((power_funcp_2)(opt.power_f))(seq[1-1], seq[2-1],power_param);
01812     case 3:
01813         return ((power_funcp_3)(opt.power_f))(seq[1-1], seq[2-1], seq[3-1],power_param);
01814     case 4:
01815         return ((power_funcp_4)(opt.power_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1],power_param);
01816     case 5:
01817         return ((power_funcp_5)(opt.power_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1],power_param);
01818     case 6:
01819         return ((power_funcp_6)(opt.power_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1],power_param);
01820     case 7:
01821         return ((power_funcp_7)(opt.power_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1],power_param);
01822     case 8:
01823         return ((power_funcp_8)(opt.power_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1],power_param);
01824     case 9:
01825         return ((power_funcp_9)(opt.power_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1],power_param);
01826     case 10:
01827         return ((power_funcp_10)(opt.power_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1],power_param);
01828     case 11:
01829         return ((power_funcp_11)(opt.power_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1],power_param);
01830     case 12:
01831         return ((power_funcp_12)(opt.power_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1],power_param);
01832     case 13:
01833         return ((power_funcp_13)(opt.power_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1],power_param);
01834     case 14:
01835         return ((power_funcp_14)(opt.power_f))(seq[1-1], seq[2-1], seq[3-1], seq[4-1], seq[5-1], seq[6-1], seq[7-1], seq[8-1], seq[9-1], seq[10-1], seq[11-1], seq[12-1], seq[13-1], seq[14-1],power_param);
01836 
01837         // end of generated lines
01838     }
01839     throw(std::logic_error("function::power(): no power function defined"));
01840 }
01841 
01842 std::vector<function_options> & function::registered_functions()
01843 {
01844     static std::vector<function_options> rf = std::vector<function_options>();
01845     return rf;
01846 }
01847 
01848 bool function::lookup_remember_table(ex & result) const
01849 {
01850     return remember_table::remember_tables()[this->serial].lookup_entry(*this,result);
01851 }
01852 
01853 void function::store_remember_table(ex const & result) const
01854 {
01855     remember_table::remember_tables()[this->serial].add_entry(*this,result);
01856 }
01857 
01858 // public
01859 
01860 unsigned function::register_new(function_options const & opt)
01861 {
01862     size_t same_name = 0;
01863     for (size_t i=0; i<registered_functions().size(); ++i) {
01864         if (registered_functions()[i].name==opt.name) {
01865             ++same_name;
01866         }
01867     }
01868     if (same_name>=opt.functions_with_same_name) {
01869         // we do not throw an exception here because this code is
01870         // usually executed before main(), so the exception could not
01871         // caught anyhow
01872         std::cerr << "WARNING: function name " << opt.name
01873                   << " already in use!" << std::endl;
01874     }
01875     registered_functions().push_back(opt);
01876     if (opt.use_remember) {
01877         remember_table::remember_tables().
01878             push_back(remember_table(opt.remember_size,
01879                                      opt.remember_assoc_size,
01880                                      opt.remember_strategy));
01881     } else {
01882         remember_table::remember_tables().push_back(remember_table());
01883     }
01884     return registered_functions().size()-1;
01885 }
01886 
01889 unsigned function::find_function(const std::string &name, unsigned nparams)
01890 {
01891     std::vector<function_options>::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end();
01892     unsigned serial = 0;
01893     while (i != end) {
01894         if (i->get_name() == name && i->get_nparams() == nparams)
01895             return serial;
01896         ++i;
01897         ++serial;
01898     }
01899     throw (std::runtime_error("no function '" + name + "' with " + ToString(nparams) + " parameters defined"));
01900 }
01901 
01903 std::string function::get_name() const
01904 {
01905     if ( serial >= registered_functions().size() ) {
01906         throw std::runtime_error("unknown function");
01907     }
01908     return registered_functions()[serial].name;
01909 }
01910 
01911 } // namespace GiNaC
01912 

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.