0
$\begingroup$

I am constructing generic circuits, and I would like to change the qubits after creating the circuits. Is there a way in cirq to do so? for instance:

circuit = cirq.Circuit(cirq.X.on(cirq.GridQubit(0, 1)))

and I would like this circuit to be transformed into:

cirq.Circuit(cirq.X.on(cirq.GridQubit(5, 7)))
$\endgroup$

1 Answer 1

0
$\begingroup$

To change the qubit, there is a method associated with the circuit object that allow you to change the qubits:

circuit = cirq.Circuit(cirq.X.on(cirq.GridQubit(0, 1)))

# transforming the qubits
qubit_map =  {cirq.GridQubit(0, 1): cirq.GridQubit(5, 7)}
circuit = circuit.transform_qubits(qubit_map =qubit_map)

will return the circuit where only the qubits are changed:

cirq.Circuit(cirq.X.on(cirq.GridQubit(5, 7)))
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.