Skip to content

Commit b91846c

Browse files
committed
restrict inv(::SVD) to square matrices
1 parent db95a2a commit b91846c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/svd.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ function pinv(F::SVD{T}; atol::Real=0, rtol::Real = (eps(real(float(oneunit(T)))
312312
end
313313

314314
function inv(F::SVD)
315-
# TODO: checksquare(F)
315+
checksquare(F)
316316
@inbounds for i in eachindex(F.S)
317317
iszero(F.S[i]) && throw(SingularException(i))
318318
end

test/svd.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ using LinearAlgebra: BlasComplex, BlasFloat, BlasReal, QRPivoted
5353
@test sf2.U*Diagonal(sf2.S)*sf2.Vt' m2
5454

5555
@test ldiv!([0., 0.], svd(Matrix(I, 2, 2)), [1., 1.]) [1., 1.]
56-
# @test_throws DimensionMismatch inv(svd(Matrix(I, 3, 2)))
56+
@test_throws DimensionMismatch inv(svd(Matrix(I, 3, 2)))
5757
@test inv(svd(Matrix(I, 2, 2))) I
5858
@test inv(svd([1 2; 3 4])) [-2.0 1.0; 1.5 -0.5]
59-
@test inv(svd([1 0 1; 0 1 0])) [0.5 0.0; 0.0 1.0; 0.5 0.0]
59+
@test pinv(svd([1 0 1; 0 1 0])) [0.5 0.0; 0.0 1.0; 0.5 0.0]
6060
@test_throws SingularException inv(svd([0 0; 0 0]))
6161
@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]
6262
end

0 commit comments

Comments
 (0)