Create MPS from Array - Constructor searched in source code

Dear ITensor Team,
I am quite new to both Julia and ITensor so please excuse if the question is to basic.
I want to write some own code around ITensor, as I need some extra functionalities. That’s the reason why I try to understand how some of ITensors Building-Blocks look like and how the logic works.

From this example I know that I can create an MPS from a Julia Array using SVD. I tried this and it works perfectly.
MPS and MPO Examples · ITensors.jl

However, I struggle to find the source code snippit responsible for this way of creating an MPS.
(I saw all different types in mps.jl but couldn’t identify this one).
It would be highly appreciated if you could tell me where to find it.

Best regards

You can find the code for that feature here:

The main “workhorse” of that function is the call to factorize on line 1954, which either does an SVD internally or a “density matrix factorization” (using an eigenvalue decomposition) depending on the parameters passed to the function.

I’m not surprised you couldn’t find it given the file it is in and the way it is written in a very “generic” style. To find that function, I used the @edit macro in the Julia REPL console, which opens a file editor jumping to the line of code that defines the function you are calling.

Thank you very much.
Especially the hint with @edit will make following questions of this kind obsolete, hopefully :slight_smile:

1 Like