Question on creating an MPO

A very convenient way to make a controlled gate like CNOT as an MPO using ITensor is to use our “OpSum” system. Here’s an example:

  n = 10 # 10 qubits, no problem to do more
  s = siteinds("Qubit",n)
  i = 3 # i will be the "control" site
  j = 7 # j will be the site where the gate acts 

  cnot = OpSum()
  cnot += "Proj0",i,"Id",j
  cnot += "Proj1",i,"X",j
  CNOT = MPO(cnot,s)

The above is using the following way of writing the CNOT gate:

CNOT_{i,j} = \ket{0}_i \bra{0}_i \otimes I_j + \ket{1}_i \bra{1}_i \otimes X_j

and the fact that the Pauli X operator is identical to the NOT single-qubit gate.