Open hwjsnc opened 4 years ago
Yes, the linear algebra solving part needs some love. There will be a can_solve
(something in that direction), which gives you both the bool and a solution. We have this already in some other parts of the eco system (e.g. Nemo), but not here yet.
Agreed. I think isinvertible would be the canonical name. And as @thofma has suggested, can_solve seems to be the name of choice elsewhere for solve.
If you want to implement something like this, feel free. Extra points if it is relatively fast with early termination in the case that it is not invertible/soluble.
The methods are in principle at https://github.com/thofma/Hecke.jl/blob/master/src/Misc/Matrix.jl#L1759-L1787, but as you/we noticed they are probably transposing too much :)
It is a bit messy to get all the combinations of left/right and w/o kernel right.
In view of https://github.com/Nemocas/Nemo.jl/issues/862, it should probably be can_solve_with_solution
and can_solve_with_solution_and_kernel
and the left/right a keyword argument.
Thanks for the quick replies, I will try to implement this in the next few days. (No promises though, because I don't know how much effort it may be.)
The functions to invert a matrix or solve a system of linear equations such as
solve
,solve_left
, orinv
currently throw an unspecificErrorException
. For example:There doesn't appear to be a convenient way to check beforehand if a solution is exists.
In a user program, it is hard to catch the exception and figure out the source of the problem: Is it an unsolvable problem, a bug, a memory exception, ...?
For this reason, I believe it would be useful to have functions that can be called to tell if the problem is solvable (for example
isinvertible
orhasinv
); and/or functions that return a union type (for exampletry_solve
).