Skip to content

Commit

Permalink
Fix .qmod files
Browse files Browse the repository at this point in the history
  • Loading branch information
matanvax2 committed Jan 5, 2025
1 parent cb474aa commit 54d2faa
Show file tree
Hide file tree
Showing 24 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion algorithms/algebraic/discrete_log/discrete_log.qmod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
qfunc discrete_log_oracle(g_generator: int, x_element: int, N_modulus: int, x1: qbit[], x2: qbit[], output func_res: qbit[]) {
allocate(ceiling(log(N_modulus, 2)), func_res);
inplace_prepare_int(1, func_res);
func_res ^= 1;
modular_exp(N_modulus, x_element, func_res, x1);
modular_exp(N_modulus, g_generator, func_res, x2);
}
Expand Down
2 changes: 1 addition & 1 deletion algorithms/algebraic/discrete_log/discrete_log_large.qmod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
qfunc discrete_log_oracle(g_generator: int, x_element: int, N_modulus: int, x1: qbit[], x2: qbit[], output func_res: qbit[]) {
allocate(ceiling(log(N_modulus, 2)), func_res);
inplace_prepare_int(1, func_res);
func_res ^= 1;
modular_exp(N_modulus, x_element, func_res, x1);
modular_exp(N_modulus, g_generator, func_res, x2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ qfunc main(output b: qnum, output ctrl: qbit[2], output aux: qbit) {
allocate(5, b);
allocate(2, ctrl);
allocate(1, aux);
inplace_prepare_int(8, b);
b ^= 8;
X(ctrl[0]);
X(ctrl[1]);
within {
Expand Down
2 changes: 1 addition & 1 deletion algorithms/algebraic/shor/shor_modular_exponentiation.qmod
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ qfunc main(output x: qbit[], output power: qbit[6], output aux: qbit) {
allocate(6, power);
allocate(1, aux);
hadamard_transform(power);
inplace_prepare_int(1, x);
x ^= 1;
mod_exp_func(6, 5, x, power, aux);
invert {
qft(power);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ qfunc long_time_integrator_step(a: real, b: real, qbe_full: FullBE) {
}

qfunc long_time_integrator(T: real, num_slices: int, qbe_full: FullBE) {
inplace_prepare_int(num_slices, qbe_full.counter);
qbe_full.counter ^= num_slices;
repeat (i: num_slices) {
long_time_integrator_step((i * T) / num_slices, ((i + 1) * T) / num_slices, qbe_full);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
qfunc main(output a: qnum, output b: qnum, output c: qnum, output res: qnum) {
prepare_int(2, a);
prepare_int(1, b);
prepare_int(5, c);
a = 2;
b = 1;
c = 5;
res = ((((((a + b) + c) & 15) % 8) ^ (3 & a)) ^ 10) == 4;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
qfunc main(output a: qnum, output b: qnum, output res: qnum) {
prepare_int(4, a);
prepare_int(5, b);
a = 4;
b = 5;
res = a & b;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
qfunc main(output a: qnum, output res: qnum) {
prepare_int(5, a);
a = 5;
res = 3 & a;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
qfunc main(output x: qnum, output y: qnum) {
prepare_int(6, x);
x = 6;
y = ~x;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
qfunc main(output a: qnum, output b: qnum, output res: qnum) {
allocate_num(5, True, 0, a);
allocate_num(3, False, 0, b);
inplace_prepare_int(4, a);
inplace_prepare_int(5, b);
a ^= 4;
b ^= 5;
res = a | b;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
qfunc main(output a: qnum, output res: qnum) {
prepare_int(4, a);
a = 4;
res = 3 | a;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
qfunc main(output a: qnum, output b: qnum, output res: qnum) {
allocate_num(5, True, 0, a);
allocate_num(3, False, 0, b);
inplace_prepare_int(4, a);
inplace_prepare_int(5, b);
a ^= 4;
b ^= 5;
res = a ^ b;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
qfunc main(output a: qnum, output res: qnum) {
prepare_int(4, a);
a = 4;
res = 3 ^ a;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
qfunc main(output a: qnum, output b: qnum, output res: qnum) {
prepare_int(4, a);
a = 4;
allocate(3, b);
hadamard_transform(b);
res = min(a, b);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
qfunc main(output power: qnum, output x: qnum) {
allocate(ceiling(log(5, 2)), x);
inplace_prepare_int(1, x);
x ^= 1;
allocate(3, power);
hadamard_transform(power);
modular_exp(5, 4, x, power);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
qfunc main(output a: qnum, output b: qnum, output res: qnum) {
allocate(5, a);
allocate(5, b);
inplace_prepare_int(4, a);
inplace_prepare_int(7, b);
a ^= 4;
b ^= 7;
res = (a + b) % 4;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
qfunc main(output a: qnum, output b: qnum, output res: qnum) {
prepare_int(4, a);
prepare_int(5, b);
a = 4;
b = 5;
res = a * b;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
qfunc main(output a: qnum, output b: qnum, output res: qnum) {
prepare_int(4, a);
prepare_int(5, b);
a = 4;
b = 5;
res = a - b;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
qfunc main(output a: qnum, output res: qnum) {
prepare_int(4, a);
a = 4;
res = a - 3.5;
}
2 changes: 1 addition & 1 deletion functions/open_library_definitions/prepare_bell_state.qmod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
qfunc prepare_bell_state(state_num: int, output q: qbit[2]) {
allocate(2, q);
inplace_prepare_int(state_num, q);
q ^= state_num;
H(q[0]);
CX(q[0], q[1]);
}
2 changes: 1 addition & 1 deletion functions/open_library_definitions/prepare_int.qmod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
qfunc prepare_int(value: int, output out: qnum<floor(log(value, 2)) + 1>) {
allocate(floor(log(value, 2)) + 1, out);
inplace_prepare_int(value, out);
out ^= value;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
qfunc main(output state: qbit[], output phase: qnum) {
allocate(2, state);
allocate_num(2, False, 2, phase);
inplace_prepare_int(3, state);
state ^= 3;
qpe(lambda() {
CRZ(pi, state[0], state[1]);
}, phase);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
qfunc main(output z: qnum) {
x: qnum;
y: qnum;
prepare_int(2, x);
prepare_int(1, y);
x = 2;
y = 1;
z = (((2 * x) + y) + max(3 * y, 2)) > 4;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
qfunc main(output z: qnum) {
x: qnum;
y: qnum;
prepare_int(2, x);
prepare_int(1, y);
x = 2;
y = 1;
z = (((2 * x) + y) + max(3 * y, 2)) > 4;
}

0 comments on commit 54d2faa

Please sign in to comment.