-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store info in Cholesky type #21976
Store info in Cholesky type #21976
Conversation
and delay throwing for non-positive definiteness
I think I will deal with the |
base/linalg/cholesky.jl
Outdated
@@ -18,6 +18,11 @@ | |||
# through the Hermitian and Symmetric views or exact symmetric or Hermitian elements which | |||
# is checked for and an error is thrown if the check fails. | |||
|
|||
# The internal structure is as follows | |||
# - _chol! return the factor and info without checking positive definiteness |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returns ?
base/linalg/cholesky.jl
Outdated
@@ -99,30 +113,33 @@ function _chol!(A::AbstractMatrix, ::Type{LowerTriangular}) | |||
end | |||
end | |||
end | |||
return LowerTriangular(A) | |||
return LowerTriangular(A), convert(BlasInt, 0) # TODO: If we get here, do we know A is pos. def? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd think so. What could be wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay thanks. Just wanted to make sure, will remove the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was paranoid so confirmed with experiments:
for N in (10, 100, 1000), i in 1:1000
A = rand(N, N); B = A'A
for M in (A, B)
C, info = invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{LowerTriangular}}, copy(M), LowerTriangular)
infoblas = cholfact(Hermitian(M, :L)).info
info == infoblas == 0 || (info > 0 && infoblas > 0) || error()
end
for M in (A, B)
C, info = invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{UpperTriangular}}, copy(M), UpperTriangular)
infoblas = cholfact(Hermitian(M, :U)).info
info == infoblas == 0 || (info > 0 && infoblas > 0) || error()
end
end
for T in (Float32, Float64, Complex64, Complex128) | ||
A = T[1 2; 2 1]; B = T[1, 1] | ||
C = cholfact(A) | ||
@show typeof(A), typeof(B), typeof(C.factors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debugging output left in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, sry
Implements #21559 (comment)
The first commit is #21595 (bump on that, its pure code deletion), so when that is merged I will rebase.
Tests pass locally, but there are still things that needs to be changed, for instance