Esempio n. 1
0
 def test_inequality_equal(self):
     """Test inequality operator: equal Paulis"""
     p1 = random_pauli(5)
     p2 = deepcopy(p1)
     self.assertFalse(p1 != p2)
     self.log.info(p2.to_label())
     self.log.info(p1.to_label())
     self.log.info(p1 != p2)
Esempio n. 2
0
 def test_random_pauli5(self):
     length = 2
     q = random_pauli(length)
     self.log.info(q)
     self.assertEqual(q.numberofqubits, length)
     self.assertEqual(len(q.v), length)
     self.assertEqual(len(q.w), length)
     self.assertEqual(len(q.to_label()), length)
     self.assertEqual(len(q.to_matrix()), 2 ** length)
Esempio n. 3
0
 def test_inequality_different(self):
     """Test inequality operator: different Paulis"""
     p1 = random_pauli(5)
     p2 = deepcopy(p1)
     p2.v[0] = (p1.v[0] + 1) % 2
     self.assertTrue(p1 != p2)
     self.log.info(p2.to_label())
     self.log.info(p1.to_label())
     self.log.info(p1 != p2)
Esempio n. 4
0
 def test_random_pauli5(self):
     length = 2
     q = random_pauli(length)
     self.log.info(q)
     self.assertEqual(q.numberofqubits, length)
     self.assertEqual(len(q.v), length)
     self.assertEqual(len(q.w), length)
     self.assertEqual(len(q.to_label()), length)
     self.assertEqual(len(q.to_matrix()), 2 ** length)
Esempio n. 5
0
    def test_pauli(self):

        v = np.zeros(3)
        w = np.zeros(3)
        v[0] = 1
        w[1] = 1
        v[2] = 1
        w[2] = 1

        p = Pauli(v, w)
        self.log.info(p)
        self.log.info("In label form:")
        self.log.info(p.to_label())
        self.log.info("In matrix form:")
        self.log.info(p.to_matrix())


        q = random_pauli(2)
        self.log.info(q)

        r = inverse_pauli(p)
        self.log.info("In label form:")
        self.log.info(r.to_label())

        self.log.info("Group in tensor order:")
        grp = pauli_group(3, case=1)
        for j in grp:
            self.log.info(j.to_label())

        self.log.info("Group in weight order:")
        grp = pauli_group(3)
        for j in grp:
            self.log.info(j.to_label())

        self.log.info("sign product:")
        p1 = Pauli(np.array([0]), np.array([1]))
        p2 = Pauli(np.array([1]), np.array([1]))
        p3, sgn = sgn_prod(p1, p2)
        self.log.info(p1.to_label())
        self.log.info(p2.to_label())
        self.log.info(p3.to_label())
        self.log.info(sgn)

        self.log.info("sign product reverse:")
        p3, sgn = sgn_prod(p2, p1)
        self.log.info(p2.to_label())
        self.log.info(p1.to_label())
        self.log.info(p3.to_label())
        self.log.info(sgn)
Esempio n. 6
0
    def test_pauli(self):

        v = np.zeros(3)
        w = np.zeros(3)
        v[0] = 1
        w[1] = 1
        v[2] = 1
        w[2] = 1

        p = Pauli(v, w)
        self.log.info(p)
        self.log.info("In label form:")
        self.log.info(p.to_label())
        self.log.info("In matrix form:")
        self.log.info(p.to_matrix())

        q = random_pauli(2)
        self.log.info(q)

        r = inverse_pauli(p)
        self.log.info("In label form:")
        self.log.info(r.to_label())

        self.log.info("Group in tensor order:")
        grp = pauli_group(3, case=1)
        for j in grp:
            self.log.info(j.to_label())

        self.log.info("Group in weight order:")
        grp = pauli_group(3)
        for j in grp:
            self.log.info(j.to_label())

        self.log.info("sign product:")
        p1 = Pauli(np.array([0]), np.array([1]))
        p2 = Pauli(np.array([1]), np.array([1]))
        p3, sgn = sgn_prod(p1, p2)
        self.log.info(p1.to_label())
        self.log.info(p2.to_label())
        self.log.info(p3.to_label())
        self.log.info(sgn)

        self.log.info("sign product reverse:")
        p3, sgn = sgn_prod(p2, p1)
        self.log.info(p2.to_label())
        self.log.info(p1.to_label())
        self.log.info(p3.to_label())
        self.log.info(sgn)