-
Notifications
You must be signed in to change notification settings - Fork 944
Cirq Backend
Trevor Grant edited this page Aug 16, 2024
·
1 revision
This section covers the usage of the Cirq backend in the QuMat library.
To initialize the Cirq backend, use the initialize_backend
function. This function accepts a backend_config
dictionary.
from qumat.cirq_backend import initialize_backend
backend_config = {
'backend_options': {
'simulator_type': 'default'
}
}
backend = initialize_backend(backend_config)
To create an empty circuit, use the create_empty_circuit function.
from qumat.cirq_backend import create_empty_circuit
circuit = create_empty_circuit(num_qubits=2)
To apply different quantum gates, use the following functions:
from qumat.cirq_backend import apply_not_gate
apply_not_gate(circuit, qubit_index=0)
from qumat.cirq_backend import apply_hadamard_gate
apply_hadamard_gate(circuit, qubit_index=0)
from qumat.cirq_backend import apply_cnot_gate
apply_cnot_gate(circuit, control_qubit_index=0, target_qubit_index=1)
To execute the circuit, use the execute_circuit function.
from qumat.cirq_backend import execute_circuit
result = execute_circuit(circuit, backend, backend_config)
print(result)