
q a b -> a b⊕a class TwoQubit:
0 0 0 0 0 def cnot(self):
1 0 1 0 1 '''Controlled NOT operation'''
2 1 0 1 1 self.onezero, self.oneone = self.oneone, self.onezero
3 1 1 1 0 return self
Using an array: Using names for the complex amplitudes:
q[0], q[1], q[2], q[3] zerozero, zeroone, onezero, oneone
swap q[2] and q[3] Python Quantum Computing simulator, Juliana Peña, 2011.