Пример #1
0
 def test_optimize(self):
     """test optimize
     """
     qc = QCirc.generate_random_gates(qubit_num=10,
                                      gate_num=100,
                                      prob={
                                          'h': 5,
                                          'cx': 5,
                                          't': 3
                                      })
     qc_opt = qc.optimize()
     self.assertEqual(qc_opt is not None, True)
Пример #2
0
 def test_generate_random_gates(self):
     """test get_gates, add_gates
     """
     qc = QCirc.generate_random_gates(qubit_num=3,
                                      gate_num=1000,
                                      prob={
                                          'h': 5,
                                          'cx': 3,
                                          't': 2
                                      })
     stats = qc.get_stats()
     self.assertEqual(round(stats['gate_freq']['h'] / 100.), 5)
     self.assertEqual(round(stats['gate_freq']['cx'] / 100.), 3)
     self.assertEqual(round(stats['gate_freq']['t'] / 100.), 2)
Пример #3
0
def main():

    qc = QCirc.generate_random_gates(qubit_num=5,
                                     gate_num=10,
                                     phase=(0.0, 0.25, 0.5),
                                     prob={
                                         'h': 7,
                                         'cx': 5,
                                         'rx': 3,
                                         'crz': 3
                                     })
    qc += QCirc().measure(qid=list(range(5)), cid=list(range(5)))
    qc += QCirc().h(0).x(0, ctrl=3).h(1).measure(qid=[2, 1], cid=[10, 4])
    print(qc)
    print()

    qc.show()