Skip to content

Commit b8b2634

Browse files
kshyattandreasnoack
authored andcommitted
A few missing tests for cholesky (#19396)
* Missing tests for cholfact * Error throwing tests for up/downdate
1 parent 38736a5 commit b8b2634

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/linalg/cholesky.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,24 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int)
6666
capds = cholfact(apds)
6767
@test inv(capds)*apds eye(n)
6868
@test abs((det(capds) - det(apd))/det(capds)) <= ε*κ*n
69+
if eltya <: BlasReal
70+
capds = cholfact!(copy(apds))
71+
@test inv(capds)*apds eye(n)
72+
@test abs((det(capds) - det(apd))/det(capds)) <= ε*κ*n
73+
end
6974
else
7075
capdh = cholfact(apdh)
7176
@test inv(capdh)*apdh eye(n)
7277
@test abs((det(capdh) - det(apd))/det(capdh)) <= ε*κ*n
78+
capdh = cholfact!(copy(apdh))
79+
@test inv(capdh)*apdh eye(n)
80+
@test abs((det(capdh) - det(apd))/det(capdh)) <= ε*κ*n
81+
capdh = cholfact!(copy(apd))
82+
@test inv(capdh)*apdh eye(n)
83+
@test abs((det(capdh) - det(apd))/det(capdh)) <= ε*κ*n
84+
capdh = cholfact!(copy(apd), :L)
85+
@test inv(capdh)*apdh eye(n)
86+
@test abs((det(capdh) - det(apd))/det(capdh)) <= ε*κ*n
7387
end
7488

7589
# test chol of 2x2 Strang matrix
@@ -125,6 +139,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int)
125139
@test size(cpapd) == size(apd)
126140
@test full(copy(cpapd)) apd
127141
@test det(cpapd) det(apd)
142+
@test logdet(cpapd) logdet(apd)
128143
@test cpapd[:P]*cpapd[:L]*cpapd[:U]*cpapd[:P]' apd
129144
end
130145

@@ -203,7 +218,9 @@ let A = complex(randn(10,5), randn(10, 5)), v = complex(randn(5), randn(5))
203218
F = cholfact(AcA, uplo)
204219
G = cholfact(BcB, uplo)
205220
@test LinAlg.lowrankupdate(F, v)[uplo] G[uplo]
221+
@test_throws DimensionMismatch LinAlg.lowrankupdate(F, ones(eltype(v), length(v)+1))
206222
@test LinAlg.lowrankdowndate(G, v)[uplo] F[uplo]
223+
@test_throws DimensionMismatch LinAlg.lowrankdowndate(G, ones(eltype(v), length(v)+1))
207224
end
208225
end
209226

@@ -245,3 +262,6 @@ end
245262
@test_throws ArgumentError Base.LinAlg.cholfact!(randn(5,5),:U,Val{false})
246263
@test_throws ArgumentError Base.LinAlg.cholfact!(randn(5,5),:U,Val{true})
247264
@test_throws ArgumentError cholfact(randn(5,5),:U,Val{false})
265+
266+
# Fail for non-BLAS element types
267+
@test_throws ArgumentError cholfact!(Hermitian(rand(Float16, 5,5)), Val{true})

0 commit comments

Comments
 (0)