Skip to content

Commit 8a681e5

Browse files
umer066orsa-classiq
authored andcommitted
resolved_conflicts
1 parent bc75272 commit 8a681e5

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

algorithms/algebraic/discrete_log/discrete_log.ipynb

+18-18
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
},
6666
{
6767
"cell_type": "code",
68-
"execution_count": 1,
68+
"execution_count": 7,
6969
"id": "2bbc4aa3-8f61-433d-a1cd-c58df445a2fd",
7070
"metadata": {
7171
"execution": {
@@ -92,20 +92,20 @@
9292
"\n",
9393
"@qfunc\n",
9494
"def discrete_log_oracle(\n",
95-
" g: CInt,\n",
96-
" x: CInt,\n",
97-
" N: CInt,\n",
95+
" g_generator: CInt,\n",
96+
" x_logarithm: CInt,\n",
97+
" N_modulus: CInt,\n",
9898
" order: CInt,\n",
9999
" x1: QArray[QBit],\n",
100100
" x2: QArray[QBit],\n",
101101
" func_res: Output[QArray[QBit]],\n",
102102
") -> None:\n",
103103
"\n",
104-
" allocate(ceiling(log(N, 2)), func_res)\n",
104+
" allocate(ceiling(log(N_modulus, 2)), func_res)\n",
105105
"\n",
106106
" inplace_prepare_int(1, func_res)\n",
107-
" modular_exp(N, x, func_res, x1)\n",
108-
" modular_exp(N, g, func_res, x2)"
107+
" modular_exp(N_modulus, x_logarithm, func_res, x1)\n",
108+
" modular_exp(N_modulus, g_generator, func_res, x2)"
109109
]
110110
},
111111
{
@@ -122,7 +122,7 @@
122122
},
123123
{
124124
"cell_type": "code",
125-
"execution_count": 2,
125+
"execution_count": 8,
126126
"id": "d7fb63ac-023d-40ac-9395-13c1274d446f",
127127
"metadata": {
128128
"execution": {
@@ -140,9 +140,9 @@
140140
"\n",
141141
"@qfunc\n",
142142
"def discrete_log(\n",
143-
" g: CInt,\n",
144-
" x: CInt,\n",
145-
" N: CInt,\n",
143+
" g_generator: CInt,\n",
144+
" x_logarithm: CInt,\n",
145+
" N_modulus: CInt,\n",
146146
" order: CInt,\n",
147147
" x1: Output[QArray[QBit]],\n",
148148
" x2: Output[QArray[QBit]],\n",
@@ -155,7 +155,7 @@
155155
" hadamard_transform(x1)\n",
156156
" hadamard_transform(x2)\n",
157157
"\n",
158-
" discrete_log_oracle(g, x, N, order, x1, x2, func_res)\n",
158+
" discrete_log_oracle(g_generator, x_logarithm, N_modulus, order, x1, x2, func_res)\n",
159159
"\n",
160160
" invert(lambda: qft(x1))\n",
161161
" invert(lambda: qft(x2))"
@@ -209,7 +209,7 @@
209209
},
210210
{
211211
"cell_type": "code",
212-
"execution_count": 3,
212+
"execution_count": 9,
213213
"id": "8ef24bb4-b063-42d6-a5ea-ddcd5310ae13",
214214
"metadata": {
215215
"execution": {
@@ -224,8 +224,8 @@
224224
"from classiq import Constraints, create_model\n",
225225
"\n",
226226
"MODULU_NUM = 5\n",
227-
"G = 3\n",
228-
"X = 2\n",
227+
"G_GENERATOR = 3\n",
228+
"X_LOGARITHM = 2\n",
229229
"ORDER = MODULU_NUM - 1 # as 5 is prime\n",
230230
"\n",
231231
"\n",
@@ -235,12 +235,12 @@
235235
" x2: Output[QNum],\n",
236236
" func_res: Output[QNum],\n",
237237
") -> None:\n",
238-
" discrete_log(G, X, MODULU_NUM, ORDER, x1, x2, func_res)"
238+
" discrete_log(G_GENERATOR, X_LOGARITHM, MODULU_NUM, ORDER, x1, x2, func_res)"
239239
]
240240
},
241241
{
242242
"cell_type": "code",
243-
"execution_count": 4,
243+
"execution_count": 10,
244244
"id": "8e9d0b08-f3f8-4e95-a468-bfeec010d97c",
245245
"metadata": {
246246
"execution": {
@@ -272,7 +272,7 @@
272272
},
273273
{
274274
"cell_type": "code",
275-
"execution_count": 5,
275+
"execution_count": 11,
276276
"id": "0aef2760-aa9a-4710-8c60-08333a0a9b0b",
277277
"metadata": {
278278
"execution": {
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
qfunc discrete_log_oracle<g: int, x: int, N: int, order: int>(x1: qbit[], x2: qbit[], output func_res: qbit[]) {
2-
allocate<ceiling(log(N, 2))>(func_res);
1+
qfunc discrete_log_oracle<g_generator: int, x_logarithm: int, N_modulus: int, order: int>(x1: qbit[], x2: qbit[], output func_res: qbit[]) {
2+
allocate<ceiling(log(N_modulus, 2))>(func_res);
33
inplace_prepare_int<1>(func_res);
4-
modular_exp<N, x>(func_res, x1);
5-
modular_exp<N, g>(func_res, x2);
4+
modular_exp<N_modulus, x_logarithm>(func_res, x1);
5+
modular_exp<N_modulus, g_generator>(func_res, x2);
66
}
77

8-
qfunc discrete_log<g: int, x: int, N: int, order: int>(output x1: qbit[], output x2: qbit[], output func_res: qbit[]) {
8+
qfunc discrete_log<g_generator: int, x_logarithm: int, N_modulus: int, order: int>(output x1: qbit[], output x2: qbit[], output func_res: qbit[]) {
99
allocate<ceiling(log(order, 2))>(x1);
1010
allocate<ceiling(log(order, 2))>(x2);
1111
hadamard_transform(x1);
1212
hadamard_transform(x2);
13-
discrete_log_oracle<g, x, N, order>(x1, x2, func_res);
13+
discrete_log_oracle<g_generator, x_logarithm, N_modulus, order>(x1, x2, func_res);
1414
invert {
1515
qft(x1);
1616
}
@@ -22,3 +22,4 @@ qfunc discrete_log<g: int, x: int, N: int, order: int>(output x1: qbit[], output
2222
qfunc main(output x1: qnum, output x2: qnum, output func_res: qnum) {
2323
discrete_log<3, 2, 5, 4>(x1, x2, func_res);
2424
}
25+

0 commit comments

Comments
 (0)