0

I have a qutip tensor as follows:

psi = constants*tensor(fock(N,0),fock(N,1),fock(N,2))

I need a way to swap the positions of the third state with the second state such that the structure becomes:

psi = (some operation on psi)
psi = constants*tensor(fock(N,0),fock(N,2),fock(N,1))

I need it to maintain the ket nature of psi, any help is appreciated.

Stal
  • 1
  • 1

1 Answers1

0

You can use the permute() method

N = 10
psi = tensor(fock(N, 0), fock(N, 1), fock(N, 2))
goal_psi = tensor(fock(N, 0), fock(N, 2), fock(N, 1))
new_psi = psi.permute([0, 2, 1])
isequal(new_psi, goal_psi)
Iyán
  • 101
  • 6