Hello! On Mon, Feb 18, 2008 at 02:32:45PM +0100, Diego Conti wrote:
But then, wouldn't it be natural to reorganize the code so that power::to_rational throws an exception when it is called as a result of the call to to_rational in fraction_free_elimination?
This approach sounds a bit wrong (to put it very mildly). First of all, power::to_rational does its work just fine, there's no need to change it. It's fraction_free_elimination which is buggy and needs to be fixed. Secondly, this would reject many valid expressions, i.e. #include <iostream> #include <ginac/ginac.h> using namespace std; using namespace GiNaC; int main(int argc, char** argv) { symbol a("A"),b("B"),c("C"),d("D"),x("X"); lst syms; syms = a,b; lst eqns; eqns = sqrt(1-pow(x,2))*a + x*b == c, -x*a + sqrt(1-pow(x,2))*b == d; ex sol = lsolve(eqns, syms, solve_algo::bareiss); cout << "System: " << eqns << endl << "Solution: " << sol << endl; return 0; }
Then one could have matrix::solve catch the exception and switch automatically to a different algorithm,
The problem is not that simple (see the example above). Best regards, Alexei -- All science is either physics or stamp collecting.