Skip to content

Commit 1e6183b

Browse files
authored
avoid division by zero in svd(::Diagonal)
1 parent 1137b4c commit 1e6183b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/diagonal.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ function svd(D::Diagonal{T}) where {T<:Number}
10241024
Vt = copy(U)
10251025
for i in 1:length(d)
10261026
j = piv[i]
1027-
U[j,i] = d[j] / S[i]
1027+
U[j,i] = iszero(d[j]) ? oneunit(Td) : d[j] / S[i]
10281028
Vt[i,j] = one(Td)
10291029
end
10301030
return SVD(U, S, Vt)

0 commit comments

Comments
 (0)