Skip to content

Instantly share code, notes, and snippets.

@nathanshammah
Created May 17, 2019 15:13
Show Gist options
  • Save nathanshammah/6ad41ed5c88aec5f37e10eff16866d37 to your computer and use it in GitHub Desktop.
Save nathanshammah/6ad41ed5c88aec5f37e10eff16866d37 to your computer and use it in GitHub Desktop.
qcircuit
from qutip import *
q = QubitCircuit(3, reverse_states=False)
q.add_gate("TOFFOLI", controls=[0, 2], targets=[1])
q.add_gate("CNOT", targets=[1], controls=[0])
display("q",q.png)
q.add_gate("TOFFOLI", controls=[0, 2], targets=[1])
display("q updated",q.png)
q2 = QubitCircuit(3, reverse_states=False)
q2.add_gate("TOFFOLI", controls=[0, 2], targets=[1])
q2.add_gate("TOFFOLI", controls=[0, 2], targets=[1])
display("q2",q2.png)
q2.add_gate("CNOT", targets=[1], controls=[0], index=[1])
display("q2 updated",q2.png)
U = gate_sequence_product(q.propagators())
U2 = gate_sequence_product(q2.propagators())
U==U2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment