+1 vote
asked by (170 points)

In the iTensor documentation, a default projective operator is mentioned, with the example code

auto sites = SpinHalf(N);
//Projects site 3 onto state 2 (i.e. the down state)
auto P3_2 = op(sites,"Proj",3,{"State",2});

However, I'm confused as to what form this operator is in, and how it can be actually applied to a spin-half MPS. Treating P3_2 as an MPO and running applyMPO(P3_2, psi) gives an error, as are my attempts to package P3_2 into an AutoMPO object somehow. What does the intended usage of these operators look like?

1 Answer

+2 votes
answered by (14.1k points)
selected by
Best answer


You would apply it by contracting it with an MPS that has the indices sites, i.e.:

psi(3) *= P3_2;
psi(3).noPrime();  // To make the site index unprimed again

It can help to print objects that you are unsure about, for example with:


you can see that it is an ITensor with a pair of unprimed and primed indices.


Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.