Skip to content

Commit 38af607

Browse files
Change standard gates examples to have main outputs
1 parent 5d4bbcf commit 38af607

File tree

10 files changed

+18
-42
lines changed

10 files changed

+18
-42
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
qfunc main() {
2-
q_target: qbit;
1+
qfunc main(output q_target: qbit, output q_control: qbit) {
32
allocate(q_target);
4-
q_control: qbit;
53
allocate(q_control);
64
CRX(1, q_control, q_target);
75
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
qfunc main() {
2-
q_target: qbit;
1+
qfunc main(output q_target: qbit, output q_control: qbit) {
32
allocate(q_target);
4-
q_control: qbit;
53
allocate(q_control);
64
CX(q_control, q_target);
75
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
qfunc main() {
2-
q: qbit;
1+
qfunc main(output q: qbit) {
32
allocate(q);
43
PHASE(1, q);
54
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
qfunc main() {
2-
q: qbit;
1+
qfunc main(output q: qbit) {
32
allocate(q);
43
R(1, 2, q);
54
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
qfunc main() {
2-
q: qbit;
1+
qfunc main(output q: qbit) {
32
allocate(q);
43
RZ(1.9, q);
54
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
qfunc main() {
2-
q: qbit[];
1+
qfunc main(output q: qbit[]) {
32
allocate(2, q);
43
RZZ(1, q);
54
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
qfunc main() {
2-
q1: qbit;
1+
qfunc main(output q1: qbit, output q2: qbit) {
32
allocate(q1);
4-
q2: qbit;
53
allocate(q2);
64
SWAP(q1, q2);
75
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
qfunc main() {
2-
q: qbit;
1+
qfunc main(output q: qbit) {
32
allocate(q);
43
U(1, 2, 1.5, 1.1, q);
54
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
qfunc main() {
2-
q: qbit;
1+
qfunc main(output q: qbit) {
32
allocate(q);
43
X(q);
54
}

functions/qmod_library_reference/qmod_core_library/standard_gates/standard_gates.ipynb

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@
5353
"outputs": [],
5454
"source": [
5555
"@qfunc\n",
56-
"def main():\n",
57-
" q = QBit()\n",
56+
"def main(q: Output[QBit]):\n",
5857
" allocate(q)\n",
5958
"\n",
6059
" X(q)\n",
@@ -110,8 +109,7 @@
110109
"outputs": [],
111110
"source": [
112111
"@qfunc\n",
113-
"def main():\n",
114-
" q = QBit()\n",
112+
"def main(q: Output[QBit]):\n",
115113
" allocate(q)\n",
116114
"\n",
117115
" theta = 1.9\n",
@@ -153,8 +151,7 @@
153151
"outputs": [],
154152
"source": [
155153
"@qfunc\n",
156-
"def main():\n",
157-
" q = QBit()\n",
154+
"def main(q: Output[QBit]):\n",
158155
" allocate(q)\n",
159156
"\n",
160157
" theta = 1\n",
@@ -193,8 +190,7 @@
193190
"outputs": [],
194191
"source": [
195192
"@qfunc\n",
196-
"def main():\n",
197-
" q = QBit()\n",
193+
"def main(q: Output[QBit]):\n",
198194
" allocate(q)\n",
199195
"\n",
200196
" theta = 1\n",
@@ -242,8 +238,7 @@
242238
"outputs": [],
243239
"source": [
244240
"@qfunc\n",
245-
"def main():\n",
246-
" q = QArray()\n",
241+
"def main(q: Output[QArray]):\n",
247242
" allocate(2, q)\n",
248243
"\n",
249244
" theta = 1\n",
@@ -296,11 +291,9 @@
296291
"outputs": [],
297292
"source": [
298293
"@qfunc\n",
299-
"def main():\n",
300-
" q_target = QBit()\n",
294+
"def main(q_target: Output[QBit], q_control: Output[QBit]):\n",
301295
" allocate(q_target)\n",
302296
"\n",
303-
" q_control = QBit()\n",
304297
" allocate(q_control)\n",
305298
"\n",
306299
" CX(q_control, q_target)\n",
@@ -347,11 +340,9 @@
347340
"outputs": [],
348341
"source": [
349342
"@qfunc\n",
350-
"def main():\n",
351-
" q_target = QBit()\n",
343+
"def main(q_target: Output[QBit], q_control: Output[QBit]):\n",
352344
" allocate(q_target)\n",
353345
"\n",
354-
" q_control = QBit()\n",
355346
" allocate(q_control)\n",
356347
"\n",
357348
" theta = 1\n",
@@ -394,11 +385,9 @@
394385
"outputs": [],
395386
"source": [
396387
"@qfunc\n",
397-
"def main():\n",
398-
" q1 = QBit()\n",
388+
"def main(q1: Output[QBit], q2: Output[QBit]):\n",
399389
" allocate(q1)\n",
400390
"\n",
401-
" q2 = QBit()\n",
402391
" allocate(q2)\n",
403392
"\n",
404393
" SWAP(q1, q2)\n",
@@ -443,8 +432,7 @@
443432
"outputs": [],
444433
"source": [
445434
"@qfunc\n",
446-
"def main():\n",
447-
" q = QBit()\n",
435+
"def main(q: Output[QBit]):\n",
448436
" allocate(q)\n",
449437
"\n",
450438
" theta = 1\n",

0 commit comments

Comments
 (0)