1 /** @file time_fateman_expand.cpp
3 * Time for polynomial expansion of (x+y+z+1)^20 * ((x+y+z+1)^20+1).
4 * This test was suggested by Richard J. Fateman as a benchmark for programs
5 * to multiply sparse polynomials fast.
9 * GiNaC Copyright (C) 1999-2010 Johannes Gutenberg University Mainz, Germany
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 using namespace GiNaC;
33 static unsigned test()
36 const symbol x("x"), y("y"), z("z");
38 const ex p = pow(x+y+z+1, 20);
40 const ex hugesum = expand(p * (p+1));
42 if (hugesum.nops()!=12341) {
43 clog << "(x+y+z+1)^20 * ((x+y+z+1)^20+1) was miscomputed!" << endl;
50 unsigned time_fateman_expand()
57 cout << "timing Fateman's polynomial expand benchmark" << flush;
60 // correct for very small times:
64 } while ((time=concord.read())<0.1 && !result);
67 cout << time/count << 's' << endl;
72 extern void randomify_symbol_serials();
74 int main(int argc, char** argv)
76 randomify_symbol_serials();
77 cout << setprecision(2) << showpoint;
78 return time_fateman_expand();