diff --git a/stdlib/LinearAlgebra/src/dense.jl b/stdlib/LinearAlgebra/src/dense.jl index b8a44159de8bd..8d5a3e6ea8de2 100644 --- a/stdlib/LinearAlgebra/src/dense.jl +++ b/stdlib/LinearAlgebra/src/dense.jl @@ -1483,10 +1483,10 @@ function pinv(A::AbstractMatrix{T}; atol::Real = 0.0, rtol::Real = (eps(real(flo return B end SVD = svd(A) - tol = max(rtol*maximum(SVD.S), atol) + tol2 = max(rtol*maximum(SVD.S), atol) Stype = eltype(SVD.S) Sinv = fill!(similar(A, Stype, length(SVD.S)), 0) - index = SVD.S .> tol + index = SVD.S .> tol2 Sinv[index] .= pinv.(view(SVD.S, index)) return SVD.Vt' * (Diagonal(Sinv) * SVD.U') end