-
-
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
Merged
Merged
Store info in Cholesky type #21976
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ debug = false | |
|
||
using Base.Test | ||
|
||
using Base.LinAlg: BlasComplex, BlasFloat, BlasReal, QRPivoted | ||
using Base.LinAlg: BlasComplex, BlasFloat, BlasReal, QRPivoted, PosDefException | ||
|
||
n = 10 | ||
|
||
|
@@ -60,7 +60,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int) | |
|
||
apos = apd[1,1] # test chol(x::Number), needs x>0 | ||
@test all(x -> x ≈ √apos, cholfact(apos).factors) | ||
@test_throws ArgumentError chol(-one(eltya)) | ||
@test_throws PosDefException chol(-one(eltya)) | ||
|
||
if eltya <: Real | ||
capds = cholfact(apds) | ||
|
@@ -194,10 +194,9 @@ end | |
|
||
begin | ||
# Cholesky factor of Matrix with non-commutative elements, here 2x2-matrices | ||
|
||
X = Matrix{Float64}[0.1*rand(2,2) for i in 1:3, j = 1:3] | ||
L = full(Base.LinAlg._chol!(X*X', LowerTriangular)) | ||
U = full(Base.LinAlg._chol!(X*X', UpperTriangular)) | ||
L = full(Base.LinAlg._chol!(X*X', LowerTriangular)[1]) | ||
U = full(Base.LinAlg._chol!(X*X', UpperTriangular)[1]) | ||
XX = full(X*X') | ||
|
||
@test sum(sum(norm, L*L' - XX)) < eps() | ||
|
@@ -212,8 +211,8 @@ for elty in (Float32, Float64, Complex{Float32}, Complex{Float64}) | |
A = randn(5,5) | ||
end | ||
A = convert(Matrix{elty}, A'A) | ||
@test full(cholfact(A)[:L]) ≈ full(invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{LowerTriangular}}, copy(A), LowerTriangular)) | ||
@test full(cholfact(A)[:U]) ≈ full(invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{UpperTriangular}}, copy(A), UpperTriangular)) | ||
@test full(cholfact(A)[:L]) ≈ full(invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{LowerTriangular}}, copy(A), LowerTriangular)[1]) | ||
@test full(cholfact(A)[:U]) ≈ full(invoke(Base.LinAlg._chol!, Tuple{AbstractMatrix, Type{UpperTriangular}}, copy(A), UpperTriangular)[1]) | ||
end | ||
|
||
# Test up- and downdates | ||
|
@@ -272,3 +271,14 @@ end | |
|
||
# Fail for non-BLAS element types | ||
@test_throws ArgumentError cholfact!(Hermitian(rand(Float16, 5,5)), Val{true}) | ||
|
||
@testset "throw for non positive matrix" begin | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. yes, sry |
||
@test_throws PosDefException C\B | ||
@test_throws PosDefException det(C) | ||
@test_throws PosDefException logdet(C) | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: