Skip to content

Commit e064d24

Browse files
committed
use atol=0 and rely on promotion in max to generate the correct fp type
1 parent 2d6219f commit e064d24

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/dense.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,7 @@ julia> M * N
17661766
17671767
[^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)
17681768
"""
1769-
function pinv(A::AbstractMatrix{T}; atol::Real = float(real(zero(T))), rtol::Real = (eps(real(float(oneunit(T))))*min(size(A)...))*iszero(atol)) where T
1769+
function pinv(A::AbstractMatrix{T}; atol::Real=0, rtol::Real = (eps(real(float(oneunit(T))))*min(size(A)...))*iszero(atol)) where T
17701770
m, n = size(A)
17711771
Tout = typeof(zero(T)/sqrt(oneunit(T) + oneunit(T)))
17721772
if m == 0 || n == 0
@@ -1834,7 +1834,7 @@ julia> nullspace(M, atol=0.95)
18341834
1.0
18351835
```
18361836
"""
1837-
function nullspace(A::AbstractVecOrMat; atol::Real = 0.0, rtol::Real = (min(size(A, 1), size(A, 2))*eps(real(float(oneunit(eltype(A))))))*iszero(atol))
1837+
function nullspace(A::AbstractVecOrMat; atol::Real=0, rtol::Real = (min(size(A, 1), size(A, 2))*eps(real(float(oneunit(eltype(A))))))*iszero(atol))
18381838
m, n = size(A, 1), size(A, 2)
18391839
(m == 0 || n == 0) && return Matrix{eigtype(eltype(A))}(I, n, n)
18401840
SVD = svd(A; full=true)

src/svd.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ and `ϵ` is the [`eps`](@ref) of the element type of `S`.
271271
!!! compat "Julia 1.12"
272272
The `rank(::SVD)` method requires at least Julia 1.12.
273273
"""
274-
function rank(S::SVD; atol::Real = 0.0, rtol::Real = (min(size(S)...)*eps(real(float(eltype(S))))))
274+
function rank(S::SVD; atol::Real=0, rtol::Real = (min(size(S)...)*eps(real(float(eltype(S))))))
275275
tol = max(atol, rtol*S.S[1])
276276
count(>(tol), S.S)
277277
end
@@ -289,7 +289,7 @@ dropping any singular values less than `max(atol, rtol*σ₁)` where `σ₁` is
289289
The default relative tolerance is `n*ϵ`, where `n` is the size of the smallest dimension of `M`, and
290290
`ϵ` is the [`eps`](@ref) of the element type of `M`.
291291
"""
292-
function ldiv!(F::SVD{T}, B::AbstractVecOrMat; atol::Real = float(real(zero(T))), rtol::Real = (eps(real(float(oneunit(T))))*min(size(F)...))*iszero(atol)) where T
292+
function ldiv!(F::SVD{T}, B::AbstractVecOrMat; atol::Real=0, rtol::Real = (eps(real(float(oneunit(T))))*min(size(F)...))*iszero(atol)) where T
293293
m, n = size(F)
294294
k = _count_svdvals(F.S, atol, rtol)
295295
if k == 0
@@ -300,7 +300,7 @@ function ldiv!(F::SVD{T}, B::AbstractVecOrMat; atol::Real = float(real(zero(T)))
300300
return B
301301
end
302302

303-
function pinv(F::SVD{T}; atol::Real = float(real(zero(T))), rtol::Real = (eps(real(float(oneunit(T))))*min(size(F)...))*iszero(atol)) where T
303+
function pinv(F::SVD{T}; atol::Real=0, rtol::Real = (eps(real(float(oneunit(T))))*min(size(F)...))*iszero(atol)) where T
304304
k = _count_svdvals(F.S, atol, rtol)
305305
@views (F.S[1:k] .\ F.Vt[1:k, :])' * F.U[:,1:k]'
306306
end

0 commit comments

Comments
 (0)