X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Ffunction.pl;h=d4a03cec8289f94e09177eebb056ef5ef903cdc2;hp=dba4b3e0ba155fb4c9920882b8f615ad53a3db68;hb=9a4f392521083d28e1c238e7898ab1d2ac5b73cd;hpb=1602530f716ba1d425a0667b897182b99c374823 diff --git a/ginac/function.pl b/ginac/function.pl index dba4b3e0..d4a03cec 100644 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -2,7 +2,7 @@ # function.pl options: \$maxargs=${maxargs} # -# GiNaC Copyright (C) 1999-2009 Johannes Gutenberg University Mainz, Germany +# GiNaC Copyright (C) 1999-2011 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 @@ -292,7 +292,7 @@ $interface=< -#include -#include -#include -#include - #include "function.h" #include "operators.h" #include "fderivative.h" @@ -609,8 +603,15 @@ $implementation=< +#include +#include +#include +#include + namespace GiNaC { ////////// @@ -842,6 +843,9 @@ function::function(unsigned ser, const exprseq & es) : exprseq(es), serial(ser) function::function(unsigned ser, const exvector & v, bool discardable) : exprseq(v,discardable), serial(ser) { + if ( ser >= registered_functions().size() ) { + throw std::runtime_error("function does not exist"); + } } function::function(unsigned ser, std::auto_ptr vp) @@ -1062,8 +1066,7 @@ ex function::eval_ncmul(const exvector & v) const unsigned function::calchash() const { - const void* this_tinfo = (const void*)typeid(*this).name(); - unsigned v = golden_ratio_hash(golden_ratio_hash((p_int)this_tinfo) ^ serial); + unsigned v = golden_ratio_hash(make_hash_seed(typeid(*this)) ^ serial); for (size_t i=0; iop(i).gethash(); @@ -1121,7 +1124,7 @@ ex function::conjugate() const const function_options & opt = registered_functions()[serial]; if (opt.conjugate_f==0) { - return exprseq::conjugate(); + return conjugate_function(*this).hold(); } if (opt.conjugate_use_exvector_args) { @@ -1311,8 +1314,8 @@ ex function::power(const ex & power_param) const // power of function // No derivative defined? Then return abstract derivative object if (opt.power_f == NULL) - return (new power::power(*this, power_param))->setflag(status_flags::dynallocated | - status_flags::evaluated); + return (new GiNaC::power(*this, power_param))->setflag(status_flags::dynallocated | + status_flags::evaluated); current_serial = serial; if (opt.power_use_exvector_args) @@ -1388,7 +1391,9 @@ unsigned function::find_function(const std::string &name, unsigned nparams) /** Return the print name of the function. */ std::string function::get_name() const { - GINAC_ASSERT(serial= registered_functions().size() ) { + throw std::runtime_error("unknown function"); + } return registered_functions()[serial].name; }