Confused on the documentation

N = 10

I am trying to apply these predefined gates for S=1/2 site type.

s = siteinds("S=1/2", N)
psi_start = MPS(s,"Up")
    H1 = op("H",s[1])
    psi1=apply(H1,psi_start)
    cnt12=op("CNOT", s[1:2]);
    psi=apply(cnt12,psi1);
    H4=op("H",s[4]);
    cnt45=op("CNOT", s[4:5]);
    psin=apply(H4,psi);
    psif=apply(cnt45,psin)

All of these work but I am confused on the documentation about the operators

  • "Rx" (takes argument: θ) Rotation around x axis
  • "Ry" (takes argument: θ) Rotation around y axis
  • "Rz" (takes argument: θ) Rotation around z axis
  • "Rn" (takes arguments: θ, ϕ, λ) (aliases: "Rn̂") Rotation about axis n=(θ, ϕ, λ)

where am I supposed to put these angles?
I tried

rxpi=op("Rx",s[3], pi/2)

and all other permutation of order of these “Rx”, s[3] and pi/2 but everything gives error.
Sorry for really stupid question. I would like to know how to properly use "Rn" as well.

No problem – I could see myself confused by this also. We should add some explicit examples to the documentation there. The kind of arguments referred to there are keyword arguments to the op function. Here are some examples:

rxpi=op("Rx",s[3];θ=pi/2)
Rn = op("Rn",s[4]; θ=0.2, ϕ=0.0, λ=pi/4)

Note the semicolon also, denoting the beginning of the keyword arguments. It’s not required in Julia but I would recommend it and it can resolve otherwise ambiguous cases.

Thank you

1 Like