Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/svd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ function pinv(F::SVD{T}; atol::Real=0, rtol::Real = (eps(real(float(oneunit(T)))
end

function inv(F::SVD)
# TODO: checksquare(F)
checksquare(F)
@inbounds for i in eachindex(F.S)
iszero(F.S[i]) && throw(SingularException(i))
end
Expand Down
4 changes: 2 additions & 2 deletions test/svd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ using LinearAlgebra: BlasComplex, BlasFloat, BlasReal, QRPivoted
@test sf2.U*Diagonal(sf2.S)*sf2.Vt' ≊ m2

@test ldiv!([0., 0.], svd(Matrix(I, 2, 2)), [1., 1.]) ≊ [1., 1.]
# @test_throws DimensionMismatch inv(svd(Matrix(I, 3, 2)))
@test_throws DimensionMismatch inv(svd(Matrix(I, 3, 2)))
@test inv(svd(Matrix(I, 2, 2))) ≈ I
@test inv(svd([1 2; 3 4])) ≈ [-2.0 1.0; 1.5 -0.5]
@test inv(svd([1 0 1; 0 1 0])) ≈ [0.5 0.0; 0.0 1.0; 0.5 0.0]
@test pinv(svd([1 0 1; 0 1 0])) ≈ [0.5 0.0; 0.0 1.0; 0.5 0.0]
@test_throws SingularException inv(svd([0 0; 0 0]))
@test inv(svd([1+2im 3+4im; 5+6im 7+8im])) ≈ [-0.5 + 0.4375im 0.25 - 0.1875im; 0.375 - 0.3125im -0.125 + 0.0625im]
end
Expand Down