File: teleport.py

package info (click to toggle)
pyscript 0.6.1-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 1,428 kB
  • ctags: 1,175
  • sloc: python: 10,146; makefile: 67
file content (46 lines) | stat: -rwxr-xr-x 944 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env pyscript

# $Id: teleport.py,v 1.3 2006/02/14 14:23:09 paultcochrane Exp $

"""
Create a quantum circuit of a quantum teleporter using the qi library
"""

# import the pyscript libraries
from pyscript import *
from pyscript.lib.qi import *

# Assemble the quantum circuit
g = Assemble(
        SWAP, 1, 2,
        NOT, 2, 1,
        H, 1,
        X, 3, 2,
        Z, 3, 1,
        hang=.5,
        wires=[QWire, QWire, QWire],
        )

# define the object for the wires
w = g.wires

# render the diagram
render(
        # the main circuit
        g,

        # some labels
        TeX(r'$|\psi\rangle$', e=w[0].w),
        TeX(r'$|\psi\rangle$', w=w[2].e),
        TeX(r'$|\beta_{00}\rangle\left\{\rule{0cm}{7mm}\right.$',
            e=(w[2].w+w[1].w)/2.),

        # the meters
        Meter(w=w[0].e),
        Meter(w=w[1].e),

        # the output file
        file="teleport.eps"
        )

# vim: expandtab shiftwidth=4: