Hi @certik , @asmeurer, @sushant-hiray, @isuruf
I have a few problems about the API we should provide with gaussian elimination and gauss jordan elimination.
Both the algorithms clearly identify two Matrices, A
anb b
in Ax = b
and operations are done on the augmented Matrix [A|b]
. Ultimate goal of the algorithms is to solve the system Ax = b
. So my question is, What should be our API to do this? I see two approaches towards this.
gaussian_elimination(const DenseMatrix &A, DenseMatrix &B)
:
This is the one I have used so far. Pros: User is able to find row echelon form of any matrix. Cons: Solving the system Ax = b
will have to be carried in steps. First creating [A|b]
, call gaussian_elimination([A|b], B)
and then solving the system using B
.
gaussian_elimination(const DensMatrix &A, const DenseMatrix &b, DenseMatrix &x)
:
This will return the solutions of the system Ax = b
as elements of vector x
. So no extra steps. But if an user wants to find the row echelon form of A
then he won't be able to do that through this API.
I would like to know your ideas regarding this.
.travis.yml
is used for both. There was this horrible bug (Shippable/support#238) that caused me hours of debugging, but a workaround now works great. @asmeurer you might be interested in this too.
I think I know, it's this part of Mul::dict_add_term()
:
} else {
// General case:
it->second = add(it->second, exp);
if (is_a<Integer>(*it->second) &&
rcp_static_cast<const Integer>(it->second)->is_zero()) {
d.erase(it);
}
}
which checks that the coefficient is zero
(after combining 2/x and 2/x), and removes it from the dictionary. So I think all that is needed is to check, that the combined coefficient and key is of the type 2^-5, i.e. that it can be represented as a Rational, and if so, remove it from the dict, and add it to the overall coefficient.