@@ -4,7 +4,7 @@ function test_eigh(T::Type, sz; kwargs...)
44 summary_str = testargs_summary (T, sz)
55 return @testset " eigh $summary_str " begin
66 test_eigh_full (T, sz; kwargs... )
7- if eltype (T) <: Union{Float16, ComplexF16, Float32, Float64, ComplexF32, ComplexF64} && ! (T <: Diagonal )
7+ if T <: Number && eltype (T) <: Union{Float16, ComplexF16, Float32, Float64, ComplexF32, ComplexF64} && ! (T <: Diagonal )
88 test_eigh_trunc (T, sz; kwargs... )
99 end
1010 end
@@ -54,31 +54,29 @@ function test_eigh_trunc(
5454 r = m - 2
5555 s = 1 + sqrt (eps (real (eltype (T))))
5656 atol = sqrt (eps (real (eltype (T))))
57- local V1, V2, V3
58- @testset " truncrank" begin
59- D1, V1, ϵ1 = @testinferred eigh_trunc (A; trunc = truncrank (r))
60- @test length (diagview (D1)) == r
61- @test isisometric (V1)
62- @test A * V1 ≈ V1 * D1
63- @test LinearAlgebra. opnorm (A - V1 * D1 * V1' ) ≈ D₀[r + 1 ]
64- @test ϵ1 ≈ norm (view (D₀, (r + 1 ): m)) atol = atol
65- end
66- @testset " trunctol" begin
67- trunc = trunctol (; atol = s * D₀[r + 1 ])
68- D2, V2, ϵ2 = @testinferred eigh_trunc (A; trunc)
69- @test length (diagview (D2)) == r
70- @test isisometric (V2)
71- @test A * V2 ≈ V2 * D2
72- @test ϵ2 ≈ norm (view (D₀, (r + 1 ): m)) atol = atol
73- end
74- @testset " truncerror" begin
75- s = 1 - sqrt (eps (real (eltype (T))))
76- trunc = truncerror (; atol = s * norm (@view (D₀[r: end ]), 1 ), p = 1 )
77- D3, V3, ϵ3 = @testinferred eigh_trunc (A; trunc)
78- @test length (diagview (D3)) == r
79- @test A * V3 ≈ V3 * D3
80- @test ϵ3 ≈ norm (view (D₀, (r + 1 ): m)) atol = atol
81- end
57+ # truncrank
58+ D1, V1, ϵ1 = @testinferred eigh_trunc (A; trunc = truncrank (r))
59+ @test length (diagview (D1)) == r
60+ @test isisometric (V1)
61+ @test A * V1 ≈ V1 * D1
62+ @test LinearAlgebra. opnorm (A - V1 * D1 * V1' ) ≈ D₀[r + 1 ]
63+ @test ϵ1 ≈ norm (view (D₀, (r + 1 ): m)) atol = atol
64+
65+ # trunctol
66+ trunc = trunctol (; atol = s * D₀[r + 1 ])
67+ D2, V2, ϵ2 = @testinferred eigh_trunc (A; trunc)
68+ @test length (diagview (D2)) == r
69+ @test isisometric (V2)
70+ @test A * V2 ≈ V2 * D2
71+ @test ϵ2 ≈ norm (view (D₀, (r + 1 ): m)) atol = atol
72+
73+ # truncerror
74+ s = 1 - sqrt (eps (real (eltype (T))))
75+ trunc = truncerror (; atol = s * norm (@view (D₀[r: end ]), 1 ), p = 1 )
76+ D3, V3, ϵ3 = @testinferred eigh_trunc (A; trunc)
77+ @test length (diagview (D3)) == r
78+ @test A * V3 ≈ V3 * D3
79+ @test ϵ3 ≈ norm (view (D₀, (r + 1 ): m)) atol = atol
8280
8381 # test for same subspace
8482 @test V1 * (V1' * V2) ≈ V2
0 commit comments