Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions algorithms/algebraic/shor/doubly_controlled_modular_adder.qmod
Original file line number Diff line number Diff line change
Expand Up @@ -33,41 +33,44 @@ qfunc check_msb(ref: int, x: qbit[], aux: qbit) {
}
}

qfunc ccmod_add(N: int, a: int, phi_b: qbit[], c1: qbit, c2: qbit, aux: qbit) {
qfunc ccmod_add(N: int, a: int, phi_b: qbit[], c1: qbit, c2: qbit) {
ctrl: qbit[];
{c1, c2} -> ctrl;
control (ctrl) {
phase_lad(a, phi_b);
}
invert {
phase_lad(N, phi_b);
}
check_msb(1, phi_b, aux);
control (aux) {
phase_lad(N, phi_b);
}
aux: qbit;
within {
allocate(1, aux);
{c1, c2} -> ctrl;
} apply {
control (ctrl) {
phase_lad(a, phi_b);
}
invert {
control (ctrl) {
phase_lad(a, phi_b);
phase_lad(N, phi_b);
}
check_msb(1, phi_b, aux);
control (aux) {
phase_lad(N, phi_b);
}
within {
invert {
control (ctrl) {
phase_lad(a, phi_b);
}
}
} apply {
check_msb(0, phi_b, aux);
}
} apply {
check_msb(0, phi_b, aux);
}
ctrl -> {c1, c2};
}

qfunc main(output b: qnum, output ctrl: qbit[2], output aux: qbit) {
qfunc main(output b: qnum, output ctrl: qbit[2]) {
allocate(5, b);
allocate(2, ctrl);
allocate(1, aux);
b ^= 8;
X(ctrl[0]);
X(ctrl[1]);
within {
qft(b);
} apply {
ccmod_add(15, 9, b, ctrl[0], ctrl[1], aux);
ccmod_add(15, 9, b, ctrl[0], ctrl[1]);
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,46 @@
{}
{
"constraints": {
"max_gate_count": {},
"optimization_parameter": "no_opt"
},
"preferences": {
"machine_precision": 8,
"custom_hardware_settings": {
"basis_gates": [
"tdg",
"ry",
"s",
"rz",
"u2",
"sx",
"rx",
"x",
"cy",
"z",
"id",
"sxdg",
"h",
"u1",
"p",
"t",
"cz",
"u",
"y",
"cx",
"sdg",
"r"
],
"is_symmetric_connectivity": true
},
"debug_mode": true,
"synthesize_all_separately": false,
"optimization_level": 3,
"output_format": [
"qasm"
],
"pretty_qasm": true,
"transpilation_option": "auto optimize",
"timeout_seconds": 300,
"random_seed": 3980209272
}
}
Loading
Loading