From 07dd4c7fc8feedf1a82c65497b02d9d20620714d Mon Sep 17 00:00:00 2001 From: Dominique Date: Tue, 15 Jul 2025 16:12:25 -0400 Subject: [PATCH] svd!: allow lower bidiagonal Close JuliaLinearAlgebra/TSVD.jl#33 TSVD requires the SVD of a lower bidiagonal matrix. If the element type is not one supported by LAPACK and if GenericLinearAlgebra is imported, the call dispatches to it. However, GenericLinearAlgebra only implements the SVD of an *upper* bidiagonal. This PR introduces a helper function to pass the transposed of the bidiagonal if the latter is a lower bidiagonal. As a result, the truncated SVD of a matrix of, say, BigFloat, is now possible. --- src/svd.jl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/svd.jl b/src/svd.jl index 8af3949..2d9fb13 100644 --- a/src/svd.jl +++ b/src/svd.jl @@ -153,13 +153,16 @@ end # The actual SVD solver routine # Notice that this routine doesn't adjust the sign and sorts the values -function __svd!( +function __svd!(B::Bidiagonal{T}, args...; kwargs...) where {T<:Real} + B.uplo == 'U' ? __svd_helper!(B, args...; kwargs...) : __svd_helper!(B', args...; kwargs...) +end + +function __svd_helper!( B::Bidiagonal{T}, U = nothing, Vá´´ = nothing; tol = 100eps(T), ) where {T<:Real} - n = size(B, 1) if n == 0 # Exit early in the empty case