Esempio n. 1
0
 def test_single_qubit_gate_decomposition(self):
     for i in range(24):
         CL = tqc.SingleQubitClifford(i)
         gate_dec = CL.gate_decomposition
         self.assertTrue(isinstance(gate_dec, list))
         for g in gate_dec:
             self.assertTrue(isinstance(g[0], str))
             self.assertTrue(g[1] == 'q0')
Esempio n. 2
0
 def test_gate_decomposition_unique_single_qubit(self):
     hash_table = []
     for i in range(24):
         CL = tqc.SingleQubitClifford(i)
         gate_dec = CL.gate_decomposition
         hash_table.append(crc32(bytes(str(gate_dec), 'utf-8')))
     self.assertTrue(len(hash_table) == 24)
     self.assertTrue(len(np.unique(hash_table)) == 24)
Esempio n. 3
0
    def test_single_qubit_hashtable_file(self):
        hash_table = tqc.get_single_qubit_clifford_hash_table()

        for i in range(24):
            Cl = tqc.SingleQubitClifford(i)
            target_hash = crc32(Cl.pauli_transfer_matrix.round().astype(int))
            table_idx = hash_table.index(target_hash)
            self.assertTrue(table_idx == i)
Esempio n. 4
0
 def test_single_qubit_hashtable_constructed(self):
     hash_table = construct_clifford_lookuptable(tqc.SingleQubitClifford,
                                                 np.arange(24))
     for i in range(24):
         Cl = tqc.SingleQubitClifford(i)
         target_hash = crc32(Cl.pauli_transfer_matrix.round().astype(int))
         table_idx = hash_table.index(target_hash)
         self.assertTrue(table_idx == i)
Esempio n. 5
0
    def test_get_clifford_id(self):
        for i in range(24):
            Cl = tqc.SingleQubitClifford(i)
            idx = tqc.get_clifford_id(Cl.pauli_transfer_matrix)
            self.assertTrue(idx == Cl.idx)

        for i in test_indices_2Q:
            Cl = tqc.TwoQubitClifford(i)
            idx = tqc.get_clifford_id(Cl.pauli_transfer_matrix)
            self.assertTrue(idx == Cl.idx)
Esempio n. 6
0
    def test_products(self):
        Cl_3 = tqc.SingleQubitClifford(3)
        Cl_3*Cl_3
        self.assertTrue(Cl_3.idx == 3)  # Pauli X
        self.assertTrue((Cl_3*Cl_3).idx == 0)  # The identity

        Cl_3 = tqc.TwoQubitClifford(3)
        self.assertTrue(Cl_3.idx == 3)  # Pauli X on q0
        self.assertTrue((Cl_3*Cl_3).idx == 0)  # The identity
        product_hash = crc32((Cl_3*Cl_3).pauli_transfer_matrix.round().astype(int))
        target_hash = crc32(tqc.TwoQubitClifford(0).pauli_transfer_matrix.round().astype(int))
        self.assertTrue(product_hash == target_hash)
Esempio n. 7
0
 def test_inverse_single_qubit_clifford(self):
     for i in range(24):
         Cl = tqc.SingleQubitClifford(i)
         Cl_inv = Cl.get_inverse()
         self.assertTrue((Cl_inv*Cl).idx == 0)