@@ -3,24 +3,21 @@ non_hermitian_error() = throw(LinearAlgebra.PosDefException(-1))
33@inline function LinearAlgebra. cholesky (A:: StaticMatrix ; check:: Bool = true )
44 ishermitian (A) || non_hermitian_error ()
55 _cholesky (Size (A), A, check)
6- # (check && (info ≠ 0)) && throw(LinearAlgebra.PosDefException(info))
7- # return Cholesky(C, 'U', info)
86end
97
108@inline function LinearAlgebra. cholesky (A:: LinearAlgebra.RealHermSymComplexHerm{<:Real, <:StaticMatrix} ; check:: Bool = true )
11- C = _cholesky (Size (A), A. data, check)
12- # (check && (info ≠ 0)) && throw(LinearAlgebra.PosDefException(info))
13- # return Cholesky(C, 'U', 0)
9+ _cholesky (Size (A), A. data, check)
1410end
1511@inline LinearAlgebra. _chol! (A:: StaticMatrix , :: Type{UpperTriangular} ) = (cholesky (A). U, 0 )
1612
17- @inline function _check_chol (A, info, check)
13+ @inline function _chol_failure (A, info, check)
1814 if check
1915 throw (LinearAlgebra. PosDefException (info))
2016 else
21- return Cholesky (A, ' U' , info)
17+ Cholesky (A, ' U' , info)
2218 end
2319end
20+ # x < zero(x) is check used in `sqrt`, letting LLVM eliminate that check and remove error code.
2421@inline _nonpdcheck (x:: Real ) = x < zero (x)
2522@inline _nonpdcheck (x) = false
2623
4138 end
4239 L_n_n = Symbol (:L_ ,n,:_ ,n)
4340 L_n_n_ltz = Symbol (:L_ ,n,:_ ,n,:_ ,:ltz )
44- # x < 0.0 is check used in `sqrt`, letting LLVM eliminate that check and remove error code.
45- # push!(q.args, :($L_n_n_ltz = )
46- push! (q. args, :($ L_n_n = _nonpdcheck ($ L_n_n) ? (return _check_chol (A, $ n, check)) : sqrt ($ L_n_n)))
47- # push!(q.args, :(info = ($L_n_n_ltz & (!failure)) ? $n : info))
48- # push!(q.args, :(failure |= $L_n_n_ltz))
49- # push!(q.args, :($L_n_n = $L_n_n_ltz ? float(typeof($L_n_n))(NaN) : sqrt($L_n_n)))
41+ push! (q. args, :($ L_n_n = _nonpdcheck ($ L_n_n) ? (return _chol_failure (A, $ n, check)) : sqrt ($ L_n_n)))
5042 Linv_n_n = Symbol (:Linv_ ,n,:_ ,n)
5143 push! (q. args, :($ Linv_n_n = inv ($ L_n_n)))
5244 for m ∈ n+ 1 : M
0 commit comments