Jutho/TensorKit.jl

More efficient support for tsvd

adrilow opened this issue · 1 comments

See tensors/factorizations.jl , 415:425

for (c, b) in blocks(t)
        U, Σ, V = _svd!(b, alg)
        Udata[c] = U
        Vdata[c] = V
        if @isdefined Σdata # cannot easily infer the type of Σ, so use this construction
            Σdata[c] = Σ
        else
            Σdata = SectorDict(c=>Σ)
        end
        dims[c] = length(Σ)
    end

This code gets executed unconditionally, independently of the truncation parameter, so the full svd is always computed. Is there a way to only calculate the biggest singular values, until truncdim, without calculating the rest? Similar to what the LowRankApprox.jl package does.

Jutho commented

Not with the current functionality, tsvd is really supposed to be the counterpart to full svd, but with some more options, and an interface that I find better suited for tensors.

Under the hood, any TensorMap is a block diagonal matrix (depending on how you want to partition the indices in left and right / domain and codomain). Any of the methods in LowRankApprox.jl could be applied to those dense matrices on the diagonal. But for many use of our use cases, the truncation really throws away only a fraction of the singular values, and first computing all of them seems like the most efficient strategy.

Nonetheless, I agree that there are other use cases where methods from LowRankApprox.jl could be useful.