-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshor_algorithm.html
More file actions
451 lines (437 loc) · 40.6 KB
/
shor_algorithm.html
File metadata and controls
451 lines (437 loc) · 40.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>QuPlayground - Shor algorithm</title>
<!--Gojs CDN-->
<script src="https://cdn.bootcss.com/gojs/1.8.20/go.js"></script>
<!--
<script src="https://cdnjs.cloudflare.com/ajax/libs/gojs/1.8.25/go-debug.js"></script>
-->
<!--Bootstrap CDN-->
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<link href="https://cdn.bootcss.com/bootstrap/4.1.1/css/bootstrap-grid.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/bootstrap/4.1.1/css/bootstrap-reboot.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/bootstrap/4.1.1/js/bootstrap.bundle.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/4.1.1/js/bootstrap.js"></script>
<link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">
<link href="json_syntax.css" rel="stylesheet">
<script src="json_syntax.js"></script>
<script src="qubit.js"></script>
<script id="code" src="main.js"></script>
</head>
<body onload="init()">
<div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-white border-bottom box-shadow">
<h3 class="my-0 mr-md-auto font-weight-normal"><a href="index.html">
<b>Qu</b>Playground</a></h3>
<nav class="my-2 my-md-0 mr-md-3">
<a class="p-2 text-dark" href="#">Developing</a>
</nav>
<a class="btn btn-outline-primary" href="https://github.com/camelop/QuPlayground">Github page</a>
</div>
<div id="main" class="container">
<div style="width: 100%; display: flex; justify-content: space-between">
<div id="myPaletteDiv" style="width: 150px; margin-right: 2px; background-color: whitesmoke; border: solid 1px black"></div>
<div id="myDiagramDiv" style="flex-grow: 1; height: 600px; border: solid 1px black"></div>
</div>
<button type="button" class="btn btn-primary" style="width:24%" onclick="save()">
Save
<i class="fa fa-download fa-1.5x"></i>
</button>
<button type="button" class="btn btn-secondary" style="width:24%" onclick="load()">
Load
<i class="fa fa-upload fa-1.5x"></i>
</button>
<button type="button" class="btn btn-success" style="width:24%" onclick="refresh()">
Refresh
<i class="fa fa-refresh fa-1.5x"></i>
</button>
<button type="button" class="btn btn-danger" style="width:24%" onclick="openRunModal()">
Run
<i class="fa fa-play-circle fa-1.5x"></i>
</button>
<br>
<textarea class="form-control" id="mySavedModel" style="width:100%;height:150px">
{ "class": "go.GraphLinksModel",
"nodeDataArray": [
{"key":"P1", "text":"Shor Algorithm", "isGroup":true, "category":"Program", "loc":"0 0"},
{"key":"P1S1", "text":"Step1", "isGroup":true, "group":"P1", "category":"Stage", "loc":"0 23.522847498307936", "size":"225.6201171875 481.512158203125"},
{"key":"P1S2", "text":"Step2", "isGroup":true, "group":"P1", "category":"Stage", "loc":"227 23.522847498307936", "size":"136.44189453125 481.512158203125"},
{"key":"a", "group":"P1S1", "category":"JSBB", "text":"factoring_to_order_finding", "isize":0, "osize":1, "code":"factoring_to_order_finding = function(input) {\n var N = input.n;\n var output = {};\n // check if N is even\n if ((N & 1) == 0) {\n output.success = true;\n output.a = 2;\n output.b = N/2;\n return output;\n }\n // check if N is prime\n Miller_Rabin = function(n) {\n var k = 30;\n var s = 0;\n var d = n-1;\n while ((d & 1) == 0) {\n d /= 2;\n ++s;\n }\n while (k--) {\n a = Math.floor(Math.random() * (n-5)) + 2;\n pow = function(base, index, M) {\n if (index == 1) return base % M;\n if ((index&1) == 0) {\n var u = pow(base, index/2, M);\n return (u * u) % M;\n } else {\n var u = pow(base, (index-1)/2, M);\n return (u * u * base) % M;\n }\n }\n x = pow(a, d, n);\n if (x == 1 || x == n-1) continue;\n var flag = true;\n for (r=1; r<s; ++r) {\n x = (x * x) % n;\n if (x == 1) return false;\n if (x == n - 1) {\n flag = false;\n break;\n }\n }\n if (flag) return false;\n }\n return true;\n }\n if (Miller_Rabin(N)) {\n output.success = false;\n output.message = \"Prime Input\";\n return output;\n }\n // check if N is a^b\n check_pow_a_b = function(n) {\n eps = 1e-6;\n prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47];\n // check if b%prime == 0\n for (i in prime) {\n nw = Math.pow(n, 1/prime[i]);\n if (Math.abs(Math.round(nw) - nw) < eps)\n return prime[i];\n }\n return false;\n }\n if (check_pow_a_b(N) != false) {\n output.success = true;\n var u = Math.round(Math.pow(N, 1/check_pow_a_b(N)));\n output.a = u;\n output.b = N/u;\n return output;\n }\n // then N = \\Sigma p_i ^ a_i\n var x = Math.floor(Math.random() * (N-2)) + 2;\n gcd = function(a, b) {\n if (b == 0) return a;\n return gcd(b, a%b);\n }\n if (gcd(N, x) > 1) {\n // lucky strike\n alert(\"LUCKY! gcd(\"+N+\", \"+x+\") = \"+gcd(N, x)+\". No need for Quantum circuit.\");\n output.success = true;\n output.a = gcd(N, x);\n output.b = N/gcd(N, x);\n return output;\n }\n // then Quantum circuit is used\n output.x = x;\n output.n = N;\n return output;\n}", "loc":"20 53.52284749830794"},
{"key":"b", "group":"P1S1", "category":"Qgate", "isize":0, "osize":1, "gtype":"|0>", "loc":"20 101.52284749830794"},
{"key":"e", "group":"P1S2", "category":"Qgate", "isize":1, "osize":1, "gtype":"Hadamard", "loc":"247 101.52284749830794"},
{"key":"base0_", "category":"Qgate", "isize":0, "osize":1, "gtype":"|0>", "loc":"20 149.52284749830795", "group":"P1S1"},
{"key":"P1S22", "text":"Step3", "isGroup":true, "group":"P1", "category":"Stage", "loc":"365 23.522847498307936", "size":"142.72607421875 481.512158203125"},
{"key":"baseJS_", "category":"JSBB", "text":"prepareU^1", "isize":0, "osize":0, "code":"prepareU1 = function(input) {\n if (typeof(input) == \"undefined\") throw \"Invalid Input while preparing U\";\n if (typeof(input.x) == \"undefined\") throw \"'x' not accepted while preparing U.\";\n var x = input.x;\n var index = 1;\n var size = 5; // controled U with U|y> = |xy%N>\n var u = [];\n // alloc\n for (var i=0; i<2**size; ++i) {\n var nw = [];\n for (var j=0; j<2**size; ++j) {\n nw.push([0,0])\n }\n u.push(nw);\n }\n for (var j=0; j<2**(size-1); ++j) {\n u[j][j] = [1, 0]; //highest bit is 0\n }\n var base = 2**(size-1);\n var power = function(m, n, N) {\n var ret = m%N;\n for (var i=1; i<n; ++i) {\n ret *= m;\n ret %= N;\n }\n return ret;\n }\n for (var j=0; j<2**(size-1); ++j) {\n u[base+j][base + (power(x, index, input.n) * j)%input.n] = [1, 0]; //highest bit is 0\n }\n console.log(\"generated U: \", u);\n input.u = u;\n return input;\n}", "loc":"247 53.52284749830794", "group":"P1S2"},
{"key":"P1S222", "text":"Step4", "isGroup":true, "group":"P1", "category":"Stage", "loc":"509 23.522847498307936", "size":"136.44189453125 481.512158203125"},
{"key":"baseJS_2", "category":"JSBB", "text":"prepareSwap", "isize":0, "osize":0, "code":"swap = function(input) {\n input.from = [0, 1];\n input.to = [1, 0];\n return input;\n}", "loc":"385 53.52284749830794", "group":"P1S22"},
{"key":"baseJS_3", "category":"JSBB", "text":"prepareU^2", "isize":0, "osize":0, "code":"prepareU2 = function(input) {\n if (typeof(input) == \"undefined\") throw \"Invalid Input while preparing U\";\n if (typeof(input.x) == \"undefined\") throw \"'x' not accepted while preparing U.\";\n var x = input.x;\n var index = 2;\n var size = 5; // controled U with U|y> = |xy%N>\n var u = [];\n // alloc\n for (var i=0; i<2**size; ++i) {\n var nw = [];\n for (var j=0; j<2**size; ++j) {\n nw.push([0,0])\n }\n u.push(nw);\n }\n for (var j=0; j<2**(size-1); ++j) {\n u[j][j] = [1, 0]; //highest bit is 0\n }\n var base = 2**(size-1);\n var power = function(m, n, N) {\n var ret = m%N;\n for (var i=1; i<n; ++i) {\n ret *= m;\n ret %= N;\n }\n return ret;\n }\n for (var j=0; j<2**(size-1); ++j) {\n u[base+j][base + (power(x, index, input.n) * j)%input.n] = [1, 0]; //highest bit is 0\n }\n input.u = u;\n return input;\n}", "loc":"529 53.52284749830794", "group":"P1S222"},
{"key":"P1S2222", "text":"Step5", "isGroup":true, "group":"P1", "category":"Stage", "loc":"647 23.522847498307936", "size":"142.72607421875 481.512158203125"},
{"key":"baseJS_32", "category":"JSBB", "text":"prepareSwap", "isize":0, "osize":0, "code":"swap = function(input) {\n input.from = [0, 1, 2];\n input.to = [2, 1, 0];\n return input;\n}", "loc":"667 53.52284749830794", "group":"P1S2222"},
{"key":"base0_3", "category":"Qgate", "isize":0, "osize":1, "gtype":"|0>", "loc":"20 389.52284749830795", "group":"P1S1"},
{"key":"base0_4", "category":"Qgate", "isize":0, "osize":1, "gtype":"|0>", "loc":"20 341.52284749830795", "group":"P1S1"},
{"key":"base0_5", "category":"Qgate", "isize":0, "osize":1, "gtype":"|0>", "loc":"20 293.52284749830795", "group":"P1S1"},
{"key":"base0_6", "category":"Qgate", "isize":0, "osize":1, "gtype":"|0>", "loc":"20 245.52284749830795", "group":"P1S1"},
{"key":"base0_7", "category":"Qgate", "isize":0, "osize":1, "gtype":"|0>", "loc":"20 197.52284749830795", "group":"P1S1"},
{"key":"e2", "group":"P1S2", "category":"Qgate", "isize":1, "osize":1, "gtype":"Hadamard", "loc":"247 245.52284749830795"},
{"key":"e3", "group":"P1S2", "category":"Qgate", "isize":1, "osize":1, "gtype":"Hadamard", "loc":"247 197.52284749830795"},
{"key":"e4", "group":"P1S2", "category":"Qgate", "isize":1, "osize":1, "gtype":"Hadamard", "loc":"247 149.52284749830795"},
{"key":"baseI_", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"385 101.52284749830794", "group":"P1S22"},
{"key":"baseI_2", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"385 197.52284749830795", "group":"P1S22"},
{"key":"baseI_3", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"385 149.52284749830795", "group":"P1S22"},
{"key":"C_U_", "text":"C_U", "category":"Qgate", "isize":5, "osize":5, "gtype":"C_U", "u":[], "loc":"385 245.52284749830795", "group":"P1S22", "fromJSBB":true, "toJSBB":false},
{"key":"baseI_4", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"529 101.52284749830794", "group":"P1S222"},
{"key":"baseI_42", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"529 149.52284749830795", "group":"P1S222"},
{"key":"SWAP_", "text":"SWAP", "category":"Qgate", "isize":2, "osize":2, "gtype":"SWAP", "u":[], "loc":"529 197.52284749830795", "group":"P1S222", "fromJSBB":true, "toJSBB":false},
{"key":"baseI_7", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"667 101.52284749830794", "group":"P1S2222"},
{"key":"baseI_72", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"667 197.52284749830795", "group":"P1S2222"},
{"key":"baseI_73", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"667 149.52284749830795", "group":"P1S2222"},
{"key":"C_U_2", "text":"C_U", "category":"Qgate", "isize":5, "osize":5, "gtype":"C_U", "u":[], "loc":"667 245.52284749830795", "group":"P1S2222", "fromJSBB":true, "toJSBB":false},
{"key":"P1S2223", "text":"Step6", "isGroup":true, "group":"P1", "category":"Stage", "loc":"791 23.522847498307936", "size":"136.44189453125 481.512158203125"},
{"key":"baseJS_33", "category":"JSBB", "text":"prepareU^4", "isize":0, "osize":0, "code":"prepareU4 = function(input) {\n if (typeof(input) == \"undefined\") throw \"Invalid Input while preparing U\";\n if (typeof(input.x) == \"undefined\") throw \"'x' not accepted while preparing U.\";\n var x = input.x;\n var index = 4;\n var size = 5; // controled U with U|y> = |xy%N>\n var u = [];\n // alloc\n for (var i=0; i<2**size; ++i) {\n var nw = [];\n for (var j=0; j<2**size; ++j) {\n nw.push([0,0])\n }\n u.push(nw);\n }\n for (var j=0; j<2**(size-1); ++j) {\n u[j][j] = [1, 0]; //highest bit is 0\n }\n var base = 2**(size-1);\n var power = function(m, n, N) {\n var ret = m%N;\n for (var i=1; i<n; ++i) {\n ret *= m;\n ret %= N;\n }\n return ret;\n }\n for (var j=0; j<2**(size-1); ++j) {\n u[base+j][base + (power(x, index, input.n) * j)%input.n] = [1, 0]; //highest bit is 0\n }\n input.u = u;\n return input;\n}", "loc":"811 53.52284749830794", "group":"P1S2223"},
{"key":"baseI_43", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"811 101.52284749830794", "group":"P1S2223"},
{"key":"SWAP_2", "text":"SWAP", "category":"Qgate", "isize":3, "osize":3, "gtype":"SWAP", "u":[], "loc":"811 149.52284749830795", "group":"P1S2223", "fromJSBB":true, "toJSBB":false},
{"key":"P1S22232", "text":"Step7", "isGroup":true, "group":"P1", "category":"Stage", "loc":"929 23.522847498307936", "size":"142.72607421875 481.512158203125"},
{"key":"baseJS_332", "category":"JSBB", "text":"prepareSwap", "isize":0, "osize":0, "code":"swap = function(input) {\n input.from = [0, 1, 2, 3];\n input.to = [3, 1, 2, 0];\n return input;\n}", "loc":"949 53.52284749830794", "group":"P1S22232"},
{"key":"baseI_432", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"949 101.52284749830794", "group":"P1S22232"},
{"key":"baseI_722", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"949 149.52284749830795", "group":"P1S22232"},
{"key":"baseI_7222", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"949 197.52284749830795", "group":"P1S22232"},
{"key":"C_U_22", "text":"C_U", "category":"Qgate", "isize":5, "osize":5, "gtype":"C_U", "u":[], "loc":"949 245.52284749830795", "group":"P1S22232", "fromJSBB":true, "toJSBB":false},
{"key":"P1S22233", "text":"Step8", "isGroup":true, "group":"P1", "category":"Stage", "loc":"1073 23.522847498307936", "size":"136.44189453125 481.512158203125"},
{"key":"baseJS_333", "category":"JSBB", "text":"prepareU^8", "isize":0, "osize":0, "code":"prepareU8 = function(input) {\n if (typeof(input) == \"undefined\") throw \"Invalid Input while preparing U\";\n if (typeof(input.x) == \"undefined\") throw \"'x' not accepted while preparing U.\";\n var x = input.x;\n var index = 8;\n var size = 5; // controled U with U|y> = |xy%N>\n var u = [];\n // alloc\n for (var i=0; i<2**size; ++i) {\n var nw = [];\n for (var j=0; j<2**size; ++j) {\n nw.push([0,0])\n }\n u.push(nw);\n }\n for (var j=0; j<2**(size-1); ++j) {\n u[j][j] = [1, 0]; //highest bit is 0\n }\n var base = 2**(size-1);\n var power = function(m, n, N) {\n var ret = m%N;\n for (var i=1; i<n; ++i) {\n ret *= m;\n ret %= N;\n }\n return ret;\n }\n for (var j=0; j<2**(size-1); ++j) {\n u[base+j][base + (power(x, index, input.n) * j)%input.n] = [1, 0]; //highest bit is 0\n }\n input.u = u;\n return input;\n}", "loc":"1093 53.52284749830794", "group":"P1S22233"},
{"key":"SWAP_22", "text":"SWAP", "category":"Qgate", "isize":4, "osize":4, "gtype":"SWAP", "u":[], "loc":"1093 101.52284749830794", "group":"P1S22233", "fromJSBB":true, "toJSBB":false},
{"key":"P1S222322", "text":"Step9", "isGroup":true, "group":"P1", "category":"Stage", "loc":"1211 23.522847498307936", "size":"142.72607421875 481.512158203125"},
{"key":"baseJS_3322", "category":"JSBB", "text":"prepareSwap", "isize":0, "osize":0, "code":"swap = function(input) {\n input.from = [0, 1, 2, 3];\n input.to = [3, 0, 1, 2];\n return input;\n}", "loc":"1231 53.52284749830794", "group":"P1S222322"},
{"key":"baseI_4322", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"1231 101.52284749830794", "group":"P1S222322"},
{"key":"baseI_7223", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"1231 149.52284749830795", "group":"P1S222322"},
{"key":"baseI_72222", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"1231 197.52284749830795", "group":"P1S222322"},
{"key":"C_U_222", "text":"C_U", "category":"Qgate", "isize":5, "osize":5, "gtype":"C_U", "u":[], "loc":"1231 245.52284749830795", "group":"P1S222322", "fromJSBB":true, "toJSBB":false},
{"key":"P1S222332", "text":"Step10", "isGroup":true, "group":"P1", "category":"Stage", "loc":"1355 23.522847498307936", "size":"142.72607421875 481.512158203125"},
{"key":"baseJS_3332", "category":"JSBB", "text":"Identity", "isize":0, "osize":0, "code":"identity = function(x) {return x;}", "loc":"1375 53.52284749830794", "group":"P1S222332"},
{"key":"SWAP_222", "text":"SWAP", "category":"Qgate", "isize":4, "osize":4, "gtype":"SWAP", "u":[], "loc":"1375 101.52284749830794", "group":"P1S222332", "fromJSBB":true, "toJSBB":false},
{"key":"P1S2223322", "text":"Step11", "isGroup":true, "group":"P1", "category":"Stage", "loc":"1499 23.522847498307936", "size":"166.7900390625 481.512158203125"},
{"key":"baseJS_33322", "category":"JSBB", "text":"prepareCRotate2", "isize":0, "osize":0, "code":"prepareCRotate = function(input) {\n var index = 2;\n input.u = [\n [[1,0], [0,0], [0,0], [0,0]],\n [[0,0], [1,0], [0,0], [0,0]],\n [[0,0], [0,0], [1,0], [0,0]],\n [[0,0], [0,0], [0,0], \n [Math.cos(2*Math.PI/(2 ** index)), \n Math.sin(2*Math.PI/(2 ** index))]]];\n return input;\n}", "loc":"1519 53.52284749830794", "group":"P1S2223322"},
{"key":"P1S22233222", "text":"Step17", "isGroup":true, "group":"P1", "category":"Stage", "loc":"2419 23.522847498307936", "size":"166.7900390625 481.512158203125"},
{"key":"baseJS_333222", "category":"JSBB", "text":"prepareCRotate2", "isize":0, "osize":0, "code":"prepareCRotate = function(input) {\n var index = 2;\n input.u = [\n [[1,0], [0,0], [0,0], [0,0]],\n [[0,0], [1,0], [0,0], [0,0]],\n [[0,0], [0,0], [1,0], [0,0]],\n [[0,0], [0,0], [0,0], \n [Math.cos(2*Math.PI/(2 ** index)), \n Math.sin(2*Math.PI/(2 ** index))]]];\n return input;\n}", "loc":"2439 53.52284749830794", "group":"P1S22233222"},
{"key":"P1S22233223", "text":"Step15", "isGroup":true, "group":"P1", "category":"Stage", "loc":"2107 23.522847498307936", "size":"166.7900390625 481.512158203125"},
{"key":"baseJS_333223", "category":"JSBB", "text":"prepareCRotate3", "isize":0, "osize":0, "code":"prepareCRotate = function(input) {\n var index = 3;\n input.u = [\n [[1,0], [0,0], [0,0], [0,0]],\n [[0,0], [1,0], [0,0], [0,0]],\n [[0,0], [0,0], [1,0], [0,0]],\n [[0,0], [0,0], [0,0], \n [Math.cos(2*Math.PI/(2 ** index)), \n Math.sin(2*Math.PI/(2 ** index))]]];\n return input;\n}", "loc":"2127 53.52284749830794", "group":"P1S22233223"},
{"key":"P1S22233224", "text":"Step14", "isGroup":true, "group":"P1", "category":"Stage", "loc":"1963 23.522847498307936", "size":"142.72607421875 481.512158203125"},
{"key":"baseJS_333224", "category":"JSBB", "text":"prepareSwap", "isize":0, "osize":0, "code":"swap = function(input) {\n input.from = [0, 1];\n input.to = [1, 0];\n return input;\n}", "loc":"1983 53.52284749830794", "group":"P1S22233224"},
{"key":"P1S22233225", "text":"Step13", "isGroup":true, "group":"P1", "category":"Stage", "loc":"1795 23.522847498307936", "size":"166.7900390625 481.512158203125"},
{"key":"baseJS_333225", "category":"JSBB", "text":"prepareCRotate2", "isize":0, "osize":0, "code":"prepareCRotate = function(input) {\n var index = 2;\n input.u = [\n [[1,0], [0,0], [0,0], [0,0]],\n [[0,0], [1,0], [0,0], [0,0]],\n [[0,0], [0,0], [1,0], [0,0]],\n [[0,0], [0,0], [0,0], \n [Math.cos(2*Math.PI/(2 ** index)), \n Math.sin(2*Math.PI/(2 ** index))]]];\n return input;\n}", "loc":"1815 53.52284749830794", "group":"P1S22233225"},
{"key":"P1S22233226", "text":"Step12", "isGroup":true, "group":"P1", "category":"Stage", "loc":"1667 23.522847498307936", "size":"126.38720703125 481.512158203125"},
{"key":"baseJS_333226", "category":"JSBB", "text":"identity", "isize":0, "osize":0, "code":"identity = function(x) {return x;}", "loc":"1687 53.52284749830794", "group":"P1S22233226"},
{"key":"baseH_", "category":"Qgate", "isize":1, "osize":1, "gtype":"Hadamard", "loc":"1519 101.52284749830794", "group":"P1S2223322", "fromJSBB":false, "toJSBB":false},
{"key":"base1_", "category":"Qgate", "isize":0, "osize":1, "gtype":"|1>", "loc":"20 437.52284749830795", "group":"P1S1"},
{"key":"C_U_3", "text":"C_U", "category":"Qgate", "isize":2, "osize":2, "gtype":"C_U", "u":[], "loc":"1687 101.52284749830794", "group":"P1S22233226", "fromJSBB":true, "toJSBB":false},
{"key":"baseI_5", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"1519 149.52284749830795", "group":"P1S2223322"},
{"key":"baseI_6", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"1815 101.52284749830794", "group":"P1S22233225"},
{"key":"baseH_2", "category":"Qgate", "isize":1, "osize":1, "gtype":"Hadamard", "loc":"1815 149.52284749830795", "group":"P1S22233225"},
{"key":"baseI_8", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"1983 101.52284749830794", "group":"P1S22233224"},
{"key":"C_U_4", "text":"C_U", "category":"Qgate", "isize":2, "osize":2, "gtype":"C_U", "u":[], "loc":"1983 149.52284749830795", "group":"P1S22233224", "fromJSBB":true, "toJSBB":false},
{"key":"baseI_9", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"1519 197.52284749830795", "group":"P1S2223322"},
{"key":"baseI_10", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"1687 149.52284749830795", "group":"P1S22233226"},
{"key":"baseI_11", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"1815 197.52284749830795", "group":"P1S22233225"},
{"key":"SWAP_3", "text":"SWAP", "category":"Qgate", "isize":2, "osize":2, "gtype":"SWAP", "u":[], "loc":"2127 101.52284749830794", "group":"P1S22233223", "fromJSBB":true, "toJSBB":false},
{"key":"P1S222332222", "text":"Step22", "isGroup":true, "group":"P1", "category":"Stage", "loc":"3211 23.522847498307936", "size":"126.38720703125 481.512158203125"},
{"key":"baseJS_3332222", "category":"JSBB", "text":"identity", "isize":0, "osize":0, "code":"identity = function(x) {return x;}", "loc":"3231 53.52284749830794", "group":"P1S222332222"},
{"key":"P1S222332223", "text":"Step21", "isGroup":true, "group":"P1", "category":"Stage", "loc":"3043 23.522847498307936", "size":"166.7900390625 481.512158203125"},
{"key":"baseJS_3332223", "category":"JSBB", "text":"prepareCRotate4", "isize":0, "osize":0, "code":"prepareCRotate = function(input) {\n var index = 4;\n input.u = [\n [[1,0], [0,0], [0,0], [0,0]],\n [[0,0], [1,0], [0,0], [0,0]],\n [[0,0], [0,0], [1,0], [0,0]],\n [[0,0], [0,0], [0,0], \n [Math.cos(2*Math.PI/(2 ** index)), \n Math.sin(2*Math.PI/(2 ** index))]]];\n return input;\n}", "loc":"3063 53.52284749830794", "group":"P1S222332223"},
{"key":"P1S222332224", "text":"Step20", "isGroup":true, "group":"P1", "category":"Stage", "loc":"2899 23.522847498307936", "size":"142.72607421875 481.512158203125"},
{"key":"baseJS_3332224", "category":"JSBB", "text":"prepareSwap", "isize":0, "osize":0, "code":"swap = function(input) {\n input.from = [0, 1, 2];\n input.to = [0, 2, 1];\n return input;\n}", "loc":"2919 53.52284749830794", "group":"P1S222332224"},
{"key":"P1S222332225", "text":"Step19", "isGroup":true, "group":"P1", "category":"Stage", "loc":"2731 23.522847498307936", "size":"166.7900390625 481.512158203125"},
{"key":"baseJS_3332225", "category":"JSBB", "text":"prepareCRotate3", "isize":0, "osize":0, "code":"prepareCRotate = function(input) {\n var index = 3;\n input.u = [\n [[1,0], [0,0], [0,0], [0,0]],\n [[0,0], [1,0], [0,0], [0,0]],\n [[0,0], [0,0], [1,0], [0,0]],\n [[0,0], [0,0], [0,0], \n [Math.cos(2*Math.PI/(2 ** index)), \n Math.sin(2*Math.PI/(2 ** index))]]];\n return input;\n}", "loc":"2751 53.52284749830794", "group":"P1S222332225"},
{"key":"P1S222332226", "text":"Step18", "isGroup":true, "group":"P1", "category":"Stage", "loc":"2587 23.522847498307936", "size":"142.72607421875 481.512158203125"},
{"key":"baseJS_3332226", "category":"JSBB", "text":"prepareSwap", "isize":0, "osize":0, "code":"swap = function(input) {\n input.from = [0, 1, 2];\n input.to = [2, 1, 0];\n return input;\n}", "loc":"2607 53.52284749830794", "group":"P1S222332226"},
{"key":"P1S222332227", "text":"Step16", "isGroup":true, "group":"P1", "category":"Stage", "loc":"2275 23.522847498307936", "size":"142.72607421875 481.512158203125"},
{"key":"baseJS_3332227", "category":"JSBB", "text":"prepareSwap", "isize":0, "osize":0, "code":"identity = function(x) {return x;}", "loc":"2295 53.52284749830794", "group":"P1S222332227"},
{"key":"baseI_12", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"2295 101.52284749830794", "group":"P1S222332227"},
{"key":"C_U_5", "text":"C_U", "category":"Qgate", "isize":2, "osize":2, "gtype":"C_U", "u":[], "loc":"2295 149.52284749830795", "group":"P1S222332227", "fromJSBB":true, "toJSBB":false},
{"key":"baseI_13", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"2127 149.52284749830795", "group":"P1S22233223"},
{"key":"baseI_14", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"2439 101.52284749830794", "group":"P1S22233222"},
{"key":"baseI_15", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"2439 149.52284749830795", "group":"P1S22233222"},
{"key":"baseH_3", "category":"Qgate", "isize":1, "osize":1, "gtype":"Hadamard", "loc":"2439 197.52284749830795", "group":"P1S22233222"},
{"key":"baseI_16", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"2607 101.52284749830794", "group":"P1S222332226"},
{"key":"baseI_17", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"2607 149.52284749830795", "group":"P1S222332226"},
{"key":"C_U_6", "text":"C_U", "category":"Qgate", "isize":2, "osize":2, "gtype":"C_U", "u":[], "loc":"2607 197.52284749830795", "group":"P1S222332226", "fromJSBB":true, "toJSBB":false},
{"key":"SWAP_4", "text":"SWAP", "category":"Qgate", "isize":3, "osize":3, "gtype":"SWAP", "u":[], "loc":"2751 101.52284749830794", "group":"P1S222332225", "fromJSBB":true, "toJSBB":false},
{"key":"baseI_18", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"2919 101.52284749830794", "group":"P1S222332224"},
{"key":"baseI_19", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"2919 149.52284749830795", "group":"P1S222332224"},
{"key":"C_U_7", "text":"C_U", "category":"Qgate", "isize":2, "osize":2, "gtype":"C_U", "u":[], "loc":"2919 197.52284749830795", "group":"P1S222332224", "fromJSBB":true, "toJSBB":false},
{"key":"baseI_20", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"2751 149.52284749830795", "group":"P1S222332225"},
{"key":"P1S2223322223", "text":"Step23", "isGroup":true, "group":"P1", "category":"Stage", "loc":"3339 23.522847498307936", "size":"142.72607421875 481.512158203125"},
{"key":"baseJS_33322223", "category":"JSBB", "text":"prepareSwap", "isize":0, "osize":0, "code":"swap = function(input) {\n input.from = [0, 1, 2];\n input.to = [2, 1, 0];\n return input;\n}", "loc":"3359 53.52284749830794", "group":"P1S2223322223"},
{"key":"SWAP_42", "text":"SWAP", "category":"Qgate", "isize":3, "osize":3, "gtype":"SWAP", "u":[], "loc":"3063 101.52284749830794", "group":"P1S222332223", "fromJSBB":true, "toJSBB":false},
{"key":"baseI_21", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"3231 101.52284749830794", "group":"P1S222332222"},
{"key":"baseI_22", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"3231 149.52284749830795", "group":"P1S222332222"},
{"key":"C_U_8", "text":"C_U", "category":"Qgate", "isize":2, "osize":2, "gtype":"C_U", "u":[], "loc":"3231 197.52284749830795", "group":"P1S222332222", "fromJSBB":true, "toJSBB":false},
{"key":"baseI_23", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"3063 149.52284749830795", "group":"P1S222332223"},
{"key":"P1S22233222232", "text":"Step25", "isGroup":true, "group":"P1", "category":"Stage", "loc":"3611 23.522847498307936", "size":"126.38720703125 481.512158203125"},
{"key":"baseJS_333222232", "category":"JSBB", "text":"identity", "isize":0, "osize":0, "code":"identity = function(x) {return x;}", "loc":"3631 53.52284749830794", "group":"P1S22233222232"},
{"key":"P1S22233222233", "text":"Step24", "isGroup":true, "group":"P1", "category":"Stage", "loc":"3483 23.522847498307936", "size":"126.38720703125 481.512158203125"},
{"key":"baseJS_333222233", "category":"JSBB", "text":"identity", "isize":0, "osize":0, "code":"identity = function(x) {return x;}", "loc":"3503 53.52284749830794", "group":"P1S22233222233"},
{"key":"baseI_24", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"3359 101.52284749830794", "group":"P1S2223322223"},
{"key":"baseI_25", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"3359 149.52284749830795", "group":"P1S2223322223"},
{"key":"baseI_26", "category":"Qgate", "isize":1, "osize":1, "gtype":"Identity", "loc":"3359 197.52284749830795", "group":"P1S2223322223"},
{"key":"baseH_4", "category":"Qgate", "isize":1, "osize":1, "gtype":"Hadamard", "loc":"3359 245.52284749830795", "group":"P1S2223322223"},
{"key":"SWAP_5", "text":"SWAP", "category":"Qgate", "isize":4, "osize":4, "gtype":"SWAP", "u":[], "loc":"3503 101.52284749830794", "group":"P1S22233222233", "fromJSBB":true, "toJSBB":false},
{"key":"baseM_", "category":"Qgate", "isize":4, "osize":0, "gtype":"Measure", "toJSBB":true, "loc":"3631 101.52284749830794", "group":"P1S22233222232", "fromJSBB":false},
{"key":"P1S222332222322", "text":"Step26", "isGroup":true, "group":"P1", "category":"Stage", "loc":"3739 23.522847498307936", "size":"196.00830078125 481.512158203125"},
{"key":"baseJS_3332222322", "category":"JSBB", "text":"display(ration_to_ans)", "isize":0, "osize":0, "code":"display = function(input) {\n var result = input.result[0];\n var nw = 0.5;\n var s = 0;\n for (var i=0; i<result.length; ++i) {\n if(result[i] > 0) s += nw;\n nw = nw / 2;\n }\n var rational_number_to_divisor = function(input) {\n var cf = []; //continued fraction\n equal = function(a, b) {\n var eps = 1e-6;\n return Math.abs(a-b) < eps;\n }\n var max_length = 100;\n while (max_length--) {\n cf.push(Math.floor(input));\n input -= Math.floor(input);\n if (equal(input, 0))\n break;\n input = 1 / input;\n }\n var p = 1;\n var q = cf[cf.length-1];\n var ptr = cf.length-2;\n while (ptr >= 0) {\n p = q * cf[ptr] + p;\n var temp = p;\n p = q; q = temp;\n --ptr;\n }\n var temp = p;\n p = q; q = temp;\n return q;\n }\n var r = rational_number_to_divisor(s);\n var ll = Math.round(input.x**(r/2) - 1);\n var rr = Math.round(input.x**(r/2) + 1);\n var pos_ans = 1;\n if (ll > 1 && input.n % ll == 0) pos_ans = ll;\n if (rr > 1 && input.n % rr == 0) pos_ans = rr;\n if (pos_ans != 1 && input.n % pos_ans == 0) {\n alert(\"Using x = \"+input.x+\"; Success! \"+input.n+\" = \"+pos_ans+\" * \"+input.n/pos_ans);\n } else {\n alert(\"Using x = \"+input.x+\"; Failed, get \"+pos_ans);\n }\n}", "loc":"3759 53.52284749830794", "group":"P1S222332222322"}
],
"linkDataArray": [
{"from":"b", "to":"e"},
{"from":"base0_", "to":"e4"},
{"from":"base0_7", "to":"e3"},
{"from":"base0_6", "to":"e2"},
{"from":"e", "to":"baseI_"},
{"from":"e4", "to":"baseI_3"},
{"from":"e3", "to":"baseI_2"},
{"from":"e2", "to":"C_U_"},
{"from":"base0_5", "to":"C_U_"},
{"from":"base0_4", "to":"C_U_"},
{"from":"base0_3", "to":"C_U_"},
{"from":"base1_", "to":"C_U_"},
{"from":"baseJS_", "to":"C_U_"},
{"from":"baseI_", "to":"baseI_4"},
{"from":"baseI_3", "to":"baseI_42"},
{"from":"baseI_2", "to":"SWAP_"},
{"from":"C_U_", "to":"SWAP_"},
{"from":"baseJS_2", "to":"SWAP_"},
{"from":"baseI_4", "to":"baseI_7"},
{"from":"baseI_42", "to":"baseI_73"},
{"from":"SWAP_", "to":"baseI_72"},
{"from":"SWAP_", "to":"C_U_2"},
{"from":"C_U_", "to":"C_U_2"},
{"from":"C_U_", "to":"C_U_2"},
{"from":"C_U_", "to":"C_U_2"},
{"from":"C_U_", "to":"C_U_2"},
{"from":"baseJS_3", "to":"C_U_2"},
{"from":"baseI_7", "to":"baseI_43"},
{"from":"baseI_73", "to":"SWAP_2"},
{"from":"baseI_72", "to":"SWAP_2"},
{"from":"C_U_2", "to":"SWAP_2"},
{"from":"baseJS_32", "to":"SWAP_2"},
{"from":"baseI_43", "to":"baseI_432"},
{"from":"SWAP_2", "to":"baseI_722"},
{"from":"SWAP_2", "to":"baseI_7222"},
{"from":"SWAP_2", "to":"C_U_22"},
{"from":"C_U_2", "to":"C_U_22"},
{"from":"C_U_2", "to":"C_U_22"},
{"from":"C_U_2", "to":"C_U_22"},
{"from":"C_U_2", "to":"C_U_22"},
{"from":"baseJS_33", "to":"C_U_22"},
{"from":"baseI_432", "to":"SWAP_22"},
{"from":"baseI_722", "to":"SWAP_22"},
{"from":"baseI_7222", "to":"SWAP_22"},
{"from":"C_U_22", "to":"SWAP_22"},
{"from":"baseJS_332", "to":"SWAP_22"},
{"from":"SWAP_22", "to":"baseI_4322"},
{"from":"SWAP_22", "to":"baseI_7223"},
{"from":"SWAP_22", "to":"baseI_72222"},
{"from":"SWAP_22", "to":"C_U_222"},
{"from":"C_U_22", "to":"C_U_222"},
{"from":"C_U_22", "to":"C_U_222"},
{"from":"C_U_22", "to":"C_U_222"},
{"from":"C_U_22", "to":"C_U_222"},
{"from":"baseJS_333", "to":"C_U_222"},
{"from":"baseI_4322", "to":"SWAP_222"},
{"from":"baseI_7223", "to":"SWAP_222"},
{"from":"baseI_72222", "to":"SWAP_222"},
{"from":"C_U_222", "to":"SWAP_222"},
{"from":"baseJS_3322", "to":"SWAP_222"},
{"from":"SWAP_222", "to":"baseH_"},
{"from":"SWAP_222", "to":"baseI_5"},
{"from":"SWAP_222", "to":"baseI_9"},
{"from":"baseH_", "to":"C_U_3"},
{"from":"baseI_5", "to":"C_U_3"},
{"from":"baseI_9", "to":"baseI_10"},
{"from":"baseJS_33322", "to":"C_U_3"},
{"from":"C_U_3", "to":"baseI_6"},
{"from":"C_U_3", "to":"baseH_2"},
{"from":"baseI_10", "to":"baseI_11"},
{"from":"baseI_6", "to":"baseI_8"},
{"from":"baseH_2", "to":"C_U_4"},
{"from":"baseI_11", "to":"C_U_4"},
{"from":"baseJS_333225", "to":"C_U_4"},
{"from":"baseI_8", "to":"SWAP_3"},
{"from":"C_U_4", "to":"SWAP_3"},
{"from":"C_U_4", "to":"baseI_13"},
{"from":"baseJS_333224", "to":"SWAP_3"},
{"from":"SWAP_3", "to":"baseI_12"},
{"from":"SWAP_3", "to":"C_U_5"},
{"from":"baseI_13", "to":"C_U_5"},
{"from":"baseJS_333223", "to":"C_U_5"},
{"from":"baseI_12", "to":"baseI_14"},
{"from":"C_U_5", "to":"baseI_15"},
{"from":"C_U_5", "to":"baseH_3"},
{"from":"baseI_14", "to":"baseI_16"},
{"from":"baseI_15", "to":"baseI_17"},
{"from":"baseH_3", "to":"C_U_6"},
{"from":"C_U_222", "to":"C_U_6"},
{"from":"baseJS_333222", "to":"C_U_6"},
{"from":"baseI_16", "to":"SWAP_4"},
{"from":"baseI_17", "to":"SWAP_4"},
{"from":"C_U_6", "to":"SWAP_4"},
{"from":"C_U_6", "to":"baseI_20"},
{"from":"baseJS_3332226", "to":"SWAP_4"},
{"from":"SWAP_4", "to":"baseI_18"},
{"from":"SWAP_4", "to":"baseI_19"},
{"from":"SWAP_4", "to":"C_U_7"},
{"from":"baseI_20", "to":"C_U_7"},
{"from":"baseJS_3332225", "to":"C_U_7"},
{"from":"baseI_18", "to":"SWAP_42"},
{"from":"baseI_19", "to":"SWAP_42"},
{"from":"C_U_7", "to":"SWAP_42"},
{"from":"C_U_7", "to":"baseI_23"},
{"from":"baseJS_3332224", "to":"SWAP_42"},
{"from":"SWAP_42", "to":"baseI_21"},
{"from":"SWAP_42", "to":"baseI_22"},
{"from":"SWAP_42", "to":"C_U_8"},
{"from":"baseI_23", "to":"C_U_8"},
{"from":"baseJS_3332223", "to":"C_U_8"},
{"from":"baseI_21", "to":"baseI_24"},
{"from":"baseI_22", "to":"baseI_25"},
{"from":"C_U_8", "to":"baseI_26"},
{"from":"C_U_8", "to":"baseH_4"},
{"from":"baseI_24", "to":"SWAP_5"},
{"from":"baseI_25", "to":"SWAP_5"},
{"from":"baseI_26", "to":"SWAP_5"},
{"from":"baseH_4", "to":"SWAP_5"},
{"from":"baseJS_33322223", "to":"SWAP_5"},
{"from":"SWAP_5", "to":"baseM_"},
{"from":"SWAP_5", "to":"baseM_"},
{"from":"SWAP_5", "to":"baseM_"},
{"from":"SWAP_5", "to":"baseM_"},
{"from":"baseM_", "to":"baseJS_3332222322"}
]}
</textarea>
</div>
<!-- JSSB -->
<div class="modal fade" id="JSBB_modal" tabindex="-1" role="dialog" aria-labelledby="Settings" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Settings</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="row">
<div class="col-1"></div>
<div class="col-10">
description: <br>
<input type="text" placeholder="" id="JSBB_description" stype>
<br>
code: <br>
<textarea id="JSBB_code" style="width: 100%" rows="10"></textarea>
</div>
<div class="col-1"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">cancel</button>
<button type="button" class="btn btn-primary" onclick="closeJSBBModal()" data-dismiss="modal">apply</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
<!-- Qgate -->
<div class="modal fade" id="Qgate_modal" tabindex="-1" role="dialog" aria-labelledby="Settings" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Settings</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="center-block">
<form class="form-horizontal" align="center">
<fieldset>
<!-- Select Basic -->
<div class="controls" align="center">
<label class="control-label">gateType</label>
<select class="input-xlarge" id="Qgate_gtype">
<option>|0></option>
<option>|1></option>
<option>Identity</option>
<option>PauliX</option>
<option>PauliZ</option>
<option>PauliY</option>
<option>Hadamard</option>
<option>Phase</option>
<option>PiD8</option>
<option>CNOT</option>
<option>SWAP</option>
<option>C_U</option>
<option>Measure</option>
</select>
<br>
</div>
<label class="control-label">  inputSize</label>
<input type="number" placeholder="" id="Qgate_isize">
<br>
<label class="control-label">outputSize</label>
<input type="number" placeholder="" id="Qgate_osize">
<div class="control-group">
<!-- Multiple Checkboxes -->
<div class="controls">
<!-- Inline Checkboxes -->
<label class="checkbox inline">
<input type="checkbox" id="Qgate_fromJS"> fromJS
</label>
<label class="checkbox inline">
<input type="checkbox" id="Qgate_toJS"> toJS
</label>
</div>
</div>
</fieldset>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">cancel</button>
<button type="button" class="btn btn-primary" onclick="closeQgateModal()" data-dismiss="modal">apply</button>
</div>
</div>
<!-- /.modal-content -->
</div>
</div>
<!-- Run_modal -->
<div class="modal fade bs-example-modal-lg" id="Run_modal" tabindex="-1" role="dialog" aria-labelledby="Settings" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="gridSystemModalLabel">Run settings</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-1"></div>
<div class="col-10">
<textarea id="Run_config" style="width: 100%" rows="5">
settings = function(programs) { for(var i in programs) {
programs[i].run(true, {n: 15}, 2); //change 'true' to 'false' to disable middle info
}}
// please wait a moment, output is kinda slow :D
</textarea>
<div class="panel">
<div class="panel-body" style="word-break:break-all">
<p id="Run_text">
gzotpa
</p>
</div>
</div>
</div>
<div class="col-1"></div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">close</button>
<button type="button" class="btn btn-danger" onclick="run()">GO!</button>
</div>
</div>
</div>
</div>
</body>
</html>