From 34cbddbe880c36a962d5012960826866e84e6970 Mon Sep 17 00:00:00 2001 From: lkdvos Date: Fri, 28 Jun 2024 11:47:21 +0200 Subject: [PATCH] Soften type restrictions on tsvd kwargs --- src/tensors/factorizations.jl | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/tensors/factorizations.jl b/src/tensors/factorizations.jl index 524e2760..fd117e5b 100644 --- a/src/tensors/factorizations.jl +++ b/src/tensors/factorizations.jl @@ -413,19 +413,18 @@ end #------------------------------# # Singular value decomposition # #------------------------------# -function tsvd!(t::AdjointTensorMap; - trunc::TruncationScheme=NoTruncation(), - p::Real=2, - alg::Union{SVD,SDD}=SDD()) +# allow kwargs to select the algorithm +function tsvd!(t::AdjointTensorMap; trunc=NoTruncation(), p::Real=2, alg=SDD()) u, s, vt, err = tsvd!(adjoint(t); trunc=trunc, p=p, alg=alg) return adjoint(vt), adjoint(s), adjoint(u), err end +function tsvd!(t::TensorMap; trunc=NoTruncation(), p::Real=2, alg=SDD()) + return _tsvd!(t, alg, trunc, p) +end -function tsvd!(t::TensorMap; - trunc::TruncationScheme=NoTruncation(), - p::Real=2, - alg::Union{SVD,SDD}=SDD()) - #early return +# implementation dispatches on algorithm +function _tsvd!(t, alg::Union{SVD,SDD}, trunc::TruncationScheme, p::Real=2) + # early return if isempty(blocksectors(t)) truncerr = zero(real(scalartype(t))) return _empty_svdtensors(t)..., truncerr