Unverified Commit 09360a35 authored by dwuggh's avatar dwuggh
Browse files

update

parent 8224bfcc
from calc_channel.DensityOperator import DensityOperator
import calc_channel as cc
import numpy as np
def expedient(p = 0.006):
err_model = cc.ErrorModel(0.1, p, p)jjk
# [[0.4915 0 0 0.486]
# [ 0 0.008491 0.007086 0]
# [ 0 0.007086 0.008491 0]
# [ 0.486 0 0 0.4915]]
# [[0.49150882 0 0 0.48603865]
# [ 0 0.0084911765 0.0070856237 0]
# [ 0 0.0070856237 0.0084911765 0]
# [0.48603865 0 0 0.49150882]]
ρ0 = bosonic_bell_pair([0, 3])
ρ1 = cc.make_bell_with(ρ0, err_model, False, False)
ρ1.print()
ρ = cc.make_GHZ_with(ρ1, err_model, False, False)
return ρ
def stringent():
err_model = cc.ErrorModel(0.1, 0.0075, 0.0075)
ρ0 = bosonic_bell_pair([0, 3])
ρ1 = cc.make_bell_with(ρ0, err_model, True, False)
ρ1.print()
ρ = cc.make_GHZ_with(ρ1, err_model, True, False)
return ρ
def bosonic_bell_pair(qubits = [0, 1]):
mat = np.array([
[0.44976515, 0, 0, 0.41063044],
[0, 0.05022543, 0.0085779, 0],
[0, 0.085779, 0.05022543, 0],
[0.41063044, 0, 0, 0.44976515],
])
return DensityOperator(qubits, mat)
if __name__ == "__main__":
np.set_printoptions(edgeitems=16, linewidth=200,
formatter=dict(float=lambda x: "%6.4g" % x)
)
# ρ = expedient()
# ρ = stringent()
GHZ_perfect = np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
GHZ_perfect = np.outer(GHZ_perfect, GHZ_perfect) / 2
GHZ_perfect = cc.DensityOperator([0, 3, 6, 9], GHZ_perfect)
ps = np.arange(0.002, 0.004, 0.00025)
results_c = []
results_e = []
for p in ps:
print("running probs ", p)
error_model = cc.ErrorModel(1, p, p)
ρ1 = cc.make_bell(error_model, False, False)
ρ1.print()
ρ = cc.make_GHZ_with(ρ1, error_model, False, False)
result_correct, result_error = cc.get_result(ρ.operator, error_model)
print(cc.entanglement_fidelity(ρ, GHZ_perfect))
ρ.print()
results_c.append(result_correct)
results_e.append(result_error)
for i in range(len(ps)):
print(ps[i], " : ", results_c[i][0, 0, 0, 0], " ", results_e[i][0, 0, 0, 0])
with open('data/scan_result.npz', 'wb') as f:
np.savez(f, results_c, results_e)
# with open('data/expedient_GHZ_full.npy', 'wb') as f:
# np.save(f, ρ.operator, False)
......@@ -20,8 +20,8 @@ class DensityOperator(QOperator):
super().__init__(qubits, mat)
def deepcopy(self):
operator = self.operator
qubits = self.qubits
operator = self.operator.copy()
qubits = self.qubits.copy()
return DensityOperator(qubits, operator)
def merge(self, other):
......@@ -189,4 +189,10 @@ def bell_pair(p_n, qubits = [0, 1], i = 0):
[-1, 0, 0, 1]], dtype=np.float64) / 2
ρ_0 = ρ_00 if i == 0 else ρ_11
mat = (1 - 4 / 3 * p_n) * ρ_0 + (p_n / 3) * np.identity(4)
# mat = np.array([
# [0.44976515, 0, 0, 0.41063044],
# [0, 0.05022543, 0.0085779, 0],
# [0, 0.085779, 0.05022543, 0],
# [0.41063044, 0, 0, 0.44976515],
# ])
return DensityOperator(qubits, mat)
......@@ -15,8 +15,8 @@ class QOperator(object):
# return self
def deepcopy(self):
operator = self.operator
qubits = self.qubits
operator = self.operator.copy()
qubits = self.qubits.copy()
return QOperator(qubits, operator)
def qnum(self):
......
......@@ -4,6 +4,7 @@ from .QChannel import *
from .DensityOperator import *
from .fidelity import *
from .purify_circuits import *
from .measure import *
# from os.path import dirname, basename, isfile
......
import numpy as np
from .utils import *
from .QOperator import *
from .QChannel import *
from .DensityOperator import *
from .fidelity import *
def get_GHZ_probs(mat):
probs = []
dim = mat.shape[0]
for i in range(dim // 2):
a = mat[i, i]
b = mat[i, dim - i - 1]
p1 = a + b
p2 = a - b
probs.append((p1, p2))
return np.array(probs)
def get_p(indices, p_g):
result_correct = []
result_error = []
for i in indices:
probs = np.ones(4) * (p_g / 15)
if i == 0:
probs[0] = 1 - p_g
result_correct.append(probs[0] + probs[1])
result_error.append(probs[2] + probs[3])
return result_correct, result_error
'''
@param p1 : probs of state X^j |Ψ>
@param p2 : probs of state X^j Z |Ψ>
'''
def get_pair_result_1(err_model: ErrorModel, p1, p2, qubits_number = 0):
c_correct = np.zeros((4, 4, 4, 4))
c_error = np.zeros((4, 4, 4, 4))
# probs = 0
p_g = err_model.p_g
qubits = np.flip(get_bin_digits(qubits_number, 4))
pm_correct, pm_error = measure_GHZ(err_model.p_m)
# data_errors denote which error happened on the 4 data qubits
for i in range(256):
data_errors = np.flip(get_n_digits(i, 4, 4))
pgs_correct, pgs_error = get_p(data_errors, p_g)
for j, q in enumerate(qubits):
if q == 1:
if data_errors[j] == 0:
data_errors[j] = 1
elif data_errors[j] == 1:
data_errors[j] = 0
elif data_errors[j] == 2:
data_errors[j] = 3
elif data_errors[j] == 3:
data_errors[j] = 2
p_1 = pgs_correct[0] * pgs_error[3] + pgs_correct[3] * pgs_error[0]
p_2 = pgs_correct[1] * pgs_error[2] + pgs_correct[2] * pgs_error[1]
p_3 = pgs_correct[1] * pgs_correct[2] + pgs_error[1] * pgs_error[2]
p_4 = pgs_correct[0] * pgs_correct[3] + pgs_error[0] * pgs_error[3]
pg_correct = p_1 * p_2 + p_3 * p_4
pg_error = p_1 * p_3 + p_2 * p_4
p_correct = p1 * (pg_correct * pm_correct + pg_error * pm_error) + p2 * (pg_correct * pm_error + pg_error * pm_correct)
p_error = p1 * (pg_correct * pm_error + pg_error * pm_correct) + p2 * (pg_correct * pm_correct + pg_error * pm_error)
c_correct[data_errors[0], data_errors[1], data_errors[2], data_errors[3]] += p_correct
c_error[data_errors[0], data_errors[1], data_errors[2], data_errors[3]] += p_error
return c_correct, c_error
def measure_GHZ(p_m):
pm_correct = p_m ** 4 + (1 - p_m) ** 4 + 6 * p_m ** 2 * (1 - p_m) ** 2
pm_error = 4 * p_m * (1 - p_m) ** 3 + 4 * p_m ** 3 * (1 - p_m)
return pm_correct, pm_error
def get_result(mat, err_model: ErrorModel):
probs = get_GHZ_probs(mat)
# print(probs)
print("sum", np.sum(probs))
print("trace", mat.trace())
c_correct = np.zeros((4, 4, 4, 4))
c_error = np.zeros((4, 4, 4, 4))
for (i, ps) in enumerate(probs):
_c_correct, _c_error = get_pair_result_1(err_model, ps[0], ps[1], i)
c_correct += _c_correct
c_error += _c_error
return c_correct, c_error
import numpy as np
from copy import deepcopy
from functools import reduce
from .utils import *
from .QOperator import *
......@@ -32,7 +31,6 @@ data2 ------σ------------
def bell_purify_1(ρ: DensityOperator, err_model: ErrorModel, data1, data2, q1, q2, q3 ,q4, pauli):
ρ1 = bell_pair(err_model.p_n, [q1, q3])
ρ.merge(ρ1)
# ρ.print()
# 2 control-pauli gate
c1 = cpauli(pauli, [q1, data1])
......@@ -40,8 +38,6 @@ def bell_purify_1(ρ: DensityOperator, err_model: ErrorModel, data1, data2, q1,
ρ.evolution(c1, err_model.p_g)
ρ.evolution(c2, err_model.p_g)
# print("evolution")
# ρ.print()
ρ2 = bell_pair(err_model.p_n, [q2, q4])
ρ.merge(ρ2)
......@@ -52,6 +48,8 @@ def bell_purify_1(ρ: DensityOperator, err_model: ErrorModel, data1, data2, q1,
ρ.evolution(c3, err_model.p_g)
ρ.evolution(c4, err_model.p_g)
# ρ.print()
# measurement
ρ.bell_measure(q1, q3, 'x', 'x', err_model.p_m, True)
ρ.bell_measure(q2, q4, 'x', 'x', err_model.p_m, True)
......@@ -84,16 +82,15 @@ def bell_purify_2(ρ: DensityOperator, err_model: ErrorModel, data1, data2, q1,
# for efficiency improvement
ρ1 = bell_pair(err_model.p_n, [q1, q3])
# ρ2 = bell_pair(err_model.p_n, [q2, q4])
ρ2 = ρ1.deepcopy()
ρ2.alter_qubits([q2, q4])
ρ2 = bell_pair(err_model.p_n, [q2, q4])
# ρ2 = ρ1.deepcopy()
# ρ2.alter_qubits([q2, q4])
ρ1.merge(ρ2)
c1 = cnot([q2, q1])
c2 = cnot([q4, q3])
ρ1.evolution(c1, err_model.p_g)
ρ1.evolution(c2, err_model.p_g)
ρ1.bell_measure(q2, q4, 'x', 'x', err_model.p_m)
......@@ -141,7 +138,10 @@ qubit indexing:
0 3
'''
def make_bell(err_model: ErrorModel, stringent = True, stringent_plus = True, step = False):
ρ = bell_pair(err_model.p_n, [0, 3])
return make_bell_with(bell_pair(err_model.p_n, [0, 3]), err_model, stringent, stringent_plus)
def make_bell_with(ρ: DensityOperator, err_model: ErrorModel, stringent = True, stringent_plus = True, step = False):
ρ.alter_qubits([0, 3])
bell_purify_1(ρ, err_model, 0, 3, 1, 2, 4, 5, 'z')
if step:
print(bell_fidelity(ρ))
......@@ -194,15 +194,13 @@ def make_GHZ(err_model: ErrorModel, stringent = True, stringent_plus = True):
def make_GHZ_with(ρ1: DensityOperator, err_model: ErrorModel, stringent = True, stringent_plus = True):
# ρ1 = make_bell(err_model, stringent, stringent_plus)
# ρ2 = make_bell(err_model, stringent, stringent_plus)
ρ2= ρ1.deepcopy()
ρ2 = ρ1.deepcopy()
ρ1.alter_qubits([0, 3])
ρ2.alter_qubits([6, 9])
ρ1.merge(ρ2)
bell_purify_2(ρ1, err_model, 0, 6, 1, 2, 7, 8, 'z', stringent)
# FIXME qubits mismatch for the next line, if we choose ancillas' indices to be 4 5 10 11,
# then the result density matrix would consist of 5 qubits of indices 0, 1, 3, 6, 9.
# However, if the ancilla indices are 1 2 7 8, everything works fine, at least seemingly.
# Don't know why, not even a clue.
bell_purify_2(ρ1, err_model, 0, 6, 1, 2, 7, 8, 'z', stringent)
bell_purify_2(ρ1, err_model, 3, 9, 4, 5, 10, 11, 'z', stringent)
bell_purify_2(ρ1, err_model, 3, 9, 4, 5, 10, 11, 'z', stringent)
# bell_purify_2(ρ1, err_model, 3, 9, 1, 2, 7, 8, 'z', stringent)
return ρ1
......
[0.92326034 0.00141864 0.00065553 0.00065553 0.00141863 0.00011699
0.00000201 0.00000201 0.00065553 0.00000201 0.00000088 0.00000088
0.00065553 0.00000201 0.00000088 0.00000088 0.00141852 0.00001552
0.0000019 0.0000019 0.00000625 0.00076413 0.00000102 0.00000102
0.00000189 0.00000103 0. 0. 0.00000189 0.00000103
0. 0. 0.00065553 0.0000019 0.00000088 0.00000088
0.00000189 0.00000114 0. 0. 0.00000088 0.
0. 0. 0.00000088 0. 0. 0.
0.00065553 0.0000019 0.00000088 0.00000088 0.00000189 0.00000114
0. 0. 0.00000088 0. 0. 0.
0.00000088 0. 0. 0. 0.00065452 0.00000189
0.00000088 0.00000088 0.00000189 0.00000013 0. 0.
0.00000088 0. 0. 0. 0.00000088 0.
0. 0. 0.00000189 0.00000002 0. 0.
0.00000001 0.00000101 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000088 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000088 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00065452 0.00000189 0.00000088 0.00000088
0.00000189 0.00000013 0. 0. 0.00000088 0.
0. 0. 0.00000088 0. 0. 0.
0.00000189 0.00000002 0. 0. 0.00000001 0.00000101
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000088 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000088 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00065452 0.00000189 0.00000088 0.00000088 0.00000189 0.00000013
0. 0. 0.00000088 0. 0. 0.
0.00000088 0. 0. 0. 0.00000189 0.00000002
0. 0. 0.00000001 0.00000101 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000088 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000088 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. ]
[0.94672286 0.0008531 0.00039599 0.00039599 0.00085309 0.00007313
0.00000072 0.00000072 0.00039599 0.00000072 0.00000032 0.00000032
0.00039599 0.00000072 0.00000032 0.00000032 0.00085305 0.00000802
0.00000068 0.00000068 0.00000223 0.00045747 0.00000036 0.00000036
0.00000068 0.00000037 0. 0. 0.00000068 0.00000037
0. 0. 0.00039599 0.00000068 0.00000032 0.00000032
0.00000068 0.00000041 0. 0. 0.00000032 0.
0. 0. 0.00000032 0. 0. 0.
0.00039599 0.00000068 0.00000032 0.00000032 0.00000068 0.00000041
0. 0. 0.00000032 0. 0. 0.
0.00000032 0. 0. 0. 0.00039563 0.00000068
0.00000032 0.00000032 0.00000068 0.00000004 0. 0.
0.00000032 0. 0. 0. 0.00000032 0.
0. 0. 0.00000068 0.00000001 0. 0.
0. 0.00000036 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000032 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000032 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00039563 0.00000068 0.00000032 0.00000032
0.00000068 0.00000004 0. 0. 0.00000032 0.
0. 0. 0.00000032 0. 0. 0.
0.00000068 0.00000001 0. 0. 0. 0.00000036
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000032 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000032 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00039563 0.00000068 0.00000032 0.00000032 0.00000068 0.00000004
0. 0. 0.00000032 0. 0. 0.
0.00000032 0. 0. 0. 0.00000068 0.00000001
0. 0. 0. 0.00000036 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000032 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000032 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. ]
[0.05458592 0.0014035 0.00065553 0.00065553 0.00140349 0.00007227
0.00000201 0.00000201 0.00065553 0.00000201 0.00000088 0.00000088
0.00065553 0.00000201 0.00000088 0.00000088 0.00140338 0.0000104
0.0000019 0.0000019 0.00000625 0.00074899 0.00000102 0.00000102
0.00000189 0.00000103 0. 0. 0.00000189 0.00000103
0. 0. 0.00065553 0.0000019 0.00000088 0.00000088
0.00000189 0.00000114 0. 0. 0.00000088 0.
0. 0. 0.00000088 0. 0. 0.
0.00065553 0.0000019 0.00000088 0.00000088 0.00000189 0.00000114
0. 0. 0.00000088 0. 0. 0.
0.00000088 0. 0. 0. 0.00065452 0.00000189
0.00000088 0.00000088 0.00000189 0.00000013 0. 0.
0.00000088 0. 0. 0. 0.00000088 0.
0. 0. 0.00000189 0.00000002 0. 0.
0.00000001 0.00000101 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000088 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000088 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00065452 0.00000189 0.00000088 0.00000088
0.00000189 0.00000013 0. 0. 0.00000088 0.
0. 0. 0.00000088 0. 0. 0.
0.00000189 0.00000002 0. 0. 0.00000001 0.00000101
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000088 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000088 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00065452 0.00000189 0.00000088 0.00000088 0.00000189 0.00000013
0. 0. 0.00000088 0. 0. 0.
0.00000088 0. 0. 0. 0.00000189 0.00000002
0. 0. 0.00000001 0.00000101 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000088 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000088 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. ]
[0.0399827 0.00084165 0.00039599 0.00039599 0.00084165 0.00003586
0.00000072 0.00000072 0.00039599 0.00000072 0.00000032 0.00000032
0.00039599 0.00000072 0.00000032 0.00000032 0.00084161 0.00000451
0.00000068 0.00000068 0.00000223 0.00044602 0.00000036 0.00000036
0.00000068 0.00000037 0. 0. 0.00000068 0.00000037
0. 0. 0.00039599 0.00000068 0.00000032 0.00000032
0.00000068 0.00000041 0. 0. 0.00000032 0.
0. 0. 0.00000032 0. 0. 0.
0.00039599 0.00000068 0.00000032 0.00000032 0.00000068 0.00000041
0. 0. 0.00000032 0. 0. 0.
0.00000032 0. 0. 0. 0.00039563 0.00000068
0.00000032 0.00000032 0.00000068 0.00000004 0. 0.
0.00000032 0. 0. 0. 0.00000032 0.
0. 0. 0.00000068 0.00000001 0. 0.
0. 0.00000036 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000032 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000032 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00039563 0.00000068 0.00000032 0.00000032
0.00000068 0.00000004 0. 0. 0.00000032 0.
0. 0. 0.00000032 0. 0. 0.
0.00000068 0.00000001 0. 0. 0. 0.00000036
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000032 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000032 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00039563 0.00000068 0.00000032 0.00000032 0.00000068 0.00000004
0. 0. 0.00000032 0. 0. 0.
0.00000032 0. 0. 0. 0.00000068 0.00000001
0. 0. 0. 0.00000036 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000032 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000032 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. ]
import numpy as np
with open('data/expedient_result_correct.npy', 'rb') as f:
c_correct1 = np.load(f)
with open('data/expedient_result_error.npy', 'rb') as f:
c_error1 = np.load(f)
with open('data/stringent_result_correct.npy', 'rb') as f:
c_correct2 = np.load(f)
with open('data/stringent_result_error.npy', 'rb') as f:
c_error2 = np.load(f)
with open('data/custom_result.npz', 'rb') as f:
data = np.load(f)
np.set_printoptions(suppress=True)
c1 = data['arr_0'].reshape((1, -1))[0]
c2 = data['arr_1'].reshape((1, -1))[0]
print(c1)
print(c2)
# cc1 = c_error1.reshape((1, -1))[0]
# print(cc1)
[0.9175735 0.00168388 0.00078415 0.00078415 0.00168387 0.00005306
0.00000278 0.00000278 0.00078415 0.00000278 0.00000126 0.00000126
0.00078415 0.00000278 0.00000126 0.00000126 0.00168381 0.00002045
0.00000273 0.00000273 0.00000891 0.00090119 0.00000146 0.00000146
0.00000271 0.00000147 0.00000001 0.00000001 0.00000271 0.00000147
0.00000001 0.00000001 0.00078415 0.00000273 0.00000126 0.00000126
0.00000271 0.00000152 0.00000001 0.00000001 0.00000126 0.00000001
0. 0. 0.00000126 0.00000001 0. 0.
0.00078415 0.00000273 0.00000126 0.00000126 0.00000271 0.00000152
0.00000001 0.00000001 0.00000126 0.00000001 0. 0.
0.00000126 0.00000001 0. 0. 0.00078271 0.0000027
0.00000126 0.00000126 0.0000027 0.00000008 0. 0.
0.00000126 0. 0. 0. 0.00000126 0.
0. 0. 0.0000027 0.00000003 0. 0.
0.00000001 0.00000144 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000126 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000126 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00078271 0.0000027 0.00000126 0.00000126
0.0000027 0.00000008 0. 0. 0.00000126 0.
0. 0. 0.00000126 0. 0. 0.
0.0000027 0.00000003 0. 0. 0.00000001 0.00000144
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000126 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000126 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00078271 0.0000027 0.00000126 0.00000126 0.0000027 0.00000008
0. 0. 0.00000126 0. 0. 0.
0.00000126 0. 0. 0. 0.0000027 0.00000003
0. 0. 0.00000001 0.00000144 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000126 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000126 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. ]
[0.05611403 0.0016786 0.00078415 0.00078415 0.00167858 0.00004854
0.00000278 0.00000278 0.00078415 0.00000278 0.00000126 0.00000126
0.00078415 0.00000278 0.00000126 0.00000126 0.00167853 0.00001427
0.00000273 0.00000273 0.00000891 0.0008959 0.00000146 0.00000146
0.00000271 0.00000147 0.00000001 0.00000001 0.00000271 0.00000147
0.00000001 0.00000001 0.00078415 0.00000273 0.00000126 0.00000126
0.00000271 0.00000152 0.00000001 0.00000001 0.00000126 0.00000001
0. 0. 0.00000126 0.00000001 0. 0.
0.00078415 0.00000273 0.00000126 0.00000126 0.00000271 0.00000152
0.00000001 0.00000001 0.00000126 0.00000001 0. 0.
0.00000126 0.00000001 0. 0. 0.00078271 0.0000027
0.00000126 0.00000126 0.0000027 0.00000008 0. 0.
0.00000126 0. 0. 0. 0.00000126 0.
0. 0. 0.0000027 0.00000003 0. 0.
0.00000001 0.00000144 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000126 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000126 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00078271 0.0000027 0.00000126 0.00000126
0.0000027 0.00000008 0. 0. 0.00000126 0.
0. 0. 0.00000126 0. 0. 0.
0.0000027 0.00000003 0. 0. 0.00000001 0.00000144
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000126 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000126 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00078271 0.0000027 0.00000126 0.00000126 0.0000027 0.00000008
0. 0. 0.00000126 0. 0. 0.
0.00000126 0. 0. 0. 0.0000027 0.00000003
0. 0. 0.00000001 0.00000144 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000126 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000126 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. ]
import calc_channel as cc
import numpy as np
import sys
def custom(p, stringent):
err_model = cc.ErrorModel(0.1, p, p)
ρ1 = cc.make_bell(err_model, stringent, False)
# ρ1.print()
ρ = cc.make_GHZ_with(ρ1, err_model, stringent, False)
result_correct, result_error = cc.get_result(ρ.operator, err_model)
with open('data/custom_result.npz', 'wb') as f:
np.savez(f, result_correct, result_error)
np.set_printoptions(suppress=True)
r1 = result_correct.reshape((1, -1))[0]
r2 = result_error.reshape((1, -1))[0]
print(r1)
print(r2)
return ρ
def expedient():
err_model = cc.ErrorModel(0.1, 0.006, 0.006)
bell_operator = np