Swap Gate

The SWAP gate is two-qubit operation. Expressed in basis states, the SWAP gate swaps the state of the two qubits involved in the operation:

 SWAP=(1000001001000001)\ SWAP = \begin{pmatrix} 1 & 0 & 0 & 0 \ 0 & 0 & 1 & 0 \ 0 & 1 & 0 & 0 \ 0 & 0 & 0 & 1 \end{pmatrix}

        
          version 1.0
qubits 2
X q[0]
H q[1]
display # display state before swap operation
SWAP q[0], q[1]
display # display state after swap operation
        
      
q[0]
 
 
 
q[1]