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-2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 static unsigned test(void)
31 const symbol x("x"), y("y"), z("z");
33 const ex p = pow(x+y+z+1, 20);
35 const ex hugesum = expand(p * (p+1));
37 if (hugesum.nops()!=12341) {
38 clog << "(x+y+z+1)^20 * ((x+y+z+1)^20+1) was miscomputed!" << endl;
45 unsigned time_fateman_expand(void)
52 cout << "timing Fateman's polynomial expand benchmark" << flush;
53 clog << "-------Fateman's polynomial expand benchmark:" << endl;
56 // correct for very small times:
60 } while ((time=concord.read())<0.1 && !result);
65 clog << "(no output)" << endl;
69 cout << int(1000*(time/count))*0.001 << 's' << endl;