Skip to content

Commit 2edea9d

Browse files
committed
Add qmod file to arithmetic expression
1 parent 218201c commit 2edea9d

File tree

3 files changed

+56
-5
lines changed

3 files changed

+56
-5
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
qfunc main(output a: qnum, output b: qnum, output c: qnum, output res: qnum) {
2+
a = 2;
3+
b = 1;
4+
c = 5;
5+
res = ((((((a + b) + c) & 15) % 8) ^ (3 & a)) ^ 10) == 4;
6+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"constraints": {
3+
"max_gate_count": {},
4+
"optimization_parameter": "no_opt"
5+
},
6+
"preferences": {
7+
"custom_hardware_settings": {
8+
"basis_gates": [
9+
"cx",
10+
"z",
11+
"ry",
12+
"p",
13+
"y",
14+
"t",
15+
"u",
16+
"rx",
17+
"sx",
18+
"rz",
19+
"tdg",
20+
"h",
21+
"u2",
22+
"sdg",
23+
"u1",
24+
"x",
25+
"s",
26+
"sxdg",
27+
"cy",
28+
"id",
29+
"cz",
30+
"r"
31+
],
32+
"is_symmetric_connectivity": true
33+
},
34+
"debug_mode": true,
35+
"machine_precision": 8,
36+
"optimization_level": 1,
37+
"output_format": ["qasm"],
38+
"pretty_qasm": true,
39+
"random_seed": 4204419628,
40+
"synthesize_all_separately": false,
41+
"timeout_seconds": 300,
42+
"transpilation_option": "auto optimize"
43+
}
44+
}

functions/function_usage_examples/arithmetic/arithmetic_expression/arithmetic_expression_example.ipynb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
},
6262
{
6363
"cell_type": "code",
64-
"execution_count": 1,
64+
"execution_count": 4,
6565
"id": "2",
6666
"metadata": {},
6767
"outputs": [],
@@ -78,22 +78,23 @@
7878
" res |= (a + b + c & 15) % 8 ^ 3 & a ^ 10 == 4\n",
7979
"\n",
8080
"\n",
81-
"qmod = create_model(main)"
81+
"qmod = create_model(main)\n",
82+
"write_qmod(qmod, \"arithmetic_expression\")"
8283
]
8384
},
8485
{
8586
"cell_type": "code",
86-
"execution_count": 2,
87+
"execution_count": 5,
8788
"id": "3",
8889
"metadata": {},
8990
"outputs": [
9091
{
9192
"data": {
9293
"text/plain": [
93-
"[{'a': 2.0, 'b': 1.0, 'c': 5.0, 'res': 0.0}: 1000]"
94+
"[{'a': 2, 'b': 1, 'c': 5, 'res': 0}: 2048]"
9495
]
9596
},
96-
"execution_count": 2,
97+
"execution_count": 5,
9798
"metadata": {},
9899
"output_type": "execute_result"
99100
}

0 commit comments

Comments
 (0)