Get truncation error when using apply

Hi,

I have a basic question about the apply function.

I’m using the apply function to apply a set of (two-qubit) unitaries to an MPS, and I’m setting a maximal bond dimension and cutoff. I was wondering if it’s possible to get the discarded weight returned? (Say vector of or sum of all epsilons from the SVDs used for applying the gates, where epsilon is the the sum of discarded singular values in the usual sense)

I tried looking in to the function in the source code, here, but I’m getting lost where the actual truncation is happening, specifically in the lines 2169-2170:

ϕ = product(o, ϕ; apply_dag = apply_dag)
ψ[ns′[1]:ns′[end], kwargs…] = ϕ

Could you perhaps explain to me what is happening here?

Thank you very much,

Best,
David

That line of code calls this function: ITensorMPS.jl/src/abstractmps.jl at c01cba6bb23f1db51cc51d81e6c6863abf051d7d · ITensor/ITensorMPS.jl · GitHub which factorizes the input ITensor and inserts it into the specified ranges of sites of the MPS.

The factorization of the ITensor into an MPS is performed in this function/constructor call: ITensorMPS.jl/src/abstractmps.jl at c01cba6bb23f1db51cc51d81e6c6863abf051d7d · ITensor/ITensorMPS.jl · GitHub