-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74299f5
commit fbf1316
Showing
42 changed files
with
35,808 additions
and
35,808 deletions.
There are no files selected for viewing
44,842 changes: 22,421 additions & 22,421 deletions
44,842
Algorithms/Boolean_Formula/boolean_formula.x2y2.scaffold
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
|
||
// Class Number Algorithm -- Phase I (estimate the regulator) | ||
// | ||
// | ||
// As specified in the GFI, inputs here are S and \Delta (the discriminant) | ||
// We assume we have jp, q, t, lgdelta and bound (all classically generated) | ||
// | ||
// (bound = i/N + jp/L, where i iterates classically as described in 4.1.1 | ||
// of the GFI) | ||
// | ||
cnp1(delta, jp, q, t, bound) | ||
{ | ||
qreg in[q]; | ||
qreg out[t]; | ||
bit res[t]; | ||
bit period[q]; | ||
qreg dist[lgdelta]; | ||
|
||
gfor (i=0; i < q; i++) | ||
{ | ||
zprepare(in[i], 0); // init qubits to |0> | ||
H(in[i]); // put into uniform superposition | ||
} | ||
|
||
gfor (i=0; i < t; i++) | ||
zprepare(out[i], 0); // init output qubits to |0> | ||
|
||
fn(bound, delta, j, out[0..t-1], dist); // oracle call | ||
|
||
// now measure the output of our oracle | ||
for (i=0; i < t; i++) | ||
measX(out[i], res[i]); | ||
|
||
qft(in); | ||
|
||
// and measure to get period | ||
for (i=0; i < q; i++) | ||
measX(int[i], period[i]); | ||
} | ||
|
||
// Class Number Algorithm -- Phase I (estimate the regulator) | ||
// | ||
// | ||
// As specified in the GFI, inputs here are S and \Delta (the discriminant) | ||
// We assume we have jp, q, t, lgdelta and bound (all classically generated) | ||
// | ||
// (bound = i/N + jp/L, where i iterates classically as described in 4.1.1 | ||
// of the GFI) | ||
// | ||
cnp1(delta, jp, q, t, bound) | ||
{ | ||
qreg in[q]; | ||
qreg out[t]; | ||
bit res[t]; | ||
bit period[q]; | ||
qreg dist[lgdelta]; | ||
|
||
gfor (i=0; i < q; i++) | ||
{ | ||
zprepare(in[i], 0); // init qubits to |0> | ||
H(in[i]); // put into uniform superposition | ||
} | ||
|
||
gfor (i=0; i < t; i++) | ||
zprepare(out[i], 0); // init output qubits to |0> | ||
|
||
fn(bound, delta, j, out[0..t-1], dist); // oracle call | ||
|
||
// now measure the output of our oracle | ||
for (i=0; i < t; i++) | ||
measX(out[i], res[i]); | ||
|
||
qft(in); | ||
|
||
// and measure to get period | ||
for (i=0; i < q; i++) | ||
measX(int[i], period[i]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,108 @@ | ||
|
||
// Class Number Algorithm -- Phase II (structure of the class group) | ||
// | ||
// Sect 6 of the GFI indicates the inputs to Phase II are delta, the | ||
// approximation of the regulator R (from Phase I), and q, k, N, and M. | ||
// | ||
// We further assume that the classical step of producing k generators | ||
// g[0], ..., g[k-1], was done (see GFI section 4.1.3) | ||
// | ||
// Finally, we assume the classical precomputation of logdelta = | ||
// ceiling(log_2(delta)), lognr = ceiling(log_2(N*R), logm = ceiling(log_2(M)) | ||
// sdelta = sqrt(Delta), and the jitter jp, and bound (see cnp1.c) | ||
// | ||
// res is the output array for the k q-qubit results | ||
// | ||
// See 4.1.4 of the GFI for details | ||
// | ||
cnp2(delta, q, k, g, R, N, M, logdelta, lognr, logm, sdelta, jp, bound, res) | ||
{ | ||
qreg in[q*k]; // input registers | ||
qreg I[logdelta]; | ||
qreg i[lognr]; | ||
qreg j[lognr]; | ||
qreg fout[logdelta+lognr]; | ||
qreg x[logm + lognr]; | ||
qreg y[lognr]; | ||
qreg size[logdelta+lognr]; | ||
qreg dist[lgdelta]; | ||
qreg found[1]; | ||
qreg c1[logm + lognr]; | ||
qreg c2[logm + lognr]; | ||
qreg d1[lognr]; | ||
qreg d2[lognr]; | ||
qreg a[logm + lognr]; | ||
qreg b[lognr]; | ||
|
||
gfor (i=0; i < q*k; i++) | ||
{ | ||
zprepare(in[i], 0); // init qubits to |0> | ||
H(in[i]); // put into uniform superposition | ||
} | ||
zprepare(I); // prepare all 6 output registers | ||
zprepare(i); | ||
zprepare(fout); | ||
zprepare(x); | ||
zprepare(y); | ||
zprepare(size); | ||
|
||
|
||
ghat(I, g, in, k, delta, sdelta); // oracle that produces I | ||
|
||
H(i); // put i into uniform superposition | ||
|
||
fjn(bound, delta, sdelta, I, in[q..q+t-1], dist); | ||
|
||
do { | ||
do { | ||
H(x); | ||
H(y); | ||
h(x, y, bound, delta, sdelta, i, size, dist); | ||
|
||
// measure the output of our oracle | ||
for (i=0; i < logdelta+lognr; i++) | ||
measX(size[i], result[i]); | ||
|
||
qft(x); | ||
qft(y); | ||
|
||
for (i=0; i < logm+lognr; i++) | ||
measX(x[i], c1[i]); | ||
|
||
for (i=0; i < lognr; i++) | ||
measX(y[i], d1[i]); | ||
|
||
H(x); | ||
H(y); | ||
h(x, y, bound, delta, sdelta, i, size, dist); | ||
|
||
// measure the output of our oracle | ||
for (i=0; i < logdelta+lognr; i++) | ||
measX(size[i], result[i]); | ||
|
||
qft(x); | ||
qft(y); | ||
|
||
for (i=0; i < logm+lognr; i++) | ||
measX(x[i], c2[i]); | ||
|
||
for (i=0; i < lognr; i++) | ||
measX(y[i], d2[i]); | ||
} | ||
while (gcd(d1, d2, a, b) != 1); | ||
|
||
} while (xd(c1, c2, a, b, N, M, R) != dist); | ||
|
||
fjn(bound, delta, sdelta, I, in[q..q+t-1], dist); | ||
h(x, y, bound, delta, sdelta, i, size, dist); | ||
ghat(I, g, in, k, delta, sdelta); | ||
|
||
for (i=0; i < logdelta+lognr; i++) | ||
measX(fout[i], result[i]); | ||
|
||
qft(result); | ||
|
||
for (j=0; j < k; j++) | ||
for (i=0; i < q; i++) | ||
measX(in[j][i], res[j][i]); | ||
} | ||
|
||
// Class Number Algorithm -- Phase II (structure of the class group) | ||
// | ||
// Sect 6 of the GFI indicates the inputs to Phase II are delta, the | ||
// approximation of the regulator R (from Phase I), and q, k, N, and M. | ||
// | ||
// We further assume that the classical step of producing k generators | ||
// g[0], ..., g[k-1], was done (see GFI section 4.1.3) | ||
// | ||
// Finally, we assume the classical precomputation of logdelta = | ||
// ceiling(log_2(delta)), lognr = ceiling(log_2(N*R), logm = ceiling(log_2(M)) | ||
// sdelta = sqrt(Delta), and the jitter jp, and bound (see cnp1.c) | ||
// | ||
// res is the output array for the k q-qubit results | ||
// | ||
// See 4.1.4 of the GFI for details | ||
// | ||
cnp2(delta, q, k, g, R, N, M, logdelta, lognr, logm, sdelta, jp, bound, res) | ||
{ | ||
qreg in[q*k]; // input registers | ||
qreg I[logdelta]; | ||
qreg i[lognr]; | ||
qreg j[lognr]; | ||
qreg fout[logdelta+lognr]; | ||
qreg x[logm + lognr]; | ||
qreg y[lognr]; | ||
qreg size[logdelta+lognr]; | ||
qreg dist[lgdelta]; | ||
qreg found[1]; | ||
qreg c1[logm + lognr]; | ||
qreg c2[logm + lognr]; | ||
qreg d1[lognr]; | ||
qreg d2[lognr]; | ||
qreg a[logm + lognr]; | ||
qreg b[lognr]; | ||
|
||
gfor (i=0; i < q*k; i++) | ||
{ | ||
zprepare(in[i], 0); // init qubits to |0> | ||
H(in[i]); // put into uniform superposition | ||
} | ||
zprepare(I); // prepare all 6 output registers | ||
zprepare(i); | ||
zprepare(fout); | ||
zprepare(x); | ||
zprepare(y); | ||
zprepare(size); | ||
|
||
|
||
ghat(I, g, in, k, delta, sdelta); // oracle that produces I | ||
|
||
H(i); // put i into uniform superposition | ||
|
||
fjn(bound, delta, sdelta, I, in[q..q+t-1], dist); | ||
|
||
do { | ||
do { | ||
H(x); | ||
H(y); | ||
h(x, y, bound, delta, sdelta, i, size, dist); | ||
|
||
// measure the output of our oracle | ||
for (i=0; i < logdelta+lognr; i++) | ||
measX(size[i], result[i]); | ||
|
||
qft(x); | ||
qft(y); | ||
|
||
for (i=0; i < logm+lognr; i++) | ||
measX(x[i], c1[i]); | ||
|
||
for (i=0; i < lognr; i++) | ||
measX(y[i], d1[i]); | ||
|
||
H(x); | ||
H(y); | ||
h(x, y, bound, delta, sdelta, i, size, dist); | ||
|
||
// measure the output of our oracle | ||
for (i=0; i < logdelta+lognr; i++) | ||
measX(size[i], result[i]); | ||
|
||
qft(x); | ||
qft(y); | ||
|
||
for (i=0; i < logm+lognr; i++) | ||
measX(x[i], c2[i]); | ||
|
||
for (i=0; i < lognr; i++) | ||
measX(y[i], d2[i]); | ||
} | ||
while (gcd(d1, d2, a, b) != 1); | ||
|
||
} while (xd(c1, c2, a, b, N, M, R) != dist); | ||
|
||
fjn(bound, delta, sdelta, I, in[q..q+t-1], dist); | ||
h(x, y, bound, delta, sdelta, i, size, dist); | ||
ghat(I, g, in, k, delta, sdelta); | ||
|
||
for (i=0; i < logdelta+lognr; i++) | ||
measX(fout[i], result[i]); | ||
|
||
qft(result); | ||
|
||
for (j=0; j < k; j++) | ||
for (i=0; i < q; i++) | ||
measX(in[j][i], res[j][i]); | ||
} |
Oops, something went wrong.