]> 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 23c7a95351088ae9fe746db847624db8b835ff8d..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;
@@ -62,17 +65,18 @@ unsigned time_dennyfliegner(void)
     
     vector<unsigned> sizes;
     vector<double> times;
-    timer rolex;
+    timer breitling;
     
-    sizes.push_back(40);
-    sizes.push_back(60);
+    sizes.push_back(25);
+    sizes.push_back(50);
     sizes.push_back(100);
-    sizes.push_back(150);
+    sizes.push_back(200);
     
     for (vector<unsigned>::iterator i=sizes.begin(); i!=sizes.end(); ++i) {
-        rolex.start();
-        result += expand_subs(*i);  cout << '.' << flush;
-        times.push_back(rolex.read());
+        breitling.start();
+        result += expand_subs(*i);
+        times.push_back(breitling.read());
+        cout << '.' << flush;
     }
     
     if (!result) {
@@ -83,13 +87,11 @@ unsigned time_dennyfliegner(void)
     }
     // print the report:
     cout << endl << "    size:  ";
-    for (vector<unsigned>::iterator i=sizes.begin(); i!=sizes.end(); ++i) {
+    for (vector<unsigned>::iterator i=sizes.begin(); i!=sizes.end(); ++i)
         cout << '\t' << (*i);
-    }
     cout << endl << "    time/s:";
-    for (vector<double>::iterator i=times.begin(); i!=times.end(); ++i) {
-        cout << '\t' << (*i);
-    }
+    for (vector<double>::iterator i=times.begin(); i!=times.end(); ++i)
+        cout << '\t' << int(1000*(*i))*0.001;
     cout << endl;
     
     return result;