Пример #1
0
def class_candidates(size):
    """
    Returns an array of integers representing a candidates from each of
    the 16 logical error classes.

    """
    s = st.ToricLattice(size)
    a = np.zeros(16, dtype='int64')
    for i in range(16):
        a[i] = class_candidate(s, i)
    return a
Пример #2
0
def bare_stabiliser_actions(size):
    """
    Returns a numpy array of integers representing error configurations
    generated by action of the bare stabilisers.

    """
    s = st.ToricLattice(size)
    n_bare = size**2 / 2 - 2
    a = np.zeros(n_bare, dtype='int64')
    for i in range(n_bare):
        a[i] = stab_action_for_site(s, i)
    return a
Пример #3
0
def error_candidate_for_syndrome(n, size):
    """
    Return an integer representing an error configuration that will give
    rise to the given syndrome

    0 <= n < 2**(n**2/2 - 2)

    """
    state = st.ToricLattice(size)
    synd = n_to_syndrome(state, n)
    state = st.ToricLattice.from_syndrome(size, synd, state)
    return errors_to_n(state)
Пример #4
0
def syndrome_class_orbits(size, start=0, stop=None):
    """
    Generates things of the form
    (synd_n, class_n, np.array([ ..consistent error configs ..]))
    """
    if stop is None:
        stop = 2**(size**2 / 2 - 2)
    s = st.ToricLattice(size)
    a = zero_orbit(size)
    for i in range(start, stop):
        e = error_candidate_for_syndrome(i, size)
        error_configs = e ^ a
        for j, row in enumerate(error_configs):
            # assume the classes are in numerical order (they are)
            yield (i, j, row)
Пример #5
0
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'lib'))

import state as st
import chain as ch
import conjugacy_classes as cc

size = 6

ccs = cc.ConjugacyClasses(st.ToricLattice(size))


def go(prob):
    hor_z = st.ToricLattice.HOR_Z
    vert_z = st.ToricLattice.VERT_Z

    s_orig = st.ZUniformToricState(6, prob)

    s_orig.generate_errors()
    synd = s_orig.syndrome()

    s = st.ZUniformToricState.from_syndrome(6, prob, synd)

    sv = s.copy().change_class(vert_z)
    sh = s.copy().change_class(hor_z)
    shv = s.copy().change_class(hor_z + vert_z)

    p = ch.path(s)
    pv = ch.path(sv)
    ph = ch.path(sh)
Пример #6
0
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'lib'))
import numpy as np
import matplotlib.pyplot as plt
import y_conjugacy_classes as ycc
import state as st

s2 = st.ToricLattice(2)
sc2 = ycc.synd_classes(s2)
h2 = ycc.hist_array(sc2, 2)

s4 = st.ToricLattice(4)
sc4 = ycc.synd_classes(s4)
h4 = ycc.hist_array(sc4, 4)

s6 = st.ToricLattice(6)
sc6 = ycc.synd_classes(s6)
h6 = ycc.hist_array(sc6, 6)


def p2(p):
    return ycc.success_probability(h2, p)


def p4(p):
    return ycc.success_probability(h4, p)


def p6(p):
    return ycc.success_probability(h6, p)
Пример #7
0
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'lib'))
import numpy as np
import matplotlib.pyplot as plt
import y_conjugacy_classes as ycc
import state as st

size = 4

s = st.ToricLattice(size)


@ycc.memoize
def n_to_class(n):
    return ycc.n_to_class(s, n)


@ycc.memoize
def n_to_syndrome(n):
    return ycc.n_to_syndrome(s, n)


def synd_classes():
    synd_classes = {}
    for i in range(2**(size**2 / 2)):
        synd = n_to_syndrome(i)
        if (synd, 0) in synd_classes:
            # find new class
            c = n_to_class(i ^ synd_classes[(synd, 0)][0])
            if (synd, c) in synd_classes:
Пример #8
0
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'lib'))
import numpy as np
import y_conjugacy_classes as ycc
import state as st

s4 = st.ToricLattice(4)
sc4 = ycc.synd_classes(s4)
h4 = ycc.hist_array(sc4, 4)

def p4n(p, q):
    return ycc.small_noisy_prob(h4, 4, p, q)

pp = np.linspace(0, 0.2, 81)
qq = np.linspace(0, 0.12, 49)

PP, QQ = np.meshgrid(pp, qq)

Z4 = np.array([[p4n(p, q) for p in pp] for q in qq])

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)

fontsize=16

Z = Z4 - (1 - PP)**2
cont =  ax.contour(QQ, PP, Z, [0.06, 0.05, 0.04, 0.03, 0.02, 0.01], colors=('black'))
plt.clabel(cont, inline=1, fontsize=fontsize)
cont2 = ax.contour(QQ, PP, Z, [0], colors = ('black'), linewidths=(3))