Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding rtol and atol for pinv and nullspace #29998

Merged
merged 12 commits into from
Dec 11, 2018
Prev Previous commit
Next Next commit
resolve comment
  • Loading branch information
sam0410 committed Nov 21, 2018
commit 82afdf28d33226e570e2d58ae82becc9a964140c
6 changes: 3 additions & 3 deletions stdlib/LinearAlgebra/src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ factorize(A::Transpose) = transpose(factorize(parent(A)))
## Moore-Penrose pseudoinverse

"""
pinv(M, atol::Real, rtol::Real)
pinv(M; atol::Real, rtol::Real)
pinv(M[, tol::Real]) = pinv(M, rtol=tol)

Computes the Moore-Penrose pseudoinverse.
Expand Down Expand Up @@ -1276,7 +1276,7 @@ function pinv(A::AbstractMatrix{T}; atol::Real = 0.0, rtol::Real = (eps(real(flo
Sinv[findall(.!isfinite.(Sinv))] .= zero(Stype)
return SVD.Vt' * (Diagonal(Sinv) * SVD.U')
end
pinv(A::AbstractMatrix{T}, tol::Real) where T = nullspace(A, rtol=tol) # TODO: deprecate tol in 2.0
pinv(A::AbstractMatrix{T}, tol::Real) where T = pinv(A, rtol=tol) # TODO: deprecate tol in 2.0
function pinv(x::Number)
xi = inv(x)
return ifelse(isfinite(xi), xi, zero(xi))
Expand All @@ -1285,7 +1285,7 @@ end
## Basis for null space

"""
nullspace(M, atol::Real, rtol::Real)
nullspace(M; atol::Real, rtol::Real)
nullspace(M[, tol::Real]) = nullspace(M, rtol=tol)

Computes a basis for the nullspace of `M` by including the singular
Expand Down