https://github.com/ProjectQ-Framework/ProjectQ
Raw File
Tip revision: f26198ad231a8e111f953b15b8133c88cac1135d authored by Nguyen Damien on 02 April 2024, 20:28:54 UTC
Merge pull request #469 from ProjectQ-Framework/pre-commit-ci-update-config
Tip revision: f26198a
teleport_circuit.py
# pylint: skip-file

"""Example if drawing of a quantum teleportation circuit."""

import teleport

from projectq import MainEngine
from projectq.backends import CircuitDrawer

if __name__ == "__main__":
    # create a main compiler engine with a simulator backend:
    drawing_engine = CircuitDrawer()
    locations = {0: 1, 1: 2, 2: 0}
    drawing_engine.set_qubit_locations(locations)
    eng = MainEngine(drawing_engine)

    # we just want to draw the teleportation circuit
    def create_state(eng, qb):
        """Create a quantum state."""

    # run the teleport and then, let Bob try to uncompute his qubit:
    teleport.run_teleport(eng, create_state, verbose=False)

    # print latex code to draw the circuit:
    print(drawing_engine.get_latex())
back to top