I am curious about the purpose of various actions and parameters within the replacebond! function in src/mps/mps.jl. Some of these things don't have obvious use in the code, or I tried to look into the ITensors.jl code for them but didn't get much clarity. Since I am trying to make modified versions of this function for various purposes, I thought I should make sure I understand all of the parts.
(1) What is the purpose of spec, and of the Spectrum object type more generally? I see that spec comes from the factorization "L,R,spec = factorize(...)", and I see that it is returned at the end of the replacebond! function, but what is it supposed to accomplish? In particular, when the dmrg function calls replacebond!, it doesn't use spec for anything, as far as I can tell.
(2) I see that the normalize parameter is set to false by default. Under what circumstances would one likely wish to set it to true, and in such situations, what is it meant to accomplish? I see the lines of the form "normalize && (M[b] ./= norm(M[b]))" near the end of the method, but it's not clear to me when we should be using this and why by default we choose not to.
(3) What is the purpose of setleftlim! and setrightlim!, and more broadly, what is the purpose of leftlim and rightlim at all? I see lines of the form "leftlim(M) == b-1 && setleftlim!(M, leftlim(M)+1)" near the end of the method, but again, it's not clear to me why we are doing this. I notice that we increase leftlim(M) and rightlim(M) by 1 when ortho == "left" and decrease both by 1 when ortho == "right", so that part makes sense (i.e. sweeping to the left versus sweeping to the right). But what is this trying to achieve? And in general, what values are leftlim(M) and rightlim(M) supposed to be in a given situation?