@@ -23,16 +23,17 @@ bimg = randn(n,2)/2
2323 a = eltya == Int ? rand (1 : 7 , n, n) : convert (Matrix{eltya}, eltya <: Complex ? complex .(areal, aimg) : areal)
2424 a2 = eltya == Int ? rand (1 : 7 , n, n) : convert (Matrix{eltya}, eltya <: Complex ? complex .(a2real, a2img) : a2real)
2525 @testset for atype in (" Array" , " SubArray" )
26- asym = a' + a # symmetric indefinite
27- apd = a' * a # symmetric positive-definite
26+ asym = a.' + a # symmetric indefinite
27+ aher = a' + a # Hermitian indefinite
28+ apd = a' * a # Positive-definite
2829 if atype == " Array"
29- a = a
30+ a = a
3031 a2 = a2
3132 else
32- a = view (a, 1 : n, 1 : n)
33- a2 = view (a2, 1 : n, 1 : n)
34- asym = view (asym , 1 : n, 1 : n)
35- apd = view (apd, 1 : n, 1 : n)
33+ a = view (a , 1 : n, 1 : n)
34+ a2 = view (a2 , 1 : n, 1 : n)
35+ aher = view (aher , 1 : n, 1 : n)
36+ apd = view (apd , 1 : n, 1 : n)
3637 end
3738 ε = εa = eps (abs (float (one (eltya))))
3839
@@ -48,36 +49,40 @@ bimg = randn(n,2)/2
4849 εb = eps (abs (float (one (eltyb))))
4950 ε = max (εa,εb)
5051
51- @testset " (Automatic) Bunch-Kaufman factor of indefinite matrix" begin
52- bc1 = factorize (asym)
52+ # check that factorize gives a Bunch-Kaufman
53+ @test isa (factorize (asym), LinAlg. BunchKaufman)
54+ @test isa (factorize (aher), LinAlg. BunchKaufman)
55+
56+ @testset " $uplo Bunch-Kaufman factor of indefinite matrix" for uplo in (:L , :U )
57+ bc1 = bkfact (Hermitian (aher, uplo))
5358 @test LinAlg. issuccess (bc1)
5459 @test logabsdet (bc1)[1 ] ≈ log (abs (det (bc1)))
5560 if eltya <: Real
5661 @test logabsdet (bc1)[2 ] == sign (det (bc1))
5762 else
5863 @test logabsdet (bc1)[2 ] ≈ sign (det (bc1))
5964 end
60- @test inv (bc1)* asym ≈ eye (n)
61- @test asym * (bc1\ b) ≈ b atol= 1000 ε
65+ @test inv (bc1)* aher ≈ eye (n)
66+ @test aher * (bc1\ b) ≈ b atol= 1000 ε
6267 @testset for rook in (false , true )
63- @test inv (bkfact (a.' + a, :U , true , rook))* (a.' + a) ≈ eye (n)
68+ @test inv (bkfact (Symmetric ( a.' + a, uplo), rook))* (a.' + a) ≈ eye (n)
6469 @test size (bc1) == size (bc1. LD)
65- @test size (bc1,1 ) == size (bc1. LD,1 )
66- @test size (bc1,2 ) == size (bc1. LD,2 )
70+ @test size (bc1, 1 ) == size (bc1. LD, 1 )
71+ @test size (bc1, 2 ) == size (bc1. LD, 2 )
6772 if eltya <: BlasReal
6873 @test_throws ArgumentError bkfact (a)
6974 end
7075 end
7176 end
7277
73- @testset " Bunch-Kaufman factors of a pos-def matrix" begin
74- @testset for rook in (false , true )
75- bc2 = bkfact (apd, :U , issymmetric (apd ), rook)
78+ @testset " $uplo Bunch-Kaufman factors of a pos-def matrix" for uplo in ( :U , :L )
79+ @testset " rook pivoting: $rook " for rook in (false , true )
80+ bc2 = bkfact (Hermitian ( apd, uplo ), rook)
7681 @test LinAlg. issuccess (bc2)
7782 @test logdet (bc2) ≈ log (det (bc2))
7883 @test logabsdet (bc2)[1 ] ≈ log (abs (det (bc2)))
7984 @test logabsdet (bc2)[2 ] == sign (det (bc2))
80- @test inv (bc2)* apd ≈ eye (n)
85+ @test inv (bc2)* apd ≈ eye (eltyb, n)
8186 @test apd* (bc2\ b) ≈ b atol= 150000 ε
8287 @test ishermitian (bc2) == ! issymmetric (bc2)
8388 end
@@ -104,11 +109,13 @@ end
104109 end
105110
106111 @testset for rook in (false , true )
107- F = bkfact (As, :U , issymmetric (As), rook)
108- @test ! LinAlg. issuccess (F)
109- @test det (F) == 0
110- @test_throws LinAlg. SingularException inv (F)
111- @test_throws LinAlg. SingularException F \ ones (size (As, 1 ))
112+ @testset for uplo in (:L , :U )
113+ F = bkfact (issymmetric (As) ? Symmetric (As, uplo) : Hermitian (As, uplo), rook)
114+ @test ! LinAlg. issuccess (F)
115+ @test det (F) == 0
116+ @test_throws LinAlg. SingularException inv (F)
117+ @test_throws LinAlg. SingularException F \ ones (size (As, 1 ))
118+ end
112119 end
113120 end
114121 end
0 commit comments