Cannot evaluate numerically 2^Pi, for instance.
Hi, I have found that when calling evalf() method for a power instance, its exponent is not evaluated. Here follows an example that demonstrates this: include <ginac/ginac.h> using namespace GiNaC; using namespace std; int main(void) { ex e = pow(2, Pi); cout << "e="; e.print(print_context(cout)); cout << endl; cout << "e.evalf()="; e.evalf().print(print_context(cout)); cout << endl; return 0; } The output is: e=2^Pi e.evalf()=(2.0)^Pi And I don't see anything wrong in ex power::evalf(int level) const; Do you? Regards, Pearu
On Sun, 19 Aug 2001, Pearu Peterson wrote: [...]
The output is: e=2^Pi e.evalf()=(2.0)^Pi
And I don't see anything wrong in ex power::evalf(int level) const; Do you?
After staring at it for an hour or two, yes. It's most embarrassing. Here is the fix: diff -r1.66 power.cpp 493c493 < if (!is_ex_exactly_of_type(eexponent,numeric)) ---
if (!is_ex_exactly_of_type(exponent,numeric))
See the problem? :-) Thank you for reporting this! -richy. -- Richard Kreckel <Richard.Kreckel@Uni-Mainz.DE> <http://wwwthep.physik.uni-mainz.de/~kreckel/>
participants (2)
-
Pearu Peterson
-
Richard B. Kreckel