Skip to content

Commit

Permalink
Make pinv work for Adjoint (#29837)
Browse files Browse the repository at this point in the history
Fixes #29723

(cherry picked from commit a472bc7)
  • Loading branch information
andreasnoack authored and KristofferC committed Oct 31, 2018
1 parent b9470f5 commit f938959
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
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

0 comments on commit f938959

Please sign in to comment.