1 /** @file exam_misc.cpp
6 * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 static unsigned exam_expand_subs(void)
35 for (unsigned i=0; i<VECSIZE; ++i) {
39 // prepare aux so it will swallow anything but a1^2:
40 aux = -e + a[0] + a[1];
41 e = expand(subs(expand(pow(e, 2)), a[0] == aux));
44 clog << "Denny Fliegner's quick consistency check erroneously returned "
52 /* A simple modification of Denny Fliegner's three step consistency test:
53 * 1) e = (a0 + a1)^200
55 * 3) substitute a0 by -a1 in e
56 * after which e should return 0 (without expanding). */
57 static unsigned exam_expand_subs2(void)
60 symbol a("a"), b("b");
63 e = pow(a+b,200).expand();
67 clog << "e = pow(a+b,200).expand(); f = e.subs(a == -b); erroneously returned "
68 << f << " instead of simplifying to 0." << endl;
75 unsigned exam_misc(void)
79 cout << "examining miscellaneous other things" << flush;
80 clog << "----------miscellaneous other things:" << endl;
82 result += exam_expand_subs(); cout << '.' << flush;
83 result += exam_expand_subs2(); cout << '.' << flush;
86 cout << " passed " << endl;
87 clog << "(no output)" << endl;
89 cout << " failed " << endl;