Skip to content

Commit a4d7690

Browse files
committed
Eliminate use of prepare_int()
1 parent 02101c9 commit a4d7690

File tree

15 files changed

+23
-193
lines changed

15 files changed

+23
-193
lines changed

algorithms/dqi/dqi_max_xorsat.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
"@qfunc\n",
241241
"def main(one_hot: Output[QArray]):\n",
242242
" binary = QNum(\"binary\")\n",
243-
" prepare_int(8, binary)\n",
243+
" binary |= 8\n",
244244
" binary_to_unary(binary, one_hot)\n",
245245
"\n",
246246
"\n",

community/QClass_2024/Assignments/HW1_QClass2024.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@
343343
"See also [control](https://docs.classiq.io/latest/qmod-reference/language-reference/operators/).\n",
344344
"\n",
345345
"1. Declare a `QNum` output argument using `Output[QNum]` and name it `x`.\n",
346-
"2. Use the `prepare_int` function to initialize it to `9`. Note that you don't need to specify the `QNum` attributes - size, sign, and fraction digits, as they are inferred at the point of initialization.\n",
346+
"2. Use numeric assignment (`|=`) to initialize it to `9`. Note that you don't need to specify the `QNum` attributes - size, sign, and fraction digits, as they are inferred at the point of initialization.\n",
347347
"3. Execute the circuit and observe the results.\n",
348348
"4. Declare another output argument of type `QBit` and perform a `control` such that under the condition that `x` is 9, the qubit is flipped. Execute the circuit and observe the results. Repeat for a different condition."
349349
]

community/QClass_2024/Assignments/HW2_QClass2024.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@
131131
"3. Initialize variables `x=2`, `y=7`, `z=1` and computes `res = x * y - z`.\n",
132132
"\n",
133133
"Guidance:\n",
134-
"* Use the operator `|=` to perform out-of-place assignment of arithmetic expression.\n",
135-
"* To initialize the variables, use the function `prepare_int`.\n"
134+
"* Use the operator `|=` to perform out-of-place assignment of an arithmetic expression (including classical numeric values).\n"
136135
]
137136
},
138137
{

community/QClass_2024/Sessions/week1_QClass_workshop_with_sol.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@
345345
"See also [control](https://docs.classiq.io/latest/qmod-reference/language-reference/operators/).\n",
346346
"\n",
347347
"1. Declare a `QNum` output argument using `Output[QNum]` and name it `x`.\n",
348-
"2. Use the `prepare_int` function to initialize it to `9`. Note that you don't need to specify the `QNum` attributes - size, sign, and fraction digits, as they are inferred at the point of initialization.\n",
348+
"2. Use numeric assignment (`|=`) to initialize it to `9`. Note that you don't need to specify the `QNum` attributes - size, sign, and fraction digits, as they are inferred at the point of initialization.\n",
349349
"3. Execute the circuit and observe the results.\n",
350350
"4. Declare another output argument of type `QBit` and perform a `control` such that under the condition that `x` is 9, the qubit is flipped. Execute the circuit and observe the results. Repeat for a different condition."
351351
]
@@ -479,7 +479,7 @@
479479
"@qfunc\n",
480480
"def main(res: Output[QNum]) -> None:\n",
481481
" x = QNum(\"x\")\n",
482-
" prepare_int(7, x)\n",
482+
" x |= 7\n",
483483
"\n",
484484
" y = QNum(\"y\")\n",
485485
" prepare_state(probabilities=[1 / 3, 0, 0, 0, 1 / 3, 0, 0, 1 / 3], bound=0.01, out=y)\n",

functions/function_usage_examples/arithmetic/arithmetic_expression/arithmetic_expression_example.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@
7878
"\n",
7979
"@qfunc\n",
8080
"def main(a: Output[QNum], b: Output[QNum], c: Output[QNum], res: Output[QNum]) -> None:\n",
81-
" prepare_int(2, a)\n",
82-
" prepare_int(1, b)\n",
83-
" prepare_int(5, c)\n",
81+
" a |= 2\n",
82+
" b |= 1\n",
83+
" c |= 5\n",
8484
"\n",
8585
" res |= (a + b + c & 15) % 8 ^ 3 & a ^ 10 == 4\n",
8686
"\n",

functions/function_usage_examples/arithmetic/bitwise_and/bitwise_and_example.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
"\n",
6767
"@qfunc\n",
6868
"def main(a: Output[QNum], b: Output[QNum], res: Output[QNum]) -> None:\n",
69-
" prepare_int(4, a)\n",
70-
" prepare_int(5, b)\n",
69+
" a |= 4\n",
70+
" b |= 5\n",
7171
" res |= a & b\n",
7272
"\n",
7373
"\n",
@@ -133,7 +133,7 @@
133133
"source": [
134134
"@qfunc\n",
135135
"def main(a: Output[QNum], res: Output[QNum]) -> None:\n",
136-
" prepare_int(5, a)\n",
136+
" a |= 5\n",
137137
" res |= 3 & a\n",
138138
"\n",
139139
"\n",

functions/function_usage_examples/arithmetic/bitwise_invert/bitwise_invert_example.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"\n",
3939
"@qfunc\n",
4040
"def main(x: Output[QNum], y: Output[QNum]) -> None:\n",
41-
" prepare_int(6, x)\n",
41+
" x |= 6\n",
4242
"\n",
4343
" y |= ~x\n",
4444
"\n",

functions/function_usage_examples/arithmetic/bitwise_or/bitwise_or_example.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
"source": [
136136
"@qfunc\n",
137137
"def main(a: Output[QNum], res: Output[QNum]) -> None:\n",
138-
" prepare_int(4, a)\n",
138+
" a |= 4\n",
139139
" res |= 3 | a\n",
140140
"\n",
141141
"\n",

functions/function_usage_examples/arithmetic/bitwise_xor/bitwise_xor_example.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
"source": [
136136
"@qfunc\n",
137137
"def main(a: Output[QNum], res: Output[QNum]) -> None:\n",
138-
" prepare_int(4, a)\n",
138+
" a |= 4\n",
139139
" res |= 3 ^ a\n",
140140
"\n",
141141
"\n",

functions/function_usage_examples/arithmetic/extremum/extremum_example.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"\n",
4545
"@qfunc\n",
4646
"def main(a: Output[QNum], b: Output[QNum], res: Output[QNum]) -> None:\n",
47-
" prepare_int(4, a)\n",
47+
" a |= 4\n",
4848
" allocate(3, b)\n",
4949
" hadamard_transform(b)\n",
5050
"\n",

0 commit comments

Comments
 (0)