The check=false option present in lu!, bunchkaufman! and other factorization routines is super useful to handle exceptions efficiently. Unfortunately, the svd! doesn’t have this option and I am getting LinearAlgebra.LAPACKException(1) in the middle of a very complicated routine.
What is the recommended method to emulate the check=false behavior with svd!? I am assuming that a throw-catch block will compromise type stability and performance. Is that right?
yeah probably just needs a PR to LinearAlgebra. The other check=false options were mostly added for LinearSolve.jl which doesn’t use SVD as much so no one made the PR.
Sure! basically what you want to do is figure out what line inspects the Lapack exception code and turns it into a Julia exception, and then modify it to make it do that only if check=true. check kwarg for factorizations by fredrikekre · Pull Request #27336 · JuliaLang/julia · GitHub should give you a decent template (since this implemented it for lots of other factorizations)
The SVD is a little different from LU and Cholesky. In theory, the algorithm shouldn’t fail for any matrix with finite elements so the error here is actually considered a bug in LAPACK, see Possible bug in `dgesdd` routine · Issue #672 · Reference-LAPACK/lapack · GitHub. Hence, I’m not sure it is a good idea to extend check to cover a case that is actually a bug.
I think the issue might be isolated to the divide-and-conquer algorithm so you might be able to completely avoid the issue by setting alg=QRIteration().
If you can isolate the matrix, ideally after it has been transformed to a bidiagonal, it would be useful if you could share it in the linked issue.