[GiNaC-list] simple patch for Li_evalf
Sheplyakov Alexei
varg at thsun1.jinr.ru
Thu Sep 23 15:59:04 CEST 2004
Hello!
This short program
#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
int main(int argc, char** argv)
{
ex test = Li(5, exp(I*Pi/3));
cout << test << " = " << test.evalf() << endl;
return 0;
}
gives
Li(5,exp((1/3*I)*Pi)) = Li(5,exp((1/3*I)*Pi))
instead of expected
Li(5,exp((1/3*I)*Pi)) = 0.48005914589970829926+0.89203268884598503196*I
Attached patch seems to solve the problem.
Best regards,
Alexei.
-------------- next part --------------
diff -Nru GiNaC-1.2.3-orig/ginac/inifcns_nstdsums.cpp GiNaC-1.2.3/ginac/inifcns_nstdsums.cpp
--- GiNaC-1.2.3-orig/ginac/inifcns_nstdsums.cpp 2004-09-23 10:55:05.000000000 +0400
+++ GiNaC-1.2.3/ginac/inifcns_nstdsums.cpp 2004-09-23 11:14:09.000000000 +0400
@@ -504,8 +504,13 @@
static ex Li_evalf(const ex& x1, const ex& x2)
{
// classical polylogs
- if (is_a<numeric>(x1) && is_a<numeric>(x2)) {
- return Li_num(ex_to<numeric>(x1).to_int(), ex_to<numeric>(x2));
+ if (is_a<numeric>(x1) && !is_a<lst>(x2)) {
+ // try to numerically evaluate second argument
+ ex x2_val = x2.evalf();
+ if (is_a<numeric>(x2_val))
+ return Li_num(ex_to<numeric>(x1).to_int(), ex_to<numeric>(x2_val));
+ else
+ return Li(x1,x2).hold();
}
// multiple polylogs
else if (is_a<lst>(x1) && is_a<lst>(x2)) {
More information about the GiNaC-list
mailing list