From 0a8b1206a156b51596d1664c991406029b16b869 Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Fri, 8 Sep 2017 03:53:50 -0700 Subject: [PATCH] Consolidate pinv tests (#23627) --- test/linalg/pinv.jl | 50 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/test/linalg/pinv.jl b/test/linalg/pinv.jl index 0dd73997c441a3..0cb26aa7f5648f 100644 --- a/test/linalg/pinv.jl +++ b/test/linalg/pinv.jl @@ -142,10 +142,8 @@ end @test apinv isa Vector{eltya} end end -end -@testset "zero valued numbers/vectors/matrices" begin - @testset for eltya in (Float32, Float64, Complex64, Complex128) + @testset "zero valued numbers/vectors/matrices" begin a = pinv(zero(eltya)) @test a ≈ 0.0 @@ -161,29 +159,29 @@ end @test a.diag[1] ≈ 0.0 @test a.diag[2] ≈ 0.0 end -end -@testset "sub-normal numbers/vectors/matrices" begin - @testset for eltya in (Float32, Float64) - a = pinv(realmin(eltya)/100) - @test a ≈ 0.0 - # Complex subnormal - a = pinv(realmin(eltya)/100*(1+1im)) - @test a ≈ 0.0 - - a = pinv([realmin(eltya); realmin(eltya)]/100) - @test a[1] ≈ 0.0 - @test a[2] ≈ 0.0 - # Complex subnormal - a = pinv([realmin(eltya); realmin(eltya)]/100*(1+1im)) - @test a[1] ≈ 0.0 - @test a[2] ≈ 0.0 - a = pinv(Diagonal([realmin(eltya); realmin(eltya)]/100)) - @test a.diag[1] ≈ 0.0 - @test a.diag[2] ≈ 0.0 - # Complex subnormal - a = pinv(Diagonal([realmin(eltya); realmin(eltya)]/100*(1+1im))) - @test a.diag[1] ≈ 0.0 - @test a.diag[2] ≈ 0.0 + if eltya <: Base.LinAlg.BlasReal + @testset "sub-normal numbers/vectors/matrices" begin + a = pinv(realmin(eltya)/100) + @test a ≈ 0.0 + # Complex subnormal + a = pinv(realmin(eltya)/100*(1+1im)) + @test a ≈ 0.0 + + a = pinv([realmin(eltya); realmin(eltya)]/100) + @test a[1] ≈ 0.0 + @test a[2] ≈ 0.0 + # Complex subnormal + a = pinv([realmin(eltya); realmin(eltya)]/100*(1+1im)) + @test a[1] ≈ 0.0 + @test a[2] ≈ 0.0 + a = pinv(Diagonal([realmin(eltya); realmin(eltya)]/100)) + @test a.diag[1] ≈ 0.0 + @test a.diag[2] ≈ 0.0 + # Complex subnormal + a = pinv(Diagonal([realmin(eltya); realmin(eltya)]/100*(1+1im))) + @test a.diag[1] ≈ 0.0 + @test a.diag[2] ≈ 0.0 + end end end