Example #1
0
def main():

    shots = 100
    qc = QCirc()
    qc.h(0).x(0).z(0).s(0).t(0).s_dg(0).t_dg(0).rx(0, phase=0.1).rz(0, phase=0.2)
    qc.cx(0,1).cz(0,1).ch(0,1).crz(0,1, phase=0.3)
    qc.measure(qid=[0,1], cid=[0,1]) # {'00': 50, '10': 25, '11': 25}
    # qc.measure(qid=[0], cid=[0]) # {'0': 50, '1': 59}
    # qc.measure(qid=[1], cid=[1]) # {'00': 75, '01': 25}
    # qc.measure(qid=[0,1], cid=[1,0]) # {'00': 50, '01': 25, '11': 25}
    # qc.measure(qid=[0,1], cid=[1,3]) # {'0000': 50, '0100': 25, '0101': 25}
    # qc.measure(qid=[0,1], cid=[3,1]) # {'0000': 50, '0001': 25, '0101': 25}
    
    bk = Backend()  # OK

    # bk = Backend(product='ibmq', device='aer_simulator') # OK
    # bk = Backend(product='ibmq', device='qasm_simulator') # OK
    # bk = Backend(product='qulacs', device='cpu_simulator') # OK

    # bk = Backend(product='braket_local', device='braket_sv') # OK
    # bk = Backend(product='braket_aws', device='sv1') # OK
    # bk = Backend(product='braket_aws', device='tn1') # OK
    # bk = Backend(product='braket_aws', device='dm1') # OK

    # bk = Backend(product='braket_ionq', device='ionq') # OK
    # bk = Backend(product='braket_rigetti', device='aspen_11')
    # bk = Backend(product='braket_rigetti', device='aspen_m_1') # OK
    # bk = Backend(product='braket_oqc', device='lucy') # OK

    result = bk.run(qcirc=qc, shots=shots)
    result.show(verbose=True)
Example #2
0
    def test_0(self):

        qid_0 = CreateRegister(1)
        qid_1 = CreateRegister(2,2)
        qubit_num = InitRegister(qid_0, qid_1)

        cid_0 = CreateRegister(1)
        cmem_num = InitRegister(cid_0)

        bk = Backend(product='qlazy', device='qstate_simulator')
        qc = QCirc()
        qc.h(qid_0[0])
        qc.cx(qid_0[0], qid_1[0][0]).cx(qid_0[0], qid_1[0][1]).cx(qid_0[0], qid_1[1][0]).cx(qid_0[0], qid_1[1][1])
        qc.h(qid_0[0])
        qc.measure(qid=[qid_0[0]], cid=[cid_0[0]])
        res = bk.run(qcirc=qc, shots=10)
        freq = res.frequency
        self.assertEqual(freq['0']+freq['1'], 10)