]> www.ginac.de Git - ginac.git/blobdiff - check/time_dennyfliegner.cpp
- Complete revamp of methods in class matrix. Some redundant (and poor)
[ginac.git] / check / time_dennyfliegner.cpp
index 0d787853b506307db518b942f2536b41c9e76f79..db9ff80ce6e9527e81827bc027df21904fa9b115 100644 (file)
 static unsigned expand_subs(unsigned size)
 {
     unsigned result = 0;
-    symbol a1("a1");
-    symbol a[VECSIZE];
+    // create a vector of size symbols named "a0", "a1", ...
+    vector<symbol> a;
+    for (unsigned i=0; i<size; ++i) {
+        char buf[4];
+        ostrstream(buf,sizeof(buf)) << i << ends;
+        a.push_back(symbol(string("a")+buf));
+    }
     ex e, aux;
     
-    a[1] = a1;
-    for (unsigned i=0; i<size; ++i) {
+    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));
+    e = pow(e,2).expand().subs(a[0]==aux).expand();
     
-    if (e != pow(a1,2)) {
+    if (e != pow(a[1],2)) {
         clog << "Denny Fliegner's quick consistency check erroneously returned "
              << e << "." << endl;
         ++result;