Skip to content

Commit c3161be

Browse files
cr fixes
1 parent 066766a commit c3161be

File tree

1 file changed

+24
-21
lines changed
  • algorithms/quantum_linear_solvers/hhl

1 file changed

+24
-21
lines changed

algorithms/quantum_linear_solvers/hhl/hhl.qmod

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,47 +53,50 @@ rhs_vector: real[] = [sqrt(1/6), sqrt(1/6), sqrt(1/6), sqrt(1/2)];
5353
// In our example the matrix A is a sum of commuting Pauli strings.
5454
// We define how to take powers of the Hamiltonian evolution exp(2π A), which is applied
5555
// within the Quantum Phase Estimation. We simply multiply the evolution time by the power value,
56-
// keeping the number of Trotter repetition being 1, as suitable for commuting terms.
56+
// keeping the number of repetitions at 1, since the terms commute.
5757
qfunc powered_suzuki_trotter_commuting_terms(k: int, hamiltonian: SparsePauliOp, qba: qbit[]) {
5858
suzuki_trotter(hamiltonian, -2*pi* k, 1, 1, qba);
5959
}
6060

61-
// We define a quantum function that assigns eigenvalue inversion to the amplitudes for a signed qnum of
62-
// size 4 with 4 fraction places index. The desired amplitudes are conditioned by an additional
63-
// indicator qubit being at state 1, and are normalized by the smallest possible value of 1/2^index.size.
64-
qfunc assign_inversion_size4(const index: qbit[4], indicator: qbit) {
61+
// We define a quantum function that assigns eigenvalue inversion to the amplitudes,
62+
// conditioned on an additional indicator qubit being in the |1⟩ state:
63+
// |value⟩|0⟩ -> (C / value)|value⟩|1⟩ + sqrt(1 − (C / value)^2)|value⟩|0⟩.
64+
// The variable `value` is a signed qnum of size 4 with 4 fractional bits,
65+
// and the inversion amplitudes are normalized using the smallest possible value,
66+
// C = 2^(−value.size).
67+
qfunc assign_inversion_size4(const value: qbit[4], indicator: qbit) {
6568
RY(-0.0157, indicator);
66-
skip_control { CX(index[0], indicator); }
69+
skip_control { CX(value[0], indicator); }
6770
RY(-0.0157, indicator);
68-
skip_control { CX(index[1], indicator); }
71+
skip_control { CX(value[1], indicator); }
6972
RY(-0.3379, indicator);
70-
skip_control { CX(index[0], indicator); }
73+
skip_control { CX(value[0], indicator); }
7174
RY(0.3066, indicator);
72-
skip_control { CX(index[2], indicator); }
75+
skip_control { CX(value[2], indicator); }
7376
RY(-0.1047, indicator);
74-
skip_control { CX(index[0], indicator); }
77+
skip_control { CX(value[0], indicator); }
7578
RY(-0.1047, indicator);
76-
skip_control { CX(index[1], indicator); }
79+
skip_control { CX(value[1], indicator); }
7780
RY(-0.3181, indicator);
78-
skip_control { CX(index[0], indicator); }
81+
skip_control { CX(value[0], indicator); }
7982
RY(0.4649, indicator);
80-
skip_control { CX(index[3], indicator); }
83+
skip_control { CX(value[3], indicator); }
8184
RY(-0.0475, indicator);
82-
skip_control { CX(index[0], indicator); }
85+
skip_control { CX(value[0], indicator); }
8386
RY(-0.0475, indicator);
84-
skip_control { CX(index[1], indicator); }
87+
skip_control { CX(value[1], indicator); }
8588
RY(-0.3407, indicator);
86-
skip_control { CX(index[0], indicator); }
89+
skip_control { CX(value[0], indicator); }
8790
RY(0.2457, indicator);
88-
skip_control { CX(index[2], indicator); }
91+
skip_control { CX(value[2], indicator); }
8992
RY(-0.0939, indicator);
90-
skip_control { CX(index[0], indicator); }
93+
skip_control { CX(value[0], indicator); }
9194
RY(-0.0939, indicator);
92-
skip_control { CX(index[1], indicator); }
95+
skip_control { CX(value[1], indicator); }
9396
RY(-0.3122, indicator);
94-
skip_control { CX(index[0], indicator); }
97+
skip_control { CX(value[0], indicator); }
9598
RY(0.8154, indicator);
96-
skip_control { CX(index[3], indicator); }
99+
skip_control { CX(value[3], indicator); }
97100
}
98101

99102
qfunc main(output solution: qnum<2, False, 0>, output phase_var: qnum<4, True, 4>, output indicator: qbit) {

0 commit comments

Comments
 (0)