# Visiting MPS elements

+1 vote

Dear ITensor family,

I want to access a specific element of MPS, for example:
How to obtain the value of $\psi _{1,1,...,1}$ from the general $\psi _{s1,s2,...,sn}$. Is there have such function?

Best,
Meng

Hi Meng,
Good question. We should have some examples for that. I'll probably soon make a built-in function that helps with this too.

Please take a look at this new 'code formula' I just posted on the ITensor website with example code showing you how to do the thing you are asking about. I'd appreciate any feedback you may have, such as if you have any questions about it:

http://itensor.org/docs.cgi?vers=cppv3&page=formulas/mps_element

commented by (70.1k points)
Note that in the code the function setElt makes an ITensor which has a single non-zero element equal to 1 (so like a standard basis vector) with the given index value supplied. I’ll expand the writing on the webpage to discuss aspects of the code a bit more.