Skip to content

Commit

Permalink
Consolidate pinv tests (#23627)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt authored and sambitdash committed Sep 8, 2017
1 parent 15b29bc commit 0a8b120
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions test/linalg/pinv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

0 comments on commit 0a8b120

Please sign in to comment.