# Empty MPS; how to enter coefficients

Hello,

I have been working with ITensors for a while however now I have an analytic expression that I want to write down as an MPS. I want the MPS to have bond dimension 1 so in the end it should be almost like a direct sum of vectors. I have created the empty MPS without a problem however it seems that I cannot access the coefficients inside the MPS in order to fill them. I have tried to do so in several ways: assuming that the MPS is an array and trying to entering it by hand, …
Sometimes it seems it that the program is executed properly however when I try to compute any quantity (such as norm) it returns me 0.0 or empty which is not the correct answer.

I am attaching how do I create the MPS just in case.

Thank you.


Nlegs = 3
indices = siteinds(2, Nlegs)
T = MPS(indices; linkdims = 1)

1 Like

Hi Aleix,

Here is an example code that sets the tensors of an MPS from a collection of vectors (eventually we should make this a built-in function for ITensor):

  N = 10
vecs = randn(N,2)

s = siteinds("Qubit",N)

psi = MPS(s)
for j=1:N
psi[j] = ITensor(vecs[j,:],s[j])
end
orthogonalize!(psi,1)


Here my “vecs” are just an N \times 2 random matrix for convenience, but you can of course pass any vectors v you want to the ITensor constructor like ITensor(v,s[j]).

The reason for the orthogonalize! call at the end is to put in the link indices, since some other parts of ITensor can throw errors if MPS don’t have those put in. Lastly you might want to normalize your MPS (or not) as desired, and you can call normalize!(psi) to do this.

1 Like

Thank you Miles, I think that will solve the issue!

1 Like

Great!

1 Like