@@ -150,7 +150,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::LUFactorization; kwargs...)
150150
151151 F = @get_cacheval (cache, :LUFactorization )
152152 y = _ldiv! (cache. u, F, cache. b)
153- SciMLBase. build_linear_solution (alg, y, nothing , cache)
153+ SciMLBase. build_linear_solution (alg, y, nothing , cache; retcode = ReturnCode . Success )
154154end
155155
156156function do_factorization (alg:: LUFactorization , A, b, u)
@@ -203,7 +203,7 @@ function SciMLBase.solve!(cache::LinearSolve.LinearCache, alg::GenericLUFactoriz
203203 cache. isfresh = false
204204 end
205205 y = ldiv! (cache. u, LinearSolve. @get_cacheval (cache, :GenericLUFactorization )[1 ], cache. b)
206- SciMLBase. build_linear_solution (alg, y, nothing , cache)
206+ SciMLBase. build_linear_solution (alg, y, nothing , cache; retcode = ReturnCode . Success )
207207end
208208
209209function init_cacheval (
@@ -953,6 +953,12 @@ A fast factorization which uses a Cholesky factorization on A * A'. Can be much
953953faster than LU factorization, but is not as numerically stable and thus should only
954954be applied to well-conditioned matrices.
955955
956+ !!! warn
957+ `NormalCholeskyFactorization` should only be applied to well-conditioned matrices. As a
958+ method it is not able to easily identify possible numerical issues. As a check it is
959+ recommended that the user checks `A*u-b` is approximately zero, as this may be untrue
960+ even if `sol.retcode === ReturnCode.Success` due to numerical stability issues.
961+
956962## Positional Arguments
957963
958964 - pivot: Defaults to RowMaximum(), but can be NoPivot()
@@ -1010,6 +1016,12 @@ function SciMLBase.solve!(cache::LinearCache, alg::NormalCholeskyFactorization;
10101016 fact = cholesky (Symmetric ((A)' * A), alg. pivot; check = false )
10111017 end
10121018 cache. cacheval = fact
1019+
1020+ if hasmethod (LinearAlgebra. issuccess, Tuple{typeof (fact)}) && ! LinearAlgebra. issuccess (fact)
1021+ return SciMLBase. build_linear_solution (
1022+ alg, cache. u, nothing , cache; retcode = ReturnCode. Failure)
1023+ end
1024+
10131025 cache. isfresh = false
10141026 end
10151027 if issparsematrixcsc (A)
@@ -1021,7 +1033,7 @@ function SciMLBase.solve!(cache::LinearCache, alg::NormalCholeskyFactorization;
10211033 else
10221034 y = ldiv! (cache. u, @get_cacheval (cache, :NormalCholeskyFactorization ), A' * cache. b)
10231035 end
1024- SciMLBase. build_linear_solution (alg, y, nothing , cache)
1036+ SciMLBase. build_linear_solution (alg, y, nothing , cache; retcode = ReturnCode . Success )
10251037end
10261038
10271039# # NormalBunchKaufmanFactorization
0 commit comments