diff --git a/src/common/matrixproperties.jl b/src/common/matrixproperties.jl index 5a73176e..25876b90 100644 --- a/src/common/matrixproperties.jl +++ b/src/common/matrixproperties.jl @@ -157,7 +157,7 @@ function strided_ishermitian_approx( for j in 1:blocksize:n jb = min(blocksize, n - j + 1) ϵ² += _ishermitian_approx_diag(view(A, j:(j + jb - 1), j:(j + jb - 1)), anti) - ϵ² < ϵ²max || return false + ϵ² ≤ ϵ²max || return false for i in 1:blocksize:(j - 1) ib = blocksize ϵ² += 2 * _ishermitian_approx_offdiag( @@ -165,7 +165,7 @@ function strided_ishermitian_approx( view(A, j:(j + jb - 1), i:(i + ib - 1)), anti ) - ϵ² < ϵ²max || return false + ϵ² ≤ ϵ²max || return false end end return true diff --git a/test/projections.jl b/test/projections.jl index 3923528e..9a6644cf 100644 --- a/test/projections.jl +++ b/test/projections.jl @@ -1,4 +1,5 @@ using MatrixAlgebraKit +using MatrixAlgebraKit: check_hermitian, default_hermitian_tol using Test using TestExtras using StableRNGs @@ -10,6 +11,12 @@ const BLASFloats = (Float32, Float64, ComplexF32, ComplexF64) rng = StableRNG(123) m = 54 noisefactor = eps(real(T))^(3 / 4) + + mat0 = zeros(T, (1, 1)) + @test ishermitian(mat0) + @test ishermitian(mat0; atol = default_hermitian_tol(mat0)) + @test isnothing(check_hermitian(mat0)) + for alg in (NativeBlocked(blocksize = 16), NativeBlocked(blocksize = 32), NativeBlocked(blocksize = 64)) for A in (randn(rng, T, m, m), Diagonal(randn(rng, T, m))) Ah = (A + A') / 2