- // A degenerate example that went wrong in GiNaC 0.6.2.
- unsigned result = 0;
- symbol x("x"), y("y"), t("t");
- lst eqns, vars;
- ex sol;
-
- // Create the linear system [0*x+0*y==0,0*x+1*y==t]...
- eqns.append(0*x+0*y==0).append(0*x+1*y==t);
- // ...to be solved for [x,y]...
- vars.append(x).append(y);
- // ...and solve it:
- sol = lsolve(eqns, vars);
- ex sol_x = sol.op(0).rhs(); // rhs of solution for first variable (x)
- ex sol_y = sol.op(1).rhs(); // rhs of solution for second variable (y)
-
- // It should have returned [x==x,y==t]
- if (!(sol_x - x).is_zero() ||
- !(sol_y - t).is_zero()) {
- ++result;
- clog << "solution of the system " << eqns << " for " << vars
- << " erroneously returned " << sol << endl;
- }
-
- return result;
+ // A degenerate example that went wrong in GiNaC 0.6.2.
+ unsigned result = 0;
+ symbol x("x"), y("y"), t("t");
+ lst eqns, vars;
+ ex sol;
+
+ // Create the linear system [0*x+0*y==0,0*x+1*y==t]...
+ eqns.append(0*x+0*y==0).append(0*x+1*y==t);
+ // ...to be solved for [x,y]...
+ vars.append(x).append(y);
+ // ...and solve it:
+ sol = lsolve(eqns, vars);
+ ex sol_x = sol.op(0).rhs(); // rhs of solution for first variable (x)
+ ex sol_y = sol.op(1).rhs(); // rhs of solution for second variable (y)
+
+ // It should have returned [x==x,y==t]
+ if ((sol_x != x) ||
+ (sol_y != t)) {
+ ++result;
+ clog << "solution of the system " << eqns << " for " << vars
+ << " erroneously returned " << sol << endl;
+ }
+
+ return result;
+}
+
+static unsigned exam_lsolve3S(void)
+{
+ // A degenerate example that went wrong while trying to improve elimination
+ unsigned result = 0;
+ symbol b("b"), c("c");
+ symbol x("x"), y("y"), z("z");
+ lst eqns, vars;
+ ex sol;
+
+ // Create the linear system [y+z==b,-y+z==c] with one additional row...
+ eqns.append(ex(0)==ex(0)).append(b==z+y).append(c==z-y);
+ // ...to be solved for [x,y,z]...
+ vars.append(x).append(y).append(z);
+ // ...and solve it:
+ sol = lsolve(eqns, vars);
+ ex sol_x = sol.op(0).rhs(); // rhs of solution for first variable (x)
+ ex sol_y = sol.op(1).rhs(); // rhs of solution for second variable (y)
+ ex sol_z = sol.op(2).rhs(); // rhs of solution for third variable (z)
+
+ // It should have returned [x==x,y==t,]
+ if ((sol_x != x) ||
+ (sol_y != (b-c)/2) ||
+ (sol_z != (b+c)/2)) {
+ ++result;
+ clog << "solution of the system " << eqns << " for " << vars
+ << " erroneously returned " << sol << endl;
+ }
+
+ return result;