We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b87fd55 commit ec09e25Copy full SHA for ec09e25
src/svd.jl
@@ -639,6 +639,8 @@ function LinearAlgebra.svd!(
639
# To avoid breaking on <Julia 1.3, the `alg` keyword doesn't do anything. Once we drop support for Julia 1.2
640
# and below, we can make the keyword argument work correctly
641
alg = nothing,
642
+ atol = 0,
643
+ rtol = 0
644
) where {T}
645
646
m, n = size(A)
@@ -660,6 +662,13 @@ function LinearAlgebra.svd!(
660
662
rmul!(Vᴴ, BF.rightQ')
661
663
664
s = F.S
665
+ s[_count_svdvals(s, atol, rtol)+1:end] .= 0
666
667
return SVD(U, s, Vᴴ)
668
end
669
+
670
+function _count_svdvals(S, atol::Real, rtol::Real)
671
+ isempty(S) && return 0
672
+ tol = max(rtol * S[1], atol)
673
+ return iszero(S[1]) ? 0 : searchsortedlast(S, tol, rev=true)
674
+end
0 commit comments