- unsigned result = 0;
- symbol a1("a1");
- symbol a[VECSIZE];
- ex e, aux;
-
- a[1] = a1;
- for (unsigned i=0; i<size; ++i) {
- e = e + a[i];
- }
-
- // prepare aux so it will swallow anything but a1^2:
- aux = -e + a[0] + a[1];
- e = expand(subs(expand(pow(e, 2)), a[0] == aux));
-
- if (e != pow(a1,2)) {
- clog << "Denny Fliegner's quick consistency check erroneously returned "
- << e << "." << endl;
- ++result;
- }
-
- return result;
+ unsigned result = 0;
+ // create a vector of size symbols named "a0", "a1", ...
+ vector<symbol> a;
+ ex e;
+ for (unsigned i=0; i<size; ++i) {
+#if defined(HAVE_SSTREAM)
+ ostringstream buf;
+ buf << "a" << i << ends;
+ a.push_back(symbol(buf.str()));
+#else
+ char buf[5]; // 'a' + 3 decimal digits + '\n'
+ ostrstream(buf,sizeof(buf)) << "a" << i << ends;
+ a.push_back(symbol(buf));
+#endif
+ e += a[i];
+ }
+ ex aux;
+
+ // prepare aux so it will swallow anything but a1^2:
+ aux = -e + a[0] + a[1];
+ e = pow(e,2).expand().subs(a[0]==aux).expand();
+
+ if (e != pow(a[1],2)) {
+ clog << "Denny Fliegner's quick consistency check erroneously returned "
+ << e << "." << endl;
+ ++result;
+ }
+
+ return result;