]> www.ginac.de Git - ginac.git/commitdiff
added a check for the power::expand_add_2() bug
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Thu, 24 Oct 2002 20:37:19 +0000 (20:37 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Thu, 24 Oct 2002 20:37:19 +0000 (20:37 +0000)
check/exam_paranoia.cpp

index 50b5cabd9eb1630eb6730cfd303ecb2f64d4c83d..104e20da9207f7b5f07ccddb7f305107691c1ab8 100644 (file)
@@ -352,6 +352,24 @@ static unsigned exam_paranoia14(void)
        return result;
 }
 
        return result;
 }
 
+// Under certain conditions, power::expand_add_2() could produce non-canonical
+// numeric expairs. Fixed on Oct 24, 2002.
+static unsigned exam_paranoia15(void)
+{
+       unsigned result = 0;
+
+       ex q = (pow(pow(2, numeric(1, 2))*2+1, 2)).expand();
+       // this used to produce "1+4*sqrt(2)+4*2" which would never evaluate
+       // to "9+4*sqrt(2)"
+
+       if (!(q-9-4*pow(2, numeric(1, 2).is_zero()) {
+               clog << "expand((sqrt(2)*2+1)^2) erroneously returned " << q << " instead of 9-4*sqrt(2)\n";
+               ++result;
+       }
+
+       return result;
+}
+
 unsigned exam_paranoia(void)
 {
        unsigned result = 0;
 unsigned exam_paranoia(void)
 {
        unsigned result = 0;
@@ -373,6 +391,7 @@ unsigned exam_paranoia(void)
        result += exam_paranoia12();  cout << '.' << flush;
        result += exam_paranoia13();  cout << '.' << flush;
        result += exam_paranoia14();  cout << '.' << flush;
        result += exam_paranoia12();  cout << '.' << flush;
        result += exam_paranoia13();  cout << '.' << flush;
        result += exam_paranoia14();  cout << '.' << flush;
+       result += exam_paranoia15();  cout << '.' << flush;
        
        if (!result) {
                cout << " passed " << endl;
        
        if (!result) {
                cout << " passed " << endl;