@@ -3,24 +3,21 @@ non_hermitian_error() = throw(LinearAlgebra.PosDefException(-1))
3
3
@inline function LinearAlgebra. cholesky (A:: StaticMatrix ; check:: Bool = true )
4
4
ishermitian (A) || non_hermitian_error ()
5
5
_cholesky (Size (A), A, check)
6
- # (check && (info ≠ 0)) && throw(LinearAlgebra.PosDefException(info))
7
- # return Cholesky(C, 'U', info)
8
6
end
9
7
10
8
@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)
14
10
end
15
11
@inline LinearAlgebra. _chol! (A:: StaticMatrix , :: Type{UpperTriangular} ) = (cholesky (A). U, 0 )
16
12
17
- @inline function _check_chol (A, info, check)
13
+ @inline function _chol_failure (A, info, check)
18
14
if check
19
15
throw (LinearAlgebra. PosDefException (info))
20
16
else
21
- return Cholesky (A, ' U' , info)
17
+ Cholesky (A, ' U' , info)
22
18
end
23
19
end
20
+ # x < zero(x) is check used in `sqrt`, letting LLVM eliminate that check and remove error code.
24
21
@inline _nonpdcheck (x:: Real ) = x < zero (x)
25
22
@inline _nonpdcheck (x) = false
26
23
41
38
end
42
39
L_n_n = Symbol (:L_ ,n,:_ ,n)
43
40
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)))
50
42
Linv_n_n = Symbol (:Linv_ ,n,:_ ,n)
51
43
push! (q. args, :($ Linv_n_n = inv ($ L_n_n)))
52
44
for m ∈ n+ 1 : M
0 commit comments