1 /** @file exam_inifcns_nstdsums.cpp
3 * This test routine applies assorted tests on initially known higher level
7 * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 * The data in the following include file has been produced by the following
31 * Mathematica (V4.1) script:
34 * x={0.2,0.7 ,1,1.4,3.0 }
36 * st = OpenAppend["exam_inifcns_nstdsums_data.raw"]
39 * Do[Write[st, i]; Write[st,j]; Write[st,x[[k]]+I*y[[l]]];
40 * Write[ st,N[PolyLog[i,j,x[[k]]+I*y[[l]]]]],{i,3},{j,3}], {k,5}],{l,4}]
43 * Do[Write[st, i]; Write[st,j]; Write[st,-x[[k]]+I*y[[l]]];
44 * Write[ st,N[PolyLog[i,j,-x[[k]]+I*y[[l]]]]],{i,3},{j,3}], {k,5}], {l,4}]
48 * and postprocessed by the following shell script
53 * cat exam_inifcns_nstdsums_data.raw | sed -e 's/\*\^/E/g' > exam_inifcns_nstdsums_data.raw2
54 * echo 'const char *data[] = {' > exam_inifcns_nstdsums_data.raw3
55 * for i in `cat exam_inifcns_nstdsums_data.raw2`; do echo \"$i\",; done >> exam_inifcns_nstdsums_data.raw3
56 * echo '"-999"};' >> exam_inifcns_nstdsums.h
60 #include "exam_inifcns_nstdsums.h"
63 // adjust this if you want to process more S(n,p,x) data
64 const int MAX_NDIM = 5;
65 const int MAX_PDIM = 5;
67 // signals end of data
68 const int ENDMARK = -999;
76 typedef vector<point> vp;
78 vp pp[MAX_NDIM][MAX_PDIM];
82 static unsigned inifcns_consist_S(void)
89 ex en(data[i++],symbol());
93 numeric n = ex_to<numeric>(en);
94 ex ep(data[i++],symbol());
95 numeric p = ex_to<numeric>(ep);
96 ex x(data[i++],symbol());
97 ex res(data[i++],symbol());
102 pp[n.to_int()-1][p.to_int()-1].push_back(ppbuf);
108 // cout << endl << "Calculating ";
109 for (int sum=2; sum<=3; sum++) {
110 for (int nn=1; nn<sum; nn++) {
111 vp& da = pp[nn-1][sum-nn-1];
112 for (it = da.begin(); it!=da.end(); it++) {
113 // cout << "S(" << nn << "," << sum-nn << "," << it->x << ") " << flush;
114 ex res = S(nn,sum-nn,it->x).evalf();
115 if (!is_a<numeric>(res)) {
116 if ((it->x != -1) || ((sum-nn) == 1)) {
117 clog << "S(" << nn << "," << sum-nn << "," << it->x << ") didn't give numerical result!" << endl;
122 ex reldiff = abs((it->res-res)/it->res);
123 if ((!is_a<numeric>(res)) || (reldiff > numeric("1E-10"))) {
124 clog << "S(" << nn << "," << sum-nn << "," << it->x << ") seems to be wrong:" << endl;
125 clog << "GiNaC : " << res << endl;
126 clog << "Reference : " << it->res << endl;
127 clog << "Abs. Difference : " << it->res-res << endl;
128 clog << "Rel. Difference : " << reldiff << endl;
142 unsigned exam_inifcns_nstdsums(void)
146 cout << "examining consistency of nestedsums functions" << flush;
147 clog << "----------consistency of nestedsums functions:" << endl;
149 result += inifcns_consist_S(); cout << '.' << flush;
152 cout << " passed " << endl;
153 clog << "(no output)" << endl;
155 cout << " failed " << endl;