]> www.ginac.de Git - ginac.git/commitdiff
Fix checks for sqrfree_parfrac().
authorRichard Kreckel <kreckel@ginac.de>
Sun, 18 Sep 2022 21:04:26 +0000 (23:04 +0200)
committerRichard Kreckel <kreckel@ginac.de>
Sun, 18 Sep 2022 21:04:26 +0000 (23:04 +0200)
check/exam_sqrfree.cpp

index 3e94ed67e68afb4efc53c605f0381d65f6b25be2..b9fc82a9b6f70cd32079dd7fd30a3631fafe048f 100644 (file)
@@ -202,15 +202,15 @@ unsigned exam_sqrfree_parfrac()
        symbol x("x");
        // (expression, number of terms after partial fraction decomposition)
        vector<pair<ex, unsigned>> exams = {
-               {ex("(x - 1) / (x*(x^2 + 2))", lst{x}), 2},
+               {ex("(x - 1) / (x^2*(x^2 + 2))", lst{x}), 3},
                {ex("(1 - x^10) / x", lst{x}), 2},
                {ex("(2*x^3 + x + 3) / ((x^2 + 1)^2)", lst{x}), 2},
-               {ex("1 / (x * (x+1) * (x+2))", lst{x}), 3},
-               {ex("(x*x + 3*x - 1) / (x^2*(x^2 + 2)^2)", lst{x}), 4},
+               {ex("1 / (x * (x+1)^2 * (x+2)^3)", lst{x}), 6},
+               {ex("(x*x + 3*x - 1) / (x^2*(x^2 + 2)^3)", lst{x}), 5},
                {ex("(1 - x^10) / (x + 2)", lst{x}), 11},
                {ex("(1 - x + 3*x^2) / (x^3 * (2+x)^2)", lst{x}), 5},
                {ex("(1 - x) / (x^4 * (x - 2)^3)", lst{x}), 6},
-               {ex("(1 - 2*x + x^9) / (x^5 * (1 - x + x^2)^5)", lst{x}), 12}
+               {ex("(1 - 2*x + x^9) / (x^5 * (1 - x + x^2)^6)", lst{x}), 11}
        };
        unsigned result = 0;
 
@@ -219,7 +219,8 @@ unsigned exam_sqrfree_parfrac()
        for (auto e: exams) {
                ex e1 = e.first;
                ex e2 = sqrfree_parfrac(e1, x);
-               if (e2.nops() != e.second &&
+               if (e2.nops() != e.second ||
+                   !is_a<add>(e2) ||
                    !normal(e1-e2).is_zero()) {
                        clog << "sqrfree_parfrac(" << e1 << ", " << x << ") erroneously returned "
                             << e2 << endl;