Unverified Commit 05ff15fc authored by dwuggh's avatar dwuggh
Browse files

misc update

parent 4191dc1c
expedient
final bell fidelity in make_bell 0.9851823096902954
sum 1.0000000000000002
trace 1.0000000000000002
[0.91747933 0.0015604 0.00071985 0.00071985 0.00156039 0.00012996 0.00000244 0.00000244 0.00071985 0.00000244 0.00000106 0.00000106 0.00071985 0.00000244 0.00000106 0.00000106 0.00156026 0.00001793
0.91747933 0.0015604 0.00071985 0.00071985 0.00156039 0.00012996 0.00000244 0.00000244 0.00071985 0.00000244 0.00000106 0.00000106 0.00071985 0.00000244 0.00000106 0.00000106 0.00156026 0.00001793
0.00000231 0.00000231 0.00000759 0.00084179 0.00000124 0.00000124 0.00000229 0.00000125 0.00000001 0.00000001 0.00000229 0.00000125 0.00000001 0.00000001 0.00071985 0.00000231 0.00000106 0.00000106
0.00000229 0.00000138 0.00000001 0.00000001 0.00000106 0.00000001 0. 0. 0.00000106 0.00000001 0. 0. 0.00071985 0.00000231 0.00000106 0.00000106 0.00000229 0.00000138
0.00000001 0.00000001 0.00000106 0.00000001 0. 0. 0.00000106 0.00000001 0. 0. 0.00071862 0.00000229 0.00000106 0.00000106 0.00000229 0.00000016 0. 0.
......@@ -16,8 +12,8 @@ trace 1.0000000000000002
0. 0. 0.00000106 0. 0. 0. 0.00000106 0. 0. 0. 0.00000229 0.00000002 0. 0. 0.00000001 0.00000123 0. 0.
0. 0. 0. 0. 0. 0. 0. 0. 0.00000106 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.00000106 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. ]
[0.05814528 0.00154424 0.00071985 0.00071985 0.00154423 0.00008332 0.00000244 0.00000244 0.00071985 0.00000244 0.00000106 0.00000106 0.00071985 0.00000244 0.00000106 0.00000106 0.0015441 0.00001233
0. 0. 0. 0.
0.05814528 0.00154424 0.00071985 0.00071985 0.00154423 0.00008332 0.00000244 0.00000244 0.00071985 0.00000244 0.00000106 0.00000106 0.00071985 0.00000244 0.00000106 0.00000106 0.0015441 0.00001233
0.00000231 0.00000231 0.00000759 0.00082564 0.00000124 0.00000124 0.00000229 0.00000125 0.00000001 0.00000001 0.00000229 0.00000125 0.00000001 0.00000001 0.00071985 0.00000231 0.00000106 0.00000106
0.00000229 0.00000138 0.00000001 0.00000001 0.00000106 0.00000001 0. 0. 0.00000106 0.00000001 0. 0. 0.00071985 0.00000231 0.00000106 0.00000106 0.00000229 0.00000138
0.00000001 0.00000001 0.00000106 0.00000001 0. 0. 0.00000106 0.00000001 0. 0. 0.00071862 0.00000229 0.00000106 0.00000106 0.00000229 0.00000016 0. 0.
......@@ -31,23 +27,4 @@ trace 1.0000000000000002
0. 0. 0.00000106 0. 0. 0. 0.00000106 0. 0. 0. 0.00000229 0.00000002 0. 0. 0.00000001 0.00000123 0. 0.
0. 0. 0. 0. 0. 0. 0. 0. 0.00000106 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.00000106 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. ]
qubits: [9 3 6 0]
shape: (16, 16)
trace: 1.0000000000000002
[[0.49648933 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.45979931]
[0. 0.00084837 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.00000865 0. ]
[0. 0. 0.00084837 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.00000865 0. 0. ]
[0. 0. 0. 0.00010371 0. 0. 0. 0. 0. 0. 0. 0. 0.00002495 0. 0. 0. ]
[0. 0. 0. 0. 0.00084837 0. 0. 0. 0. 0. 0. 0.00000865 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0.00001057 0. 0. 0. 0. 0.000003 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0.0000029 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0.00084837 0.00000865 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0.00000865 0.00084837 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.0000029 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0.000003 0. 0. 0. 0. 0.00001057 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0.00000865 0. 0. 0. 0. 0. 0. 0.00084837 0. 0. 0. 0. ]
[0. 0. 0. 0.00002495 0. 0. 0. 0. 0. 0. 0. 0. 0.00010371 0. 0. 0. ]
[0. 0. 0.00000865 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.00084837 0. 0. ]
[0. 0.00000865 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.00084837 0. ]
[0.45979931 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.49648933]]
0. 0. 0. 0.
import numpy as np
pm = 0.989939
p1 = 0.011
p2 = 0.011
def pn(p, n):
if n == 0:
return 1 - p
else:
return p / 3
def gen_coeff(p):
coeff = []
for i in range(4):
for j in range(4):
for k in range(4):
for l in range(4):
coeff.append(pn(p, i) * pn(p, j) * pn(p, k) * pn(p, l))
return np.array(coeff)
np.set_printoptions(suppress=True)
with open("correct.txt", 'w') as f:
correct = pm * gen_coeff(p1)
print(correct)
for coeff in correct:
f.write(str(coeff))
f.write(' ')
with open("correct.txt", 'w') as f:
error = (1 - pm) * gen_coeff(p2)
print(error)
for coeff in error:
f.write(str(coeff))
f.write(' ')
0.94709512 0.00351131 0.00351131 0.00351131 0.00351131 0.00001302
0.00001302 0.00001302 0.00351131 0.00001302 0.00001302 0.00001302
0.00351131 0.00001302 0.00001302 0.00001302 0.00351131 0.00001302
0.00001302 0.00001302 0.00001302 0.00000005 0.00000005 0.00000005
0.00001302 0.00000005 0.00000005 0.00000005 0.00001302 0.00000005
0.00000005 0.00000005 0.00351131 0.00001302 0.00001302 0.00001302
0.00001302 0.00000005 0.00000005 0.00000005 0.00001302 0.00000005
0.00000005 0.00000005 0.00001302 0.00000005 0.00000005 0.00000005
0.00351131 0.00001302 0.00001302 0.00001302 0.00001302 0.00000005
0.00000005 0.00000005 0.00001302 0.00000005 0.00000005 0.00000005
0.00001302 0.00000005 0.00000005 0.00000005 0.00351131 0.00001302
0.00001302 0.00001302 0.00001302 0.00000005 0.00000005 0.00000005
0.00001302 0.00000005 0.00000005 0.00000005 0.00001302 0.00000005
0.00000005 0.00000005 0.00001302 0.00000005 0.00000005 0.00000005
0.00000005 0. 0. 0. 0.00000005 0.
0. 0. 0.00000005 0. 0. 0.
0.00001302 0.00000005 0.00000005 0.00000005 0.00000005 0.
0. 0. 0.00000005 0. 0. 0.
0.00000005 0. 0. 0. 0.00001302 0.00000005
0.00000005 0.00000005 0.00000005 0. 0. 0.
0.00000005 0. 0. 0. 0.00000005 0.
0. 0. 0.00351131 0.00001302 0.00001302 0.00001302
0.00001302 0.00000005 0.00000005 0.00000005 0.00001302 0.00000005
0.00000005 0.00000005 0.00001302 0.00000005 0.00000005 0.00000005
0.00001302 0.00000005 0.00000005 0.00000005 0.00000005 0.
0. 0. 0.00000005 0. 0. 0.
0.00000005 0. 0. 0. 0.00001302 0.00000005
0.00000005 0.00000005 0.00000005 0. 0. 0.
0.00000005 0. 0. 0. 0.00000005 0.
0. 0. 0.00001302 0.00000005 0.00000005 0.00000005
0.00000005 0. 0. 0. 0.00000005 0.
0. 0. 0.00000005 0. 0. 0.
0.00351131 0.00001302 0.00001302 0.00001302 0.00001302 0.00000005
0.00000005 0.00000005 0.00001302 0.00000005 0.00000005 0.00000005
0.00001302 0.00000005 0.00000005 0.00000005 0.00001302 0.00000005
0.00000005 0.00000005 0.00000005 0. 0. 0.
0.00000005 0. 0. 0. 0.00000005 0.
0. 0. 0.00001302 0.00000005 0.00000005 0.00000005
0.00000005 0. 0. 0. 0.00000005 0.
0. 0. 0.00000005 0. 0. 0.
0.00001302 0.00000005 0.00000005 0.00000005 0.00000005 0.
0. 0. 0.00000005 0. 0. 0.
0.00000005 0. 0. 0.
0.00962557 0.00003569 0.00003569 0.00003569 0.00003569 0.00000013
0.00000013 0.00000013 0.00003569 0.00000013 0.00000013 0.00000013
0.00003569 0.00000013 0.00000013 0.00000013 0.00003569 0.00000013
0.00000013 0.00000013 0.00000013 0. 0. 0.
0.00000013 0. 0. 0. 0.00000013 0.
0. 0. 0.00003569 0.00000013 0.00000013 0.00000013
0.00000013 0. 0. 0. 0.00000013 0.
0. 0. 0.00000013 0. 0. 0.
0.00003569 0.00000013 0.00000013 0.00000013 0.00000013 0.
0. 0. 0.00000013 0. 0. 0.
0.00000013 0. 0. 0. 0.00003569 0.00000013
0.00000013 0.00000013 0.00000013 0. 0. 0.
0.00000013 0. 0. 0. 0.00000013 0.
0. 0. 0.00000013 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000013 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000013 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00003569 0.00000013 0.00000013 0.00000013
0.00000013 0. 0. 0. 0.00000013 0.
0. 0. 0.00000013 0. 0. 0.
0.00000013 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000013 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000013 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00003569 0.00000013 0.00000013 0.00000013 0.00000013 0.
0. 0. 0.00000013 0. 0. 0.
0.00000013 0. 0. 0. 0.00000013 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000013 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000013 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0.
0.96462132 0.00208935 0.00208935 0.00208935 0.00208935 0.00000453
0.00000453 0.00000453 0.00208935 0.00000453 0.00000453 0.00000453
0.00208935 0.00000453 0.00000453 0.00000453 0.00208935 0.00000453
0.00000453 0.00000453 0.00000453 0.00000001 0.00000001 0.00000001
0.00000453 0.00000001 0.00000001 0.00000001 0.00000453 0.00000001
0.00000001 0.00000001 0.00208935 0.00000453 0.00000453 0.00000453
0.00000453 0.00000001 0.00000001 0.00000001 0.00000453 0.00000001
0.00000001 0.00000001 0.00000453 0.00000001 0.00000001 0.00000001
0.00208935 0.00000453 0.00000453 0.00000453 0.00000453 0.00000001
0.00000001 0.00000001 0.00000453 0.00000001 0.00000001 0.00000001
0.00000453 0.00000001 0.00000001 0.00000001 0.00208935 0.00000453
0.00000453 0.00000453 0.00000453 0.00000001 0.00000001 0.00000001
0.00000453 0.00000001 0.00000001 0.00000001 0.00000453 0.00000001
0.00000001 0.00000001 0.00000453 0.00000001 0.00000001 0.00000001
0.00000001 0. 0. 0. 0.00000001 0.
0. 0. 0.00000001 0. 0. 0.
0.00000453 0.00000001 0.00000001 0.00000001 0.00000001 0.
0. 0. 0.00000001 0. 0. 0.
0.00000001 0. 0. 0. 0.00000453 0.00000001
0.00000001 0.00000001 0.00000001 0. 0. 0.
0.00000001 0. 0. 0. 0.00000001 0.
0. 0. 0.00208935 0.00000453 0.00000453 0.00000453
0.00000453 0.00000001 0.00000001 0.00000001 0.00000453 0.00000001
0.00000001 0.00000001 0.00000453 0.00000001 0.00000001 0.00000001
0.00000453 0.00000001 0.00000001 0.00000001 0.00000001 0.
0. 0. 0.00000001 0. 0. 0.
0.00000001 0. 0. 0. 0.00000453 0.00000001
0.00000001 0.00000001 0.00000001 0. 0. 0.
0.00000001 0. 0. 0. 0.00000001 0.
0. 0. 0.00000453 0.00000001 0.00000001 0.00000001
0.00000001 0. 0. 0. 0.00000001 0.
0. 0. 0.00000001 0. 0. 0.
0.00208935 0.00000453 0.00000453 0.00000453 0.00000453 0.00000001
0.00000001 0.00000001 0.00000453 0.00000001 0.00000001 0.00000001
0.00000453 0.00000001 0.00000001 0.00000001 0.00000453 0.00000001
0.00000001 0.00000001 0.00000001 0. 0. 0.
0.00000001 0. 0. 0. 0.00000001 0.
0. 0. 0.00000453 0.00000001 0.00000001 0.00000001
0.00000001 0. 0. 0. 0.00000001 0.
0. 0. 0.00000001 0. 0. 0.
0.00000453 0.00000001 0.00000001 0.00000001 0.00000001 0.
0. 0. 0.00000001 0. 0. 0.
0.00000001 0. 0. 0.
0.00980373 0.00002123 0.00002123 0.00002123 0.00002123 0.00000005
0.00000005 0.00000005 0.00002123 0.00000005 0.00000005 0.00000005
0.00002123 0.00000005 0.00000005 0.00000005 0.00002123 0.00000005
0.00000005 0.00000005 0.00000005 0. 0. 0.
0.00000005 0. 0. 0. 0.00000005 0.
0. 0. 0.00002123 0.00000005 0.00000005 0.00000005
0.00000005 0. 0. 0. 0.00000005 0.
0. 0. 0.00000005 0. 0. 0.
0.00002123 0.00000005 0.00000005 0.00000005 0.00000005 0.
0. 0. 0.00000005 0. 0. 0.
0.00000005 0. 0. 0. 0.00002123 0.00000005
0.00000005 0.00000005 0.00000005 0. 0. 0.
0.00000005 0. 0. 0. 0.00000005 0.
0. 0. 0.00000005 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000005 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000005 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00002123 0.00000005 0.00000005 0.00000005
0.00000005 0. 0. 0. 0.00000005 0.
0. 0. 0.00000005 0. 0. 0.
0.00000005 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.00000005 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000005 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00002123 0.00000005 0.00000005 0.00000005 0.00000005 0.
0. 0. 0.00000005 0. 0. 0.
0.00000005 0. 0. 0. 0.00000005 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0.00000005 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.00000005 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0. 0. 0. 0.
......@@ -34,7 +34,7 @@ fn get_weight(pd: f64, pm: f64) -> (f64, f64) {
// w1 = 0.5;
// w2 = 1.0 - w1;
log::debug!("{}, {}", w1, w2);
log::info!("w1: {}, w2: {}", w1, w2);
(w1, w2)
}
......@@ -74,7 +74,7 @@ pub fn runner1(xn: usize, zm: usize, p: f64, measure_model: MeasureNoiseModel) -
}
pub fn runner2(xn: usize, zm: usize, measure_rounds: usize, measure_model: MeasureNoiseModel) -> usize {
let p1 = 0.006;
let p1 = 0.01;
let probs = &measure_model.success.probs;
let p_ext = probs[1] * 4.;
log::debug!("p_ext: {}", p_ext);
......@@ -91,8 +91,8 @@ pub fn runner2(xn: usize, zm: usize, measure_rounds: usize, measure_model: Measu
None => 1,
};
if result == 0 {
log::warn!("gx: {:?}", gx);
log::warn!("gz: {:?}", gz);
log::trace!("gx: {:?}", gx);
log::trace!("gz: {:?}", gz);
}
log::info!("result: {}", result);
......
......@@ -34,8 +34,8 @@ fn main() {
.short('p'),
)
.arg(
Arg::new("rounds")
.about("the number of rounds to run")
Arg::new("repeat")
.about("repeat times")
.short('r')
.default_value("1"),
)
......@@ -46,25 +46,28 @@ fn main() {
.default_value("1"),
)
.arg(
Arg::new("channel-correct")
.about("channel for correct measurement outcome")
.default_value("./custom_correct2.txt"),
)
.arg(
Arg::new("channel-error")
.about("channel for error measurement outcome")
.default_value("./custom_error2.txt"),
Arg::new("measure-rounds")
.about("thread number to use")
.short('t')
.long("measure-rounds")
.default_value("1"),
)
.arg(Arg::new("channel").about("channel"))
.get_matches();
let xn = matches.value_of("xn").unwrap().parse::<usize>().unwrap();
let zm = matches.value_of("zm").unwrap().parse::<usize>().unwrap();
let p = match matches.value_of("p0") {
let measure_rounds = matches
.value_of("measure-rounds")
.unwrap()
.parse::<usize>()
.unwrap();
let _p = match matches.value_of("p0") {
Some(p_str) => p_str.parse::<f64>().unwrap(),
None => 0.000,
};
let rounds = matches
.value_of("rounds")
.value_of("repeat")
.unwrap()
.parse::<usize>()
.unwrap();
......@@ -74,23 +77,21 @@ fn main() {
.parse::<usize>()
.unwrap();
let file_correct = matches.value_of("channel-correct").unwrap();
let file_error = matches.value_of("channel-error").unwrap();
let str_correct = std::fs::read_to_string(file_correct).unwrap();
let str_error = std::fs::read_to_string(file_error).unwrap();
let channel_str = std::fs::read_to_string(matches.value_of("channel").unwrap()).unwrap();
// let str_correct = std::fs::read_to_string("./custom_correct.txt").unwrap();
// let str_error = std::fs::read_to_string("./custom_error.txt").unwrap();
let m_correct = load_arr(&str_correct);
let m_error = load_arr(&str_error);
let (m_correct, m_error) = load_arr(&channel_str);
// let pm = 0.06;
// let m_correct = vec![1. - pm];
// let m_error = vec![pm];
// let pm = 0.02;
// let mut m_correct = vec![0.; 256];
// let mut m_error = vec![0.; 256];
// m_correct[0] = 1. - pm;
// m_error[0] = pm;
let measure_model = error::MeasureNoiseModel::new(m_correct, m_error);
let result: Vec<usize> = (0..rounds)
.into_par_iter()
.map(|_| runner2(xn, zm, 30, measure_model.clone()))
.map(|_| runner2(xn, zm, measure_rounds, measure_model.clone()))
// .map(|_| runner1(xn, zm, 0.006, measure_model.clone()))
.collect();
......
use crate::error::NoiseChannel;
use rand::prelude::{ThreadRng, thread_rng};
use ansi_term::{Colour, Style};
use ansi_term::Colour;
/// The Stabilizer Formalism
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
......@@ -51,15 +51,15 @@ impl CodeState {
}
pub fn gen_independent_error(&mut self, channel: NoiseChannel) {
// let mut i = 0;
let mut i = 0;
for data in self.datas.iter_mut() {
// let data_old = *data;
let data_old = *data;
channel.apply_mut(data, &mut self.rng);
// let data_new = *data;
// if data_old != data_new {
// log::debug!("data error at {}, old: {}, new: {}", i, data_old, data_new);
// }
// i = i + 1;
let data_new = *data;
if data_old != data_new {
log::debug!("data error at {}, old: {}, new: {}", i, data_old, data_new);
}
i = i + 1;
}
}
......@@ -101,7 +101,7 @@ impl CodeState {
// z data error and stabilizer X's defect
let color_z = Colour::Green.bold();
let color_measerr = Colour::Yellow;
// let color_measure = Colour::Yellow;
let data_char = "⋅ ";
for i in 0..(2 * xn + 1) {
......@@ -155,6 +155,6 @@ impl CodeState {
}
output.push('\n')
}
println!("{}", output)
log::trace!("\n {}", output);
}
}
pub fn load_arr(input: &str) -> Vec<f64> {
pub fn load_arr(input: &str) -> (Vec<f64>, Vec<f64>) {
let mut result = Vec::<f64>::new();
let input = input.trim_matches(&['[', ']', ' '][..]);
for i in input.split(&[',', ' ', '\n', '\t'][..]) {
......@@ -12,20 +12,8 @@ pub fn load_arr(input: &str) -> Vec<f64> {
}
}
}
result
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn can_load_numeric_array() {
let str = " [ 0.9175735 0.00168388 \n \t0.00078415 0. ] ";
let arr_expected = vec![0.9175735, 0.00168388, 0.00078415, 0.];
assert_eq!(load_arr(str), arr_expected);
}
assert_eq!(result.len(), 512);
let (correct, error) = result.split_at(256);
(correct.to_vec(), error.to_vec())
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment