From 2fea65e989e0fc8385e3ea25aff598b28137a252 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Fri, 14 Mar 2025 18:16:03 +0530 Subject: [PATCH 1/2] Ensure positive-definite matrix in lapack posv test --- test/lapack.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/lapack.jl b/test/lapack.jl index 6cda435d..068a43a6 100644 --- a/test/lapack.jl +++ b/test/lapack.jl @@ -687,7 +687,11 @@ end @testset for elty in (Float32, Float64, ComplexF32, ComplexF64) local n = 10 a = randn(elty, n, n) - A = a'*a + # generate a symmetric positive definite matrix as Q*D*Q', + # where Q is orthogonal, and D contains the eigenvalues + Q, _ = qr(a) + D = Diagonal(rand(real(elty), n) .+ real(oneunit(elty))) + A = Matrix(Hermitian(Q*D*Q')) # ensure that the matrix is exactly hermitian B = rand(elty, n, n) D = copy(A) C = copy(B) From 545d30771dda7615bbeaca9d5bb5f762e90d83cd Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Sat, 15 Mar 2025 22:42:25 +0530 Subject: [PATCH 2/2] Add identity to matrix --- test/lapack.jl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/lapack.jl b/test/lapack.jl index 068a43a6..8bc20ffd 100644 --- a/test/lapack.jl +++ b/test/lapack.jl @@ -687,11 +687,7 @@ end @testset for elty in (Float32, Float64, ComplexF32, ComplexF64) local n = 10 a = randn(elty, n, n) - # generate a symmetric positive definite matrix as Q*D*Q', - # where Q is orthogonal, and D contains the eigenvalues - Q, _ = qr(a) - D = Diagonal(rand(real(elty), n) .+ real(oneunit(elty))) - A = Matrix(Hermitian(Q*D*Q')) # ensure that the matrix is exactly hermitian + A = a'*a + I B = rand(elty, n, n) D = copy(A) C = copy(B)