]> www.ginac.de Git - ginac.git/blobdiff - check/exam_misc.cpp
fix stupid memory problem.
[ginac.git] / check / exam_misc.cpp
index f8a52578c1005b59c758b9ea438a131014dcb872..c9872a93284bce8659586a99ba2afc4d52fc9bba 100644 (file)
 static unsigned exam_expand_subs(void)
 {
        unsigned result = 0;
 static unsigned exam_expand_subs(void)
 {
        unsigned result = 0;
-       symbol a1("a1");
        symbol a[VECSIZE];
        ex e, aux;
        
        symbol a[VECSIZE];
        ex e, aux;
        
-       a[1] = a1;
-       for (unsigned i=0; i<VECSIZE; ++i) {
+       for (unsigned i=0; i<VECSIZE; ++i)
                e = e + a[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));
        
        
        // 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)) {
+       if (e != pow(a[1],2)) {
                clog << "Denny Fliegner's quick consistency check erroneously returned "
                     << e << "." << endl;
                ++result;
                clog << "Denny Fliegner's quick consistency check erroneously returned "
                     << e << "." << endl;
                ++result;
@@ -72,6 +69,23 @@ static unsigned exam_expand_subs2(void)
        return result;
 }
 
        return result;
 }
 
+static unsigned exam_expand_power(void)
+{
+       unsigned result = 0;
+       symbol x("x"), a("a"), b("b");
+       ex e;
+       
+       e = pow(x,pow(a+b,2)-pow(a,2)-pow(b,2)-a*b*2).expand();
+       
+       if (e != 1) {
+               clog << "e = pow(x,pow(a+b,2)-pow(a,2)-pow(b,2)-a*b*2).expand(); erroneously returned "
+                    << e << " instead of simplifying to 1." << endl;
+               ++result;
+       }
+       
+       return result;
+}
+
 unsigned exam_misc(void)
 {
        unsigned result = 0;
 unsigned exam_misc(void)
 {
        unsigned result = 0;
@@ -81,6 +95,7 @@ unsigned exam_misc(void)
        
        result += exam_expand_subs();  cout << '.' << flush;
        result += exam_expand_subs2();  cout << '.' << flush;
        
        result += exam_expand_subs();  cout << '.' << flush;
        result += exam_expand_subs2();  cout << '.' << flush;
+       result += exam_expand_power(); cout << '.' << flush;
        
        if (!result) {
                cout << " passed " << endl;
        
        if (!result) {
                cout << " passed " << endl;