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
39 typedef vector<point> vp;
44 static unsigned inifcns_consist_S(void)
48 ifstream in("exam_inifcns_nstdsums_data");
51 clog << "exam_inifcns_nstdsums_data not readable!" << endl;
76 numeric n = ex_to<numeric>(en);
77 numeric p = ex_to<numeric>(ep);
82 pp[n.to_int()-1][p.to_int()-1].push_back(ppbuf);
90 cout << endl << "Calculating ";
91 for (int sum=2; sum<=3; sum++) {
92 for (int nn=1; nn<sum; nn++) {
93 vp& da = pp[nn-1][sum-nn-1];
94 for (it = da.begin(); it!=da.end(); it++) {
95 cout << "S(" << nn << "," << sum-nn << "," << it->x << ") " << flush;
96 ex res = S(nn,sum-nn,it->x).evalf();
97 if (!is_a<numeric>(res)) {
98 if ((it->x != -1) || ((sum-nn) == 1)) {
99 clog << "S(" << nn << "," << sum-nn << "," << it->x << ") didn't give numerical result!" << endl;
104 ex reldiff = abs((it->res-res)/it->res);
105 if ((!is_a<numeric>(res)) || (reldiff > numeric("1E-10"))) {
106 clog << "S(" << nn << "," << sum-nn << "," << it->x << ") seems to be wrong:" << endl;
107 clog << "GiNaC : " << res << endl;
108 clog << "Reference : " << it->res << endl;
109 clog << "Abs. Difference : " << it->res-res << endl;
110 clog << "Rel. Difference : " << reldiff << endl;
124 unsigned exam_inifcns_nstdsums(void)
128 cout << "examining consistency of nestedsums functions" << flush;
129 clog << "----------consistency of nestedsums functions:" << endl;
131 result += inifcns_consist_S(); cout << '.' << flush;
134 cout << " passed " << endl;
135 clog << "(no output)" << endl;
137 cout << " failed " << endl;