示例#1
0
    def test_hadamard_pauli_identities(self):
        X = qc.PauliX()
        Y = qc.PauliY()
        Z = qc.PauliZ()
        H = qc.Hadamard()

        self.assertLess(max_absolute_difference(H(X(H)), Z), epsilon)
        self.assertLess(max_absolute_difference(H(Z(H)), X), epsilon)
        self.assertLess(max_absolute_difference(H(Y(H)), -Y), epsilon)
        self.assertLess(max_absolute_difference(X(Y(X)), -Y), epsilon)
示例#2
0
    def test_rotations_equal_pauli(self):
        X = qc.PauliX()
        Y = qc.PauliY()
        Z = qc.PauliZ()
        Rx = qc.RotationX(np.pi)
        Ry = qc.RotationY(np.pi)
        Rz = qc.RotationZ(np.pi)

        self.assertLess(max_absolute_difference(1j * Rx, X), epsilon)
        self.assertLess(max_absolute_difference(1j * Ry, Y), epsilon)
        self.assertLess(max_absolute_difference(1j * Rz, Z), epsilon)
示例#3
0
    def test_pauli_identities(self):
        X = qc.PauliX()
        Y = qc.PauliY()
        Z = qc.PauliZ()

        self.assertLess(max_absolute_difference(X(Y), 1j * Z), epsilon)
        self.assertLess(max_absolute_difference(Y(X), -1j * Z), epsilon)
        self.assertLess(max_absolute_difference(Y(Z), 1j * X), epsilon)
        self.assertLess(max_absolute_difference(Z(Y), -1j * X), epsilon)
        self.assertLess(max_absolute_difference(Z(X), 1j * Y), epsilon)
        self.assertLess(max_absolute_difference(X(Z), -1j * Y), epsilon)