Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions stdlib/LinearAlgebra/src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ julia> M * N

[^KY88]: Konstantinos Konstantinides and Kung Yao, "Statistical analysis of effective singular values in matrix rank determination", IEEE Transactions on Acoustics, Speech and Signal Processing, 36(5), 1988, 757-763. [doi:10.1109/29.1585](https://doi.org/10.1109/29.1585)
"""
function pinv(A::StridedMatrix{T}, rtol::Real) where T
function pinv(A::AbstractMatrix{T}, rtol::Real) where T
m, n = size(A)
Tout = typeof(zero(T)/sqrt(one(T) + one(T)))
if m == 0 || n == 0
Expand Down Expand Up @@ -1269,7 +1269,7 @@ function pinv(A::StridedMatrix{T}, rtol::Real) where T
Sinv[findall(.!isfinite.(Sinv))] .= zero(Stype)
return SVD.Vt' * (Diagonal(Sinv) * SVD.U')
end
function pinv(A::StridedMatrix{T}) where T
function pinv(A::AbstractMatrix{T}) where T
rtol = eps(real(float(one(T))))*min(size(A)...)
return pinv(A, rtol)
end
Expand Down
3 changes: 3 additions & 0 deletions stdlib/LinearAlgebra/test/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ bimg = randn(n,2)/2
pinva15 = pinv(a[:,1:n1])
@test a[:,1:n1]*pinva15*a[:,1:n1] ≈ a[:,1:n1]
@test pinva15*a[:,1:n1]*pinva15 ≈ pinva15
pinva15 = pinv(a[:,1:n1]') # the Adjoint case
@test a[:,1:n1]'*pinva15*a[:,1:n1]' ≈ a[:,1:n1]'
@test pinva15*a[:,1:n1]'*pinva15 ≈ pinva15

@test size(pinv(Matrix{eltya}(undef,0,0))) == (0,0)
end
Expand Down