Skip to content

Commit

Permalink
Soften type restrictions on tsvd kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Jun 28, 2024
1 parent 8b41fe3 commit 34cbddb
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/tensors/factorizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 34cbddb

Please sign in to comment.