X-Git-Url: https://ginac.de/ginac.git//ginac.git?a=blobdiff_plain;ds=sidebyside;f=ginac%2Ffunction.cppy;h=2737b934ffe754251740a7e36e884ebb0ce27153;hb=aed514f534cc6b4438822c1fcf80c203a828a94c;hp=d020d65fe54fbadfa4f4d62b6f83bd20d418bd5a;hpb=cd22e73d44e3320898f62a0accdbbe005b33d3e5;p=ginac.git diff --git a/ginac/function.cppy b/ginac/function.cppy index d020d65f..2737b934 100644 --- a/ginac/function.cppy +++ b/ginac/function.cppy @@ -7,7 +7,7 @@ * Please do not modify it directly, edit function.cppy instead! * function.py options: maxargs=@maxargs@ * - * GiNaC Copyright (C) 1999-2016 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2022 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 @@ -75,7 +75,7 @@ function_options::~function_options() void function_options::initialize() { - set_name("unnamed_function", "\\\\mbox{unnamed}"); + set_name("unnamed_function", "\\mbox{unnamed}"); nparams = 0; eval_f = evalf_f = real_part_f = imag_part_f = conjugate_f = expand_f = derivative_f = expl_derivative_f = power_f = series_f = nullptr; @@ -104,7 +104,7 @@ function_options & function_options::set_name(std::string const & n, { name = n; if (tn==std::string()) - TeX_name = "\\\\mbox{"+name+"}"; + TeX_name = "\\mbox{"+name+"}"; else TeX_name = tn; return *this; @@ -259,18 +259,20 @@ function::function(unsigned ser, exvector && v) void function::read_archive(const archive_node& n, lst& sym_lst) { inherited::read_archive(n, sym_lst); - // Find serial number by function name + // Find serial number by function name and number of parameters + unsigned np = seq.size(); std::string s; if (n.find_string("name", s)) { unsigned int ser = 0; for (auto & it : registered_functions()) { - if (s == it.name) { + if (s == it.name && np == registered_functions()[ser].nparams) { serial = ser; return; } ++ser; } - throw (std::runtime_error("unknown function '" + s + "' in archive")); + throw (std::runtime_error("unknown function '" + s + + "' with " + std::to_string(np) + " parameters in archive")); } else throw (std::runtime_error("unnamed function in archive")); } @@ -435,7 +437,7 @@ ex function::evalf() const } current_serial = serial; if (opt.evalf_use_exvector_args) - return ((evalf_funcp_exvector)(opt.evalf_f))(seq); + return ((evalf_funcp_exvector)(opt.evalf_f))(eseq); switch (opt.nparams) { // the following lines have been generated for max. @maxargs@ parameters +++ for N in range(1, maxargs + 1): @@ -448,7 +450,7 @@ ex function::evalf() const } /** - * This method is defined to be in line with behaviour of function::return_type() + * This method is defined to be in line with behavior of function::return_type() */ ex function::eval_ncmul(const exvector & v) const { @@ -764,7 +766,7 @@ ex function::expl_derivative(const symbol & s) const // explicit differentiation // end of generated lines } } - // There is no fallback for explicit deriviative. + // There is no fallback for explicit derivative. throw(std::logic_error("function::expl_derivative(): explicit derivation is called, but no such function defined")); } @@ -838,8 +840,8 @@ void function::store_remember_table(ex const & result) const unsigned function::register_new(function_options const & opt) { size_t same_name = 0; - for (size_t i=0; i