def test_swap_qubits(self, sparse): a = qu.up() & qu.down() s = qu.swap(2, sparse=sparse) assert_allclose(s @ a, qu.down() & qu.up())
def test_swap_higher_dim(self, sparse): a = qu.rand_ket(9) s = qu.swap(3, sparse=sparse) assert_allclose(s @ a, a.reshape([3, 3]).T.reshape([9, 1]))
def test_swap_qubits(self, sparse): a = up() & down() s = swap(2, sparse=sparse) assert_allclose(s @ a, down() & up())