microsoft/qdk
Publicmirrored from https://github.com/microsoft/qdkAvailable
samples/qasm/sample_000.qasm
35lines · modecode
| 1 | // Repetition code syndrome measurement |
| 2 | include "stdgates.inc"; |
| 3 | |
| 4 | qubit[3] q; |
| 5 | qubit[2] a; |
| 6 | bit[3] c; |
| 7 | bit[2] syn; |
| 8 | |
| 9 | def syndrome(qubit[3] d, qubit[2] a) -> bit[2] { |
| 10 | bit[2] b; |
| 11 | cx d[0], a[0]; |
| 12 | cx d[1], a[0]; |
| 13 | cx d[1], a[1]; |
| 14 | cx d[2], a[1]; |
| 15 | for int i in [0:1] { |
| 16 | measure a[i] -> b[i]; |
| 17 | } |
| 18 | return b; |
| 19 | } |
| 20 | |
| 21 | for int i in [0:2] { |
| 22 | reset q[i]; |
| 23 | } |
| 24 | for int i in [0:1] { |
| 25 | reset a[i]; |
| 26 | } |
| 27 | x q[0]; // insert an error |
| 28 | barrier q; |
| 29 | syn = syndrome(q, a); |
| 30 | if(syn == 1) x q[0]; |
| 31 | if(syn == 2) x q[2]; |
| 32 | if(syn == 3) x q[1]; |
| 33 | for int i in [0:2]{ |
| 34 | c[i] = measure q[i]; |
| 35 | } |