def __init__(self, wires, qsimh_options, shots=1000, analytic=True, qubits=None): super().__init__(wires, shots, analytic, qubits) self.circuit = None self.qsimh_options = qsimh_options self._simulator = qsimcirq.QSimhSimulator(qsimh_options)
def test_cirq_qsimh_simulate(): # Pick qubits. a, b = [cirq.GridQubit(0, 0), cirq.GridQubit(0, 1)] # Create a circuit cirq_circuit = cirq.Circuit(cirq.CNOT(a, b), cirq.CNOT(b, a), cirq.X(a)) qsimh_options = {'k': [0], 'w': 0, 'p': 1, 'r': 1} qsimhSim = qsimcirq.QSimhSimulator(qsimh_options) result = qsimhSim.compute_amplitudes( cirq_circuit, bitstrings=[0b00, 0b01, 0b10, 0b11]) assert np.allclose(result, [0j, 0j, (1 + 0j), 0j])
def test_cirq_qsimh_simulate(self): # Pick qubits. a, b = [cirq.GridQubit(0, 0), cirq.GridQubit(0, 1)] # Create a circuit cirq_circuit = cirq.Circuit(cirq.CNOT(a, b), cirq.CNOT(b, a), cirq.CZ(a, b)) qsim_circuit = qsimcirq.QSimCircuit(cirq_circuit) qsimh_options = {'k': [0], 'w': 0, 'p': 1, 'r': 1} qsimhSim = qsimcirq.QSimhSimulator(qsimh_options) result = qsimhSim.compute_amplitudes( qsim_circuit, bitstrings=['00', '01', '10', '11']) self.assertSequenceEqual(result, [(1 + 0j), 0j, 0j, 0j])