File tree Expand file tree Collapse file tree 2 files changed +7
-12
lines changed
algorithms/amplitude_amplification_and_estimation/quantum_counting Expand file tree Collapse file tree 2 files changed +7
-12
lines changed Original file line number Diff line number Diff line change 77// this qubit implements the marking oracle used inside amplitude amplification iterations.
88
99
10- // Defining the QStruct , containing the quantum variables a and b
10+ // Defining the qstruct , containing the quantum variables a and b, each with two qubits
1111qstruct OracleVars {
1212 a: qnum<2>;
1313 b: qnum<2>;
1414}
1515
1616
17- // Configuration constants
18- A_BITS: int = 2;
19- B_BITS: int = 2;
2017
21- PROBLEM_QUBITS: int = A_BITS + B_BITS ; // 4 qubits: a[2] || b[2]
22- THRESHOLD: int = 2; // predicate: (a + b) <= THRESHOLD
18+ PROBLEM_QUBITS: int = 4 ; // 4 qubits
19+ THRESHOLD: int = 2; // predicate: (a + b) <= THRESHOLD
2320
2421
2522
Original file line number Diff line number Diff line change 1111// the solution ratio; QPE extracts an estimate of that phase.
1212
1313
14- // Problem sizes (in qubits)
15- A_BITS: int = 2;
16- B_BITS: int = 2;
14+
1715
1816// Mark states for which (a + b) <= THRESHOLD
1917THRESHOLD: int = 2;
@@ -22,13 +20,13 @@ THRESHOLD: int = 2;
2220// Larger values provide finer phase resolution.
2321PHASE_QUBITS: int = 5;
2422
25- // Defining the QStruct , containing the quantum variables a and b
23+ // Defining the qstruct , containing the quantum variables a and b
2624qstruct OracleVars {
2725 a: qnum<2>;
2826 b: qnum<2>;
2927}
3028
31- // Predicate: flips `res` iff the input (a, b) is a "good" solution.
29+ // Predicate: flips `res` iff the input (a, b) is a marked solution.
3230qperm arith_equation(const state: OracleVars, res: qbit) {
3331 res ^= (state.a + state.b) <= 2;
3432}
@@ -43,7 +41,7 @@ qfunc arith_oracle(state: OracleVars) {
4341qfunc main(output phase_var: qnum<PHASE_QUBITS, UNSIGNED, PHASE_QUBITS>) {
4442 state_var: OracleVars;
4543
46- allocate(state_var); // Initiates the ancilla QStruct
44+ allocate(state_var); // Initiates the ancilla qstruct
4745 allocate(phase_var); // Initiates the phase quantum variable
4846
4947 // Prepare a uniform superposition over all (a, b) inputs.
You can’t perform that action at this time.
0 commit comments