Skip to content

Commit cab77e1

Browse files
committed
avoid double-copy of svd functions
1 parent e5cfa3e commit cab77e1

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/implementations/svd.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,16 @@ function svd_vals!(A::AbstractMatrix, S, alg::LAPACK_SVDAlgorithm)
232232
return S
233233
end
234234

235+
# avoid double allocation
236+
for f in (:svd_compact, :svd_full, :svd_vals)
237+
f! = Symbol(f, :!)
238+
@eval $f(A, alg::LAPACK_SafeDivideAndConquer) = $f!(A, alg)
239+
end
240+
for f in (:svd_trunc, :svd_trunc_no_error)
241+
f! = Symbol(f, :!)
242+
@eval $f(A, alg::TruncatedAlgorithm{<:LAPACK_SafeDivideAndConquer}) = $f!(A, alg)
243+
end
244+
235245
function svd_trunc_no_error!(A, USVᴴ, alg::TruncatedAlgorithm)
236246
U, S, Vᴴ = svd_compact!(A, USVᴴ, alg.alg)
237247
USVᴴtrunc, ind = truncate(svd_trunc!, (U, S, Vᴴ), alg.trunc)

0 commit comments

Comments
 (0)