@@ -92,7 +92,6 @@ function gesvdx_batched!(::ROCSOLVER, As::AbstractVector{<:StridedROCMatrix}, Ss
9292 else
9393 YArocSOLVER. gesvdx_batched! (As, Ss, Us, Vᴴs; kwargs... )
9494 end
95- _complete_svd_basis_batched! (Us, Vᴴs, size (Ss, 1 ))
9695 return Ss, Us, Vᴴs
9796end
9897function gesvdx_batched! (:: ROCSOLVER , As:: StridedROCArray{T, 3} , Ss:: StridedROCMatrix , Us:: StridedROCArray{T, 3} , Vᴴs:: StridedROCArray{T, 3} ; kwargs... ) where {T <: BlasFloat }
@@ -101,30 +100,27 @@ function gesvdx_batched!(::ROCSOLVER, As::StridedROCArray{T, 3}, Ss::StridedROCM
101100 else
102101 YArocSOLVER. gesvdx_strided_batched! (As, Ss, Us, Vᴴs; kwargs... )
103102 end
104- _complete_svd_basis_batched! (Us, Vᴴs, size (Ss, 1 ))
105103 return Ss, Us, Vᴴs
106104end
107105
108- function _complete_svd_basis_batched! (Us:: StridedROCArray{<:Any, 3} , Vᴴs:: StridedROCArray{<:Any, 3} , minmn:: Int )
109- (size (Us, 2 ) == size (Us, 1 ) && size (Vᴴs, 1 ) == size (Vᴴs, 2 )) || return Us, Vᴴs
110- for b in axes (Us, 3 )
111- complete_svd_basis! (view (Us, :, :, b), view (Vᴴs, :, :, b), minmn)
112- end
113- return Us, Vᴴs
114- end
115-
116106gesdd! (:: ROCSOLVER , A:: StridedROCMatrix , S:: StridedROCVector , U:: StridedROCMatrix , Vᴴ:: StridedROCMatrix ; kwargs... ) =
117107 YArocSOLVER. gesdd! (A, S, U, Vᴴ; kwargs... )
118108
119109function _gesvdx_rank1! (A:: StridedROCMatrix , S:: StridedROCVector , U:: StridedROCMatrix , Vᴴ:: StridedROCMatrix ; kwargs... )
120110 select_kwargs = Base. structdiff (NamedTuple (kwargs), (; irange = nothing , vl = nothing , vu = nothing ))
121- S[:] .= norm (A)
122- if m == 1
123- Vᴴ .= A ./ S
124- U .= 1
125- else
126- U .= A ./ S
127- Vᴴ .= 1
111+ nrmA = norm (A)
112+ fill! (S, nrmA)
113+ if ! isempty (U) && ! isempty (Vᴴ)
114+ u, v = view (U, :, 1 ), view (Vᴴ, 1 , :)
115+ x, e = size (A, 1 ) == 1 ? (v, u) : (u, v)
116+ if iszero (nrmA)
117+ zero! (x)
118+ fill! (view (x, 1 : 1 ), one (eltype (x)))
119+ else
120+ copyto! (x, vec (A))
121+ x ./= nrmA
122+ end
123+ fill! (e, one (eltype (e)))
128124 end
129125 _gesvdx_apply_range! (S, select_kwargs)
130126 return S, U, Vᴴ
0 commit comments