Unverified Commit d9d37eb3 authored by dwuggh's avatar dwuggh
Browse files

fix measurement order

parent 53f08da4
......@@ -231,6 +231,14 @@ impl GridGeometry {
self.scale.get_measure_num(self.stabilizer)
}
pub fn get_measure_coordinate(&self, measure: usize) -> Coordinate {
let a = match self.stabilizer {
Stabilizer::X => self.scale.xm,
Stabilizer::Z => self.scale.zm,
};
Coordinate::new(measure % a, measure / a)
}
fn get_path_to_boundary(&self, measure: usize) -> Vec<usize> {
let c = Coordinate::from_measure_index(self.stabilizer, measure, &self.scale);
if self.stabilizer == Stabilizer::X {
......@@ -420,4 +428,12 @@ mod tests {
assert_eq!(w, 5);
}
}
#[test]
fn get_measure_coordinate_is_correct() {
let scale = gen_scale(7, 5);
let geometry = GridGeometry::new(Stabilizer::X, scale);
let c = geometry.get_measure_coordinate(8);
assert_eq!(c, Coordinate::new(2, 1))
}
}
......@@ -89,6 +89,7 @@ impl<'a> SurfaceCodeModel<'a> {
) {
let mut m = start;
while m < measures.len() {
log::trace!("{} m: {}", geometry.stabilizer, m);
let datas = geometry.get_measureq_datas(m);
let result = datas.iter().rfold(0, |x, y| x ^ datas_ref[*y]);
let is_success = channel.is_success(rng);
......@@ -109,7 +110,16 @@ impl<'a> SurfaceCodeModel<'a> {
datas_ref[datas[i]] ^= ops[i];
}
}
m = m + 2;
m += 1;
let c = geometry.get_measure_coordinate(m);
let mut parity = (c.x + c.y) % 2;
while parity != start {
m += 1;
let c = geometry.get_measure_coordinate(m);
parity = (c.x + c.y) % 2;
}
}
}
measure_group(
......@@ -149,46 +159,6 @@ impl<'a> SurfaceCodeModel<'a> {
&mut self.state.rng,
);
// for mx in 0..a.len() {
// let datas = self.gx.get_measureq_datas(mx);
// let result = datas.iter().rfold(0, |x, y| x ^ datas_ref[*y]);
// let is_success = channel.is_success(&mut self.state.rng);
// // strictly speaking, the measurement procedure should be divided into
// // 4 steps. But since all the kraus operator commute(up to a global phase),
// // the order is unnecessary.
// if is_success {
// a[mx] = result & BIT_X != BIT_X;
// let ops = channel.success.get_rand_op(&mut self.state.rng);
// for i in 0..datas.len() {
// datas_ref[datas[i]] ^= ops[i];
// }
// } else {
// a[mx] = result & BIT_X == BIT_X;
// let ops = channel.failure.get_rand_op(&mut self.state.rng);
// for i in 0..datas.len() {
// datas_ref[datas[i]] ^= ops[i];
// }
// }
// }
// // let b = &mut self.state.measures_z;
// for mz in 0..b.len() {
// let datas = self.gz.get_measureq_datas(mz);
// let result = datas.iter().rfold(0, |x, y| x ^ datas_ref[*y]);
// let is_success = channel.is_success(&mut self.state.rng);
// if is_success {
// b[mz] = result & BIT_Z != BIT_Z;
// let ops = channel.success.get_rand_op(&mut self.state.rng);
// for i in 0..datas.len() {
// datas_ref[datas[i]] ^= ops[i];
// }
// } else {
// b[mz] = result & BIT_Z == BIT_Z;
// let ops = channel.failure.get_rand_op(&mut self.state.rng);
// for i in 0..datas.len() {
// datas_ref[datas[i]] ^= ops[i];
// }
// }
// }
}
/// whether the surface code has logical error, when ecc process failed.
......
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