pyqrack-cpu 1.32.7__py3-none-manylinux_2_39_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyqrack-cpu might be problematic. Click here for more details.

@@ -0,0 +1,1277 @@
1
+ # (C) Daniel Strano and the Qrack contributors 2017-2021. All rights reserved.
2
+ #
3
+ # "QrackSystem" is a central access point, in Python, to the vm6502q/qrack
4
+ # shared library, in C++11. For ease, it wraps all Qrack shared library
5
+ # functions with native Python method signatures.
6
+ #
7
+ # The "QrackSystem" references underlying distinct Qrack simulator instances
8
+ # via integer IDs that are created upon request to allocate a new simulator.
9
+ # While you can directly use QrackSystem to manage all your simulators, we
10
+ # suggest that you instead instantiate an instance of "QrackSimulator", which
11
+ # requests its own new simulator ID and supplies it to "QrackSystem" for all
12
+ # Qrack shared library calls, therefore acting as an independent Qrack
13
+ # simulator object.
14
+ #
15
+ # Use of this source code is governed by an MIT-style license that can be
16
+ # found in the LICENSE file or at https://opensource.org/licenses/MIT.
17
+
18
+ import os
19
+ from ctypes import *
20
+ from sys import platform as _platform
21
+
22
+
23
+ class QrackSystem:
24
+ def __init__(self):
25
+ shared_lib_path = ""
26
+ if os.environ.get('PYQRACK_SHARED_LIB_PATH') != None:
27
+ shared_lib_path = os.environ.get('PYQRACK_SHARED_LIB_PATH')
28
+ elif _platform == "win32":
29
+ shared_lib_path = os.path.dirname(__file__) + "/qrack_lib/qrack_pinvoke.dll"
30
+ elif _platform == "darwin":
31
+ shared_lib_path = os.path.dirname(__file__) + "/qrack_lib/libqrack_pinvoke.dylib"
32
+ else:
33
+ shared_lib_path = os.path.dirname(__file__) + "/qrack_lib/libqrack_pinvoke.so"
34
+
35
+ try:
36
+ self.qrack_lib = CDLL(shared_lib_path)
37
+ except Exception as e:
38
+ if _platform == "win32":
39
+ shared_lib_path = "C:/Program Files/libqrack*/lib/qrack_pinvoke.lib"
40
+ elif _platform == "darwin":
41
+ shared_lib_path = "/usr/local/lib/qrack/libqrack_pinvoke.dylib"
42
+ else:
43
+ shared_lib_path = "/usr/local/lib/qrack/libqrack_pinvoke.so"
44
+
45
+ try:
46
+ self.qrack_lib = CDLL(shared_lib_path)
47
+ except Exception as e:
48
+ if _platform == "win32":
49
+ shared_lib_path = "C:/Program Files (x86)/libqrack*/lib/qrack_pinvoke.lib"
50
+ elif _platform == "darwin":
51
+ shared_lib_path = "/usr/lib/qrack/libqrack_pinvoke.dylib"
52
+ else:
53
+ shared_lib_path = "/usr/lib/qrack/libqrack_pinvoke.so"
54
+
55
+ try:
56
+ self.qrack_lib = CDLL(shared_lib_path)
57
+ except Exception as e:
58
+ print("IMPORTANT: Did you remember to install OpenCL, if your Qrack version was built with OpenCL?")
59
+ raise e
60
+
61
+ self.fppow = 5
62
+ if "QRACK_FPPOW" in os.environ:
63
+ self.fppow = int(os.environ.get('QRACK_FPPOW'))
64
+ if self.fppow < 4 or self.fppow > 7:
65
+ raise ValueError(
66
+ "QRACK_FPPOW environment variable must be an integer >3 and <8. (Qrack builds from 4 for fp16/half, up to 7 for fp128/quad."
67
+ )
68
+
69
+ # Define function signatures, up front
70
+
71
+ # non-quantum
72
+
73
+ self.qrack_lib.DumpIds.restype = None
74
+ self.qrack_lib.DumpIds.argtypes = [c_ulonglong, CFUNCTYPE(None, c_ulonglong)]
75
+
76
+ self.qrack_lib.Dump.restype = None
77
+ self.qrack_lib.Dump.argtypes = [
78
+ c_ulonglong,
79
+ CFUNCTYPE(c_ulonglong, c_double, c_double)
80
+ ]
81
+
82
+ # These next two methods need to have c_double pointers, if PyQrack is built with fp64.
83
+ self.qrack_lib.InKet.restype = None
84
+ self.qrack_lib.OutKet.restype = None
85
+ self.qrack_lib.OutProbs.restype = None
86
+
87
+ if self.fppow < 6:
88
+ self.qrack_lib.InKet.argtypes = [c_ulonglong, POINTER(c_float)]
89
+ self.qrack_lib.OutKet.argtypes = [c_ulonglong, POINTER(c_float)]
90
+ self.qrack_lib.OutProbs.argtypes = [c_ulonglong, POINTER(c_float)]
91
+ else:
92
+ self.qrack_lib.InKet.argtypes = [c_ulonglong, POINTER(c_double)]
93
+ self.qrack_lib.OutKet.argtypes = [c_ulonglong, POINTER(c_double)]
94
+ self.qrack_lib.OutProbs.argtypes = [c_ulonglong, POINTER(c_double)]
95
+
96
+ self.qrack_lib.init.restype = c_ulonglong
97
+ self.qrack_lib.init.argtypes = []
98
+
99
+ self.qrack_lib.get_error.restype = c_int
100
+ self.qrack_lib.get_error.argtypes = [c_ulonglong]
101
+
102
+ self.qrack_lib.init_count.restype = c_ulonglong
103
+ self.qrack_lib.init_count.argtypes = [c_ulonglong, c_bool]
104
+
105
+ self.qrack_lib.init_count_pager.restype = c_ulonglong
106
+ self.qrack_lib.init_count_pager.argtypes = [c_ulonglong, c_bool]
107
+
108
+ self.qrack_lib.init_count_type.restype = c_ulonglong
109
+ self.qrack_lib.init_count_type.argtypes = [
110
+ c_ulonglong,
111
+ c_bool,
112
+ c_bool,
113
+ c_bool,
114
+ c_bool,
115
+ c_bool,
116
+ c_bool,
117
+ c_bool,
118
+ c_bool,
119
+ c_bool,
120
+ c_bool
121
+ ]
122
+
123
+ self.qrack_lib.init_clone.restype = c_ulonglong
124
+ self.qrack_lib.init_clone.argtypes = [c_ulonglong]
125
+
126
+ self.qrack_lib.destroy.restype = None
127
+ self.qrack_lib.destroy.argtypes = [c_ulonglong]
128
+
129
+ self.qrack_lib.seed.restype = None
130
+ self.qrack_lib.seed.argtypes = [c_ulonglong, c_ulonglong]
131
+
132
+ self.qrack_lib.set_concurrency.restype = None
133
+ self.qrack_lib.set_concurrency.argtypes = [c_ulonglong, c_ulonglong]
134
+
135
+ # pseudo-quantum
136
+
137
+ self.qrack_lib.ProbAll.restype = None
138
+ if self.fppow == 5:
139
+ self.qrack_lib.ProbAll.argtypes = [
140
+ c_ulonglong,
141
+ c_ulonglong,
142
+ POINTER(c_ulonglong),
143
+ POINTER(c_float)
144
+ ]
145
+ elif self.fppow == 6:
146
+ self.qrack_lib.ProbAll.argtypes = [
147
+ c_ulonglong,
148
+ c_ulonglong,
149
+ POINTER(c_ulonglong),
150
+ POINTER(c_double)
151
+ ]
152
+
153
+ self.qrack_lib.Prob.restype = c_double
154
+ self.qrack_lib.Prob.argtypes = [c_ulonglong, c_ulonglong]
155
+
156
+ self.qrack_lib.ProbRdm.restype = c_double
157
+ self.qrack_lib.ProbRdm.argtypes = [c_ulonglong, c_ulonglong]
158
+
159
+ self.qrack_lib.PermutationProb.restype = c_double
160
+ self.qrack_lib.PermutationProb.argtypes = [
161
+ c_ulonglong,
162
+ c_ulonglong,
163
+ POINTER(c_ulonglong),
164
+ POINTER(c_bool)
165
+ ]
166
+
167
+ self.qrack_lib.PermutationProbRdm.restype = c_double
168
+ self.qrack_lib.PermutationProbRdm.argtypes = [
169
+ c_ulonglong,
170
+ c_ulonglong,
171
+ POINTER(c_ulonglong),
172
+ POINTER(c_bool),
173
+ c_bool
174
+ ]
175
+
176
+ self.qrack_lib.PermutationExpectation.restype = c_double
177
+ self.qrack_lib.PermutationExpectation.argtypes = [
178
+ c_ulonglong,
179
+ c_ulonglong,
180
+ POINTER(c_ulonglong)
181
+ ]
182
+
183
+ self.qrack_lib.PermutationExpectationRdm.restype = c_double
184
+ self.qrack_lib.PermutationExpectationRdm.argtypes = [
185
+ c_ulonglong,
186
+ c_ulonglong,
187
+ POINTER(c_ulonglong),
188
+ c_bool
189
+ ]
190
+
191
+ self.qrack_lib.FactorizedExpectation.restype = c_double
192
+ self.qrack_lib.FactorizedExpectation.argtypes = [
193
+ c_ulonglong,
194
+ c_ulonglong,
195
+ POINTER(c_ulonglong),
196
+ c_ulonglong,
197
+ POINTER(c_ulonglong)
198
+ ]
199
+
200
+ self.qrack_lib.FactorizedExpectationRdm.restype = c_double
201
+ self.qrack_lib.FactorizedExpectationRdm.argtypes = [
202
+ c_ulonglong,
203
+ c_ulonglong,
204
+ POINTER(c_ulonglong),
205
+ c_ulonglong,
206
+ POINTER(c_ulonglong),
207
+ c_bool
208
+ ]
209
+
210
+ if self.fppow == 5:
211
+ self.qrack_lib.FactorizedExpectationFp.restype = c_double
212
+ self.qrack_lib.FactorizedExpectationFp.argtypes = [
213
+ c_ulonglong,
214
+ c_ulonglong,
215
+ POINTER(c_ulonglong),
216
+ POINTER(c_float)
217
+ ]
218
+ self.qrack_lib.FactorizedExpectationFpRdm.restype = c_double
219
+ self.qrack_lib.FactorizedExpectationFpRdm.argtypes = [
220
+ c_ulonglong,
221
+ c_ulonglong,
222
+ POINTER(c_ulonglong),
223
+ POINTER(c_float),
224
+ c_bool
225
+ ]
226
+ self.qrack_lib.UnitaryExpectation.restype = c_double
227
+ self.qrack_lib.UnitaryExpectation.argtypes = [
228
+ c_ulonglong,
229
+ c_ulonglong,
230
+ POINTER(c_ulonglong),
231
+ POINTER(c_float)
232
+ ]
233
+ self.qrack_lib.MatrixExpectation.restype = c_double
234
+ self.qrack_lib.MatrixExpectation.argtypes = [
235
+ c_ulonglong,
236
+ c_ulonglong,
237
+ POINTER(c_ulonglong),
238
+ POINTER(c_float)
239
+ ]
240
+ self.qrack_lib.UnitaryExpectationEigenVal.restype = c_double
241
+ self.qrack_lib.UnitaryExpectationEigenVal.argtypes = [
242
+ c_ulonglong,
243
+ c_ulonglong,
244
+ POINTER(c_ulonglong),
245
+ POINTER(c_float),
246
+ POINTER(c_float)
247
+ ]
248
+ self.qrack_lib.MatrixExpectationEigenVal.restype = c_double
249
+ self.qrack_lib.MatrixExpectationEigenVal.argtypes = [
250
+ c_ulonglong,
251
+ c_ulonglong,
252
+ POINTER(c_ulonglong),
253
+ POINTER(c_float),
254
+ POINTER(c_float)
255
+ ]
256
+ elif self.fppow == 6:
257
+ self.qrack_lib.FactorizedExpectationFp.restype = c_double
258
+ self.qrack_lib.FactorizedExpectationFp.argtypes = [
259
+ c_ulonglong,
260
+ c_ulonglong,
261
+ POINTER(c_ulonglong),
262
+ POINTER(c_double)
263
+ ]
264
+ self.qrack_lib.FactorizedExpectationFpRdm.restype = c_double
265
+ self.qrack_lib.FactorizedExpectationFpRdm.argtypes = [
266
+ c_ulonglong,
267
+ c_ulonglong,
268
+ POINTER(c_ulonglong),
269
+ POINTER(c_double),
270
+ c_bool
271
+ ]
272
+ self.qrack_lib.UnitaryExpectation.restype = c_double
273
+ self.qrack_lib.UnitaryExpectation.argtypes = [
274
+ c_ulonglong,
275
+ c_ulonglong,
276
+ POINTER(c_ulonglong),
277
+ POINTER(c_double)
278
+ ]
279
+ self.qrack_lib.MatrixExpectation.restype = c_double
280
+ self.qrack_lib.MatrixExpectation.argtypes = [
281
+ c_ulonglong,
282
+ c_ulonglong,
283
+ POINTER(c_ulonglong),
284
+ POINTER(c_double)
285
+ ]
286
+ self.qrack_lib.UnitaryExpectationEigenVal.restype = c_double
287
+ self.qrack_lib.UnitaryExpectationEigenVal.argtypes = [
288
+ c_ulonglong,
289
+ c_ulonglong,
290
+ POINTER(c_ulonglong),
291
+ POINTER(c_double),
292
+ POINTER(c_double)
293
+ ]
294
+ self.qrack_lib.MatrixExpectationEigenVal.restype = c_double
295
+ self.qrack_lib.MatrixExpectationEigenVal.argtypes = [
296
+ c_ulonglong,
297
+ c_ulonglong,
298
+ POINTER(c_ulonglong),
299
+ POINTER(c_double),
300
+ POINTER(c_double)
301
+ ]
302
+
303
+ self.qrack_lib.PauliExpectation.restype = c_double
304
+ self.qrack_lib.PauliExpectation.argtypes = [
305
+ c_ulonglong,
306
+ c_ulonglong,
307
+ POINTER(c_ulonglong),
308
+ POINTER(c_ulonglong)
309
+ ]
310
+
311
+ self.qrack_lib.Variance.restype = c_double
312
+ self.qrack_lib.Variance.argtypes = [
313
+ c_ulonglong,
314
+ c_ulonglong,
315
+ POINTER(c_ulonglong)
316
+ ]
317
+
318
+ self.qrack_lib.VarianceRdm.restype = c_double
319
+ self.qrack_lib.VarianceRdm.argtypes = [
320
+ c_ulonglong,
321
+ c_ulonglong,
322
+ POINTER(c_ulonglong),
323
+ c_bool
324
+ ]
325
+
326
+ self.qrack_lib.FactorizedVariance.restype = c_double
327
+ self.qrack_lib.FactorizedVariance.argtypes = [
328
+ c_ulonglong,
329
+ c_ulonglong,
330
+ POINTER(c_ulonglong),
331
+ c_ulonglong,
332
+ POINTER(c_ulonglong)
333
+ ]
334
+
335
+ self.qrack_lib.FactorizedVarianceRdm.restype = c_double
336
+ self.qrack_lib.FactorizedVarianceRdm.argtypes = [
337
+ c_ulonglong,
338
+ c_ulonglong,
339
+ POINTER(c_ulonglong),
340
+ c_ulonglong,
341
+ POINTER(c_ulonglong),
342
+ c_bool
343
+ ]
344
+
345
+ if self.fppow == 5:
346
+ self.qrack_lib.FactorizedVarianceFp.restype = c_double
347
+ self.qrack_lib.FactorizedVarianceFp.argtypes = [
348
+ c_ulonglong,
349
+ c_ulonglong,
350
+ POINTER(c_ulonglong),
351
+ POINTER(c_float)
352
+ ]
353
+ self.qrack_lib.FactorizedVarianceFpRdm.restype = c_double
354
+ self.qrack_lib.FactorizedVarianceFpRdm.argtypes = [
355
+ c_ulonglong,
356
+ c_ulonglong,
357
+ POINTER(c_ulonglong),
358
+ POINTER(c_float),
359
+ c_bool
360
+ ]
361
+ self.qrack_lib.UnitaryVariance.restype = c_double
362
+ self.qrack_lib.UnitaryVariance.argtypes = [
363
+ c_ulonglong,
364
+ c_ulonglong,
365
+ POINTER(c_ulonglong),
366
+ POINTER(c_float)
367
+ ]
368
+ self.qrack_lib.MatrixVariance.restype = c_double
369
+ self.qrack_lib.MatrixVariance.argtypes = [
370
+ c_ulonglong,
371
+ c_ulonglong,
372
+ POINTER(c_ulonglong),
373
+ POINTER(c_float)
374
+ ]
375
+ self.qrack_lib.UnitaryVarianceEigenVal.restype = c_double
376
+ self.qrack_lib.UnitaryVarianceEigenVal.argtypes = [
377
+ c_ulonglong,
378
+ c_ulonglong,
379
+ POINTER(c_ulonglong),
380
+ POINTER(c_float),
381
+ POINTER(c_float)
382
+ ]
383
+ self.qrack_lib.MatrixVarianceEigenVal.restype = c_double
384
+ self.qrack_lib.MatrixVarianceEigenVal.argtypes = [
385
+ c_ulonglong,
386
+ c_ulonglong,
387
+ POINTER(c_ulonglong),
388
+ POINTER(c_float),
389
+ POINTER(c_float)
390
+ ]
391
+ elif self.fppow == 6:
392
+ self.qrack_lib.FactorizedVarianceFp.restype = c_double
393
+ self.qrack_lib.FactorizedVarianceFp.argtypes = [
394
+ c_ulonglong,
395
+ c_ulonglong,
396
+ POINTER(c_ulonglong),
397
+ POINTER(c_double)
398
+ ]
399
+ self.qrack_lib.FactorizedVarianceFpRdm.restype = c_double
400
+ self.qrack_lib.FactorizedVarianceFpRdm.argtypes = [
401
+ c_ulonglong,
402
+ c_ulonglong,
403
+ POINTER(c_ulonglong),
404
+ POINTER(c_double),
405
+ c_bool
406
+ ]
407
+ self.qrack_lib.UnitaryVariance.restype = c_double
408
+ self.qrack_lib.UnitaryVariance.argtypes = [
409
+ c_ulonglong,
410
+ c_ulonglong,
411
+ POINTER(c_ulonglong),
412
+ POINTER(c_double)
413
+ ]
414
+ self.qrack_lib.MatrixVariance.restype = c_double
415
+ self.qrack_lib.MatrixVariance.argtypes = [
416
+ c_ulonglong,
417
+ c_ulonglong,
418
+ POINTER(c_ulonglong),
419
+ POINTER(c_double)
420
+ ]
421
+ self.qrack_lib.UnitaryVarianceEigenVal.restype = c_double
422
+ self.qrack_lib.UnitaryVarianceEigenVal.argtypes = [
423
+ c_ulonglong,
424
+ c_ulonglong,
425
+ POINTER(c_ulonglong),
426
+ POINTER(c_double),
427
+ POINTER(c_double)
428
+ ]
429
+ self.qrack_lib.MatrixVarianceEigenVal.restype = c_double
430
+ self.qrack_lib.MatrixVarianceEigenVal.argtypes = [
431
+ c_ulonglong,
432
+ c_ulonglong,
433
+ POINTER(c_ulonglong),
434
+ POINTER(c_double),
435
+ POINTER(c_double)
436
+ ]
437
+
438
+ self.qrack_lib.PauliVariance.restype = c_double
439
+ self.qrack_lib.PauliVariance.argtypes = [
440
+ c_ulonglong,
441
+ c_ulonglong,
442
+ POINTER(c_ulonglong),
443
+ POINTER(c_ulonglong)
444
+ ]
445
+
446
+ self.qrack_lib.JointEnsembleProbability.restype = c_double
447
+ self.qrack_lib.JointEnsembleProbability.argtypes = [
448
+ c_ulonglong,
449
+ c_ulonglong,
450
+ POINTER(c_int),
451
+ c_ulonglong
452
+ ]
453
+
454
+ self.qrack_lib.PhaseParity.restype = None
455
+ self.qrack_lib.PhaseParity.argtypes = [
456
+ c_ulonglong,
457
+ c_double,
458
+ c_ulonglong,
459
+ POINTER(c_ulonglong)
460
+ ]
461
+
462
+ self.qrack_lib.PhaseRootN.restype = None
463
+ self.qrack_lib.PhaseRootN.argtypes = [
464
+ c_ulonglong,
465
+ c_ulonglong,
466
+ c_ulonglong,
467
+ POINTER(c_ulonglong)
468
+ ]
469
+
470
+ self.qrack_lib.ResetAll.restype = None
471
+ self.qrack_lib.ResetAll.argtypes = [c_ulonglong]
472
+
473
+ # allocate and release
474
+
475
+ self.qrack_lib.allocateQubit.restype = None
476
+ self.qrack_lib.allocateQubit.argtypes = [c_ulonglong, c_ulonglong]
477
+
478
+ self.qrack_lib.release.restype = c_bool
479
+ self.qrack_lib.release.argtypes = [c_ulonglong, c_ulonglong]
480
+
481
+ self.qrack_lib.num_qubits.restype = c_ulonglong
482
+ self.qrack_lib.num_qubits.argtypes = [c_ulonglong]
483
+
484
+ # single-qubit gates
485
+
486
+ self.qrack_lib.X.restype = None
487
+ self.qrack_lib.X.argtypes = [c_ulonglong, c_ulonglong]
488
+
489
+ self.qrack_lib.Y.restype = None
490
+ self.qrack_lib.Y.argtypes = [c_ulonglong, c_ulonglong]
491
+
492
+ self.qrack_lib.Z.restype = None
493
+ self.qrack_lib.Z.argtypes = [c_ulonglong, c_ulonglong]
494
+
495
+ self.qrack_lib.H.restype = None
496
+ self.qrack_lib.H.argtypes = [c_ulonglong, c_ulonglong]
497
+
498
+ self.qrack_lib.S.restype = None
499
+ self.qrack_lib.S.argtypes = [c_ulonglong, c_ulonglong]
500
+
501
+ self.qrack_lib.T.restype = None
502
+ self.qrack_lib.T.argtypes = [c_ulonglong, c_ulonglong]
503
+
504
+ self.qrack_lib.AdjS.restype = None
505
+ self.qrack_lib.AdjS.argtypes = [c_ulonglong, c_ulonglong]
506
+
507
+ self.qrack_lib.AdjT.restype = None
508
+ self.qrack_lib.AdjT.argtypes = [c_ulonglong, c_ulonglong]
509
+
510
+ self.qrack_lib.U.restype = None
511
+ self.qrack_lib.U.argtypes = [
512
+ c_ulonglong,
513
+ c_ulonglong,
514
+ c_double,
515
+ c_double,
516
+ c_double
517
+ ]
518
+
519
+ self.qrack_lib.Mtrx.restype = None
520
+ self.qrack_lib.Mtrx.argtypes = [c_ulonglong, POINTER(c_double), c_ulonglong]
521
+
522
+ # multi-controlled single-qubit gates
523
+
524
+ self.qrack_lib.MCX.restype = None
525
+ self.qrack_lib.MCX.argtypes = [
526
+ c_ulonglong,
527
+ c_ulonglong,
528
+ POINTER(c_ulonglong),
529
+ c_ulonglong
530
+ ]
531
+
532
+ self.qrack_lib.MCY.restype = None
533
+ self.qrack_lib.MCY.argtypes = [
534
+ c_ulonglong,
535
+ c_ulonglong,
536
+ POINTER(c_ulonglong),
537
+ c_ulonglong
538
+ ]
539
+
540
+ self.qrack_lib.MCZ.restype = None
541
+ self.qrack_lib.MCZ.argtypes = [
542
+ c_ulonglong,
543
+ c_ulonglong,
544
+ POINTER(c_ulonglong),
545
+ c_ulonglong
546
+ ]
547
+
548
+ self.qrack_lib.MCH.restype = None
549
+ self.qrack_lib.MCH.argtypes = [
550
+ c_ulonglong,
551
+ c_ulonglong,
552
+ POINTER(c_ulonglong),
553
+ c_ulonglong
554
+ ]
555
+
556
+ self.qrack_lib.MCS.restype = None
557
+ self.qrack_lib.MCS.argtypes = [
558
+ c_ulonglong,
559
+ c_ulonglong,
560
+ POINTER(c_ulonglong),
561
+ c_ulonglong
562
+ ]
563
+
564
+ self.qrack_lib.MCT.restype = None
565
+ self.qrack_lib.MCT.argtypes = [
566
+ c_ulonglong,
567
+ c_ulonglong,
568
+ POINTER(c_ulonglong),
569
+ c_ulonglong
570
+ ]
571
+
572
+ self.qrack_lib.MCAdjS.restype = None
573
+ self.qrack_lib.MCAdjS.argtypes = [
574
+ c_ulonglong,
575
+ c_ulonglong,
576
+ POINTER(c_ulonglong),
577
+ c_ulonglong
578
+ ]
579
+
580
+ self.qrack_lib.MCAdjT.restype = None
581
+ self.qrack_lib.MCAdjT.argtypes = [
582
+ c_ulonglong,
583
+ c_ulonglong,
584
+ POINTER(c_ulonglong),
585
+ c_ulonglong
586
+ ]
587
+
588
+ self.qrack_lib.MCU.restype = None
589
+ self.qrack_lib.MCU.argtypes = [
590
+ c_ulonglong,
591
+ c_ulonglong,
592
+ POINTER(c_ulonglong),
593
+ c_ulonglong,
594
+ c_double,
595
+ c_double,
596
+ c_double
597
+ ]
598
+
599
+ self.qrack_lib.MCMtrx.restype = None
600
+ self.qrack_lib.MCMtrx.argtypes = [
601
+ c_ulonglong,
602
+ c_ulonglong,
603
+ POINTER(c_ulonglong),
604
+ POINTER(c_double),
605
+ c_ulonglong
606
+ ]
607
+
608
+ # multi-anti-controlled single-qubit gates
609
+
610
+ self.qrack_lib.MACX.restype = None
611
+ self.qrack_lib.MACX.argtypes = [
612
+ c_ulonglong,
613
+ c_ulonglong,
614
+ POINTER(c_ulonglong),
615
+ c_ulonglong
616
+ ]
617
+
618
+ self.qrack_lib.MACY.restype = None
619
+ self.qrack_lib.MACY.argtypes = [
620
+ c_ulonglong,
621
+ c_ulonglong,
622
+ POINTER(c_ulonglong),
623
+ c_ulonglong
624
+ ]
625
+
626
+ self.qrack_lib.MACZ.restype = None
627
+ self.qrack_lib.MACZ.argtypes = [
628
+ c_ulonglong,
629
+ c_ulonglong,
630
+ POINTER(c_ulonglong),
631
+ c_ulonglong
632
+ ]
633
+
634
+ self.qrack_lib.MACH.restype = None
635
+ self.qrack_lib.MACH.argtypes = [
636
+ c_ulonglong,
637
+ c_ulonglong,
638
+ POINTER(c_ulonglong),
639
+ c_ulonglong
640
+ ]
641
+
642
+ self.qrack_lib.MACS.restype = None
643
+ self.qrack_lib.MACS.argtypes = [
644
+ c_ulonglong,
645
+ c_ulonglong,
646
+ POINTER(c_ulonglong),
647
+ c_ulonglong
648
+ ]
649
+
650
+ self.qrack_lib.MACT.restype = None
651
+ self.qrack_lib.MACT.argtypes = [
652
+ c_ulonglong,
653
+ c_ulonglong,
654
+ POINTER(c_ulonglong),
655
+ c_ulonglong
656
+ ]
657
+
658
+ self.qrack_lib.MACAdjS.restype = None
659
+ self.qrack_lib.MACAdjS.argtypes = [
660
+ c_ulonglong,
661
+ c_ulonglong,
662
+ POINTER(c_ulonglong),
663
+ c_ulonglong
664
+ ]
665
+
666
+ self.qrack_lib.MACAdjT.restype = None
667
+ self.qrack_lib.MACAdjT.argtypes = [
668
+ c_ulonglong,
669
+ c_ulonglong,
670
+ POINTER(c_ulonglong),
671
+ c_ulonglong
672
+ ]
673
+
674
+ self.qrack_lib.MACU.restype = None
675
+ self.qrack_lib.MACU.argtypes = [
676
+ c_ulonglong,
677
+ c_ulonglong,
678
+ POINTER(c_ulonglong),
679
+ c_ulonglong,
680
+ c_double,
681
+ c_double,
682
+ c_double
683
+ ]
684
+
685
+ self.qrack_lib.MACMtrx.restype = None
686
+ self.qrack_lib.MACMtrx.argtypes = [
687
+ c_ulonglong,
688
+ c_ulonglong,
689
+ POINTER(c_ulonglong),
690
+ POINTER(c_double),
691
+ c_ulonglong
692
+ ]
693
+
694
+ self.qrack_lib.UCMtrx.restype = None
695
+ self.qrack_lib.UCMtrx.argtypes = [
696
+ c_ulonglong,
697
+ c_ulonglong,
698
+ POINTER(c_ulonglong),
699
+ POINTER(c_double),
700
+ c_ulonglong,
701
+ c_ulonglong
702
+ ]
703
+
704
+ self.qrack_lib.Multiplex1Mtrx.restype = None
705
+ self.qrack_lib.Multiplex1Mtrx.argtypes = [
706
+ c_ulonglong,
707
+ c_ulonglong,
708
+ POINTER(c_ulonglong),
709
+ c_ulonglong,
710
+ POINTER(c_double)
711
+ ]
712
+
713
+ # coalesced single qubit gates
714
+
715
+ self.qrack_lib.MX.restype = None
716
+ self.qrack_lib.MX.argtypes = [c_ulonglong, c_ulonglong, POINTER(c_ulonglong)]
717
+
718
+ self.qrack_lib.MY.restype = None
719
+ self.qrack_lib.MY.argtypes = [c_ulonglong, c_ulonglong, POINTER(c_ulonglong)]
720
+
721
+ self.qrack_lib.MZ.restype = None
722
+ self.qrack_lib.MZ.argtypes = [c_ulonglong, c_ulonglong, POINTER(c_ulonglong)]
723
+
724
+ # rotations
725
+
726
+ self.qrack_lib.R.restype = None
727
+ self.qrack_lib.R.argtypes = [c_ulonglong, c_ulonglong, c_double, c_ulonglong]
728
+
729
+ self.qrack_lib.MCR.restype = None
730
+ self.qrack_lib.MCR.argtypes = [
731
+ c_ulonglong,
732
+ c_ulonglong,
733
+ c_double,
734
+ c_ulonglong,
735
+ POINTER(c_ulonglong),
736
+ c_ulonglong
737
+ ]
738
+
739
+ # exponential of Pauli operators
740
+
741
+ self.qrack_lib.Exp.restype = None
742
+ self.qrack_lib.Exp.argtypes = [
743
+ c_ulonglong,
744
+ c_ulonglong,
745
+ POINTER(c_int),
746
+ c_double,
747
+ POINTER(c_ulonglong)
748
+ ]
749
+
750
+ self.qrack_lib.MCExp.restype = None
751
+ self.qrack_lib.MCExp.argtypes = [
752
+ c_ulonglong,
753
+ c_ulonglong,
754
+ POINTER(c_int),
755
+ c_double,
756
+ c_ulonglong,
757
+ POINTER(c_ulonglong),
758
+ POINTER(c_ulonglong)
759
+ ]
760
+
761
+ # measurements
762
+
763
+ self.qrack_lib.M.restype = c_ulonglong
764
+ self.qrack_lib.M.argtypes = [c_ulonglong, c_ulonglong]
765
+
766
+ self.qrack_lib.ForceM.restype = c_ulonglong
767
+ self.qrack_lib.ForceM.argtypes = [c_ulonglong, c_ulonglong, c_bool]
768
+
769
+ self.qrack_lib.MAll.restype = c_ulonglong
770
+ self.qrack_lib.MAll.argtypes = [c_ulonglong]
771
+
772
+ self.qrack_lib.Measure.restype = c_ulonglong
773
+ self.qrack_lib.Measure.argtypes = [
774
+ c_ulonglong,
775
+ c_ulonglong,
776
+ POINTER(c_int),
777
+ POINTER(c_ulonglong)
778
+ ]
779
+
780
+ self.qrack_lib.MeasureShots.restype = None
781
+ self.qrack_lib.MeasureShots.argtypes = [
782
+ c_ulonglong,
783
+ c_ulonglong,
784
+ POINTER(c_ulonglong),
785
+ c_ulonglong,
786
+ POINTER(c_ulonglong)
787
+ ]
788
+
789
+ # swap
790
+
791
+ self.qrack_lib.SWAP.restype = None
792
+ self.qrack_lib.SWAP.argtypes = [c_ulonglong, c_ulonglong, c_ulonglong]
793
+
794
+ self.qrack_lib.ISWAP.restype = None
795
+ self.qrack_lib.ISWAP.argtypes = [c_ulonglong, c_ulonglong, c_ulonglong]
796
+
797
+ self.qrack_lib.AdjISWAP.restype = None
798
+ self.qrack_lib.AdjISWAP.argtypes = [c_ulonglong, c_ulonglong, c_ulonglong]
799
+
800
+ self.qrack_lib.FSim.restype = None
801
+ self.qrack_lib.FSim.argtypes = [
802
+ c_ulonglong,
803
+ c_double,
804
+ c_double,
805
+ c_ulonglong,
806
+ c_ulonglong
807
+ ]
808
+
809
+ self.qrack_lib.CSWAP.restype = None
810
+ self.qrack_lib.CSWAP.argtypes = [
811
+ c_ulonglong,
812
+ c_ulonglong,
813
+ POINTER(c_ulonglong),
814
+ c_ulonglong,
815
+ c_ulonglong
816
+ ]
817
+
818
+ self.qrack_lib.ACSWAP.restype = None
819
+ self.qrack_lib.ACSWAP.argtypes = [
820
+ c_ulonglong,
821
+ c_ulonglong,
822
+ POINTER(c_ulonglong),
823
+ c_ulonglong,
824
+ c_ulonglong
825
+ ]
826
+
827
+ # Schmidt decomposition
828
+
829
+ self.qrack_lib.Compose.restype = None
830
+ self.qrack_lib.Compose.argtypes = [
831
+ c_ulonglong,
832
+ c_ulonglong,
833
+ POINTER(c_ulonglong)
834
+ ]
835
+
836
+ self.qrack_lib.Decompose.restype = c_ulonglong
837
+ self.qrack_lib.Decompose.argtypes = [
838
+ c_ulonglong,
839
+ c_ulonglong,
840
+ POINTER(c_ulonglong)
841
+ ]
842
+
843
+ self.qrack_lib.Dispose.restype = None
844
+ self.qrack_lib.Dispose.argtypes = [
845
+ c_ulonglong,
846
+ c_ulonglong,
847
+ POINTER(c_ulonglong)
848
+ ]
849
+
850
+ # (quasi-)Boolean gates
851
+
852
+ self.qrack_lib.AND.restype = None
853
+ self.qrack_lib.AND.argtypes = [
854
+ c_ulonglong,
855
+ c_ulonglong,
856
+ c_ulonglong,
857
+ c_ulonglong
858
+ ]
859
+
860
+ self.qrack_lib.OR.restype = None
861
+ self.qrack_lib.OR.argtypes = [
862
+ c_ulonglong,
863
+ c_ulonglong,
864
+ c_ulonglong,
865
+ c_ulonglong
866
+ ]
867
+
868
+ self.qrack_lib.XOR.restype = None
869
+ self.qrack_lib.XOR.argtypes = [
870
+ c_ulonglong,
871
+ c_ulonglong,
872
+ c_ulonglong,
873
+ c_ulonglong
874
+ ]
875
+
876
+ self.qrack_lib.NAND.restype = None
877
+ self.qrack_lib.NAND.argtypes = [
878
+ c_ulonglong,
879
+ c_ulonglong,
880
+ c_ulonglong,
881
+ c_ulonglong
882
+ ]
883
+
884
+ self.qrack_lib.NOR.restype = None
885
+ self.qrack_lib.NOR.argtypes = [
886
+ c_ulonglong,
887
+ c_ulonglong,
888
+ c_ulonglong,
889
+ c_ulonglong
890
+ ]
891
+
892
+ self.qrack_lib.XNOR.restype = None
893
+ self.qrack_lib.XNOR.argtypes = [
894
+ c_ulonglong,
895
+ c_ulonglong,
896
+ c_ulonglong,
897
+ c_ulonglong
898
+ ]
899
+
900
+ # half classical (quasi-)Boolean gates
901
+
902
+ self.qrack_lib.CLAND.restype = None
903
+ self.qrack_lib.CLAND.argtypes = [c_ulonglong, c_bool, c_ulonglong, c_ulonglong]
904
+
905
+ self.qrack_lib.CLOR.restype = None
906
+ self.qrack_lib.CLOR.argtypes = [c_ulonglong, c_bool, c_ulonglong, c_ulonglong]
907
+
908
+ self.qrack_lib.CLXOR.restype = None
909
+ self.qrack_lib.CLXOR.argtypes = [c_ulonglong, c_bool, c_ulonglong, c_ulonglong]
910
+
911
+ self.qrack_lib.CLNAND.restype = None
912
+ self.qrack_lib.CLNAND.argtypes = [c_ulonglong, c_bool, c_ulonglong, c_ulonglong]
913
+
914
+ self.qrack_lib.CLNOR.restype = None
915
+ self.qrack_lib.CLNOR.argtypes = [c_ulonglong, c_bool, c_ulonglong, c_ulonglong]
916
+
917
+ self.qrack_lib.CLXNOR.restype = None
918
+ self.qrack_lib.CLXNOR.argtypes = [c_ulonglong, c_bool, c_ulonglong, c_ulonglong]
919
+
920
+ # Fourier transform
921
+
922
+ self.qrack_lib.QFT.restype = None
923
+ self.qrack_lib.QFT.argtypes = [c_ulonglong, c_ulonglong, POINTER(c_ulonglong)]
924
+
925
+ self.qrack_lib.IQFT.restype = None
926
+ self.qrack_lib.IQFT.argtypes = [c_ulonglong, c_ulonglong, POINTER(c_ulonglong)]
927
+
928
+ # Arithmetic-Logic-Unit (ALU)
929
+
930
+ self.qrack_lib.ADD.restype = None
931
+ self.qrack_lib.ADD.argtypes = [
932
+ c_ulonglong,
933
+ c_ulonglong,
934
+ POINTER(c_ulonglong),
935
+ c_ulonglong,
936
+ POINTER(c_ulonglong)
937
+ ]
938
+
939
+ self.qrack_lib.SUB.restype = None
940
+ self.qrack_lib.SUB.argtypes = [
941
+ c_ulonglong,
942
+ c_ulonglong,
943
+ POINTER(c_ulonglong),
944
+ c_ulonglong,
945
+ POINTER(c_ulonglong)
946
+ ]
947
+
948
+ self.qrack_lib.ADDS.restype = None
949
+ self.qrack_lib.ADDS.argtypes = [
950
+ c_ulonglong,
951
+ c_ulonglong,
952
+ POINTER(c_ulonglong),
953
+ c_ulonglong,
954
+ c_ulonglong,
955
+ POINTER(c_ulonglong)
956
+ ]
957
+
958
+ self.qrack_lib.SUBS.restype = None
959
+ self.qrack_lib.SUBS.argtypes = [
960
+ c_ulonglong,
961
+ c_ulonglong,
962
+ POINTER(c_ulonglong),
963
+ c_ulonglong,
964
+ c_ulonglong,
965
+ POINTER(c_ulonglong)
966
+ ]
967
+
968
+ self.qrack_lib.MUL.restype = None
969
+ self.qrack_lib.MUL.argtypes = [
970
+ c_ulonglong,
971
+ c_ulonglong,
972
+ POINTER(c_ulonglong),
973
+ c_ulonglong,
974
+ POINTER(c_ulonglong),
975
+ POINTER(c_ulonglong)
976
+ ]
977
+
978
+ self.qrack_lib.DIV.restype = None
979
+ self.qrack_lib.DIV.argtypes = [
980
+ c_ulonglong,
981
+ c_ulonglong,
982
+ POINTER(c_ulonglong),
983
+ c_ulonglong,
984
+ POINTER(c_ulonglong),
985
+ POINTER(c_ulonglong)
986
+ ]
987
+
988
+ self.qrack_lib.MULN.restype = None
989
+ self.qrack_lib.MULN.argtypes = [
990
+ c_ulonglong,
991
+ c_ulonglong,
992
+ POINTER(c_ulonglong),
993
+ POINTER(c_ulonglong),
994
+ c_ulonglong,
995
+ POINTER(c_ulonglong),
996
+ POINTER(c_ulonglong)
997
+ ]
998
+
999
+ self.qrack_lib.DIVN.restype = None
1000
+ self.qrack_lib.DIVN.argtypes = [
1001
+ c_ulonglong,
1002
+ c_ulonglong,
1003
+ POINTER(c_ulonglong),
1004
+ POINTER(c_ulonglong),
1005
+ c_ulonglong,
1006
+ POINTER(c_ulonglong),
1007
+ POINTER(c_ulonglong)
1008
+ ]
1009
+
1010
+ self.qrack_lib.POWN.restype = None
1011
+ self.qrack_lib.POWN.argtypes = [
1012
+ c_ulonglong,
1013
+ c_ulonglong,
1014
+ POINTER(c_ulonglong),
1015
+ POINTER(c_ulonglong),
1016
+ c_ulonglong,
1017
+ POINTER(c_ulonglong),
1018
+ POINTER(c_ulonglong)
1019
+ ]
1020
+
1021
+ self.qrack_lib.MCADD.restype = None
1022
+ self.qrack_lib.MCADD.argtypes = [
1023
+ c_ulonglong,
1024
+ c_ulonglong,
1025
+ POINTER(c_ulonglong),
1026
+ c_ulonglong,
1027
+ POINTER(c_ulonglong),
1028
+ c_ulonglong,
1029
+ POINTER(c_ulonglong)
1030
+ ]
1031
+
1032
+ self.qrack_lib.MCSUB.restype = None
1033
+ self.qrack_lib.MCSUB.argtypes = [
1034
+ c_ulonglong,
1035
+ c_ulonglong,
1036
+ POINTER(c_ulonglong),
1037
+ c_ulonglong,
1038
+ POINTER(c_ulonglong),
1039
+ c_ulonglong,
1040
+ POINTER(c_ulonglong)
1041
+ ]
1042
+
1043
+ self.qrack_lib.MCMUL.restype = None
1044
+ self.qrack_lib.MCMUL.argtypes = [
1045
+ c_ulonglong,
1046
+ c_ulonglong,
1047
+ POINTER(c_ulonglong),
1048
+ c_ulonglong,
1049
+ POINTER(c_ulonglong),
1050
+ c_ulonglong,
1051
+ POINTER(c_ulonglong)
1052
+ ]
1053
+
1054
+ self.qrack_lib.MCDIV.restype = None
1055
+ self.qrack_lib.MCDIV.argtypes = [
1056
+ c_ulonglong,
1057
+ c_ulonglong,
1058
+ POINTER(c_ulonglong),
1059
+ c_ulonglong,
1060
+ POINTER(c_ulonglong),
1061
+ c_ulonglong,
1062
+ POINTER(c_ulonglong)
1063
+ ]
1064
+
1065
+ self.qrack_lib.MCMULN.restype = None
1066
+ self.qrack_lib.MCMULN.argtypes = [
1067
+ c_ulonglong,
1068
+ c_ulonglong,
1069
+ POINTER(c_ulonglong),
1070
+ c_ulonglong,
1071
+ POINTER(c_ulonglong),
1072
+ POINTER(c_ulonglong),
1073
+ c_ulonglong,
1074
+ POINTER(c_ulonglong),
1075
+ POINTER(c_ulonglong)
1076
+ ]
1077
+
1078
+ self.qrack_lib.MCDIVN.restype = None
1079
+ self.qrack_lib.MCDIVN.argtypes = [
1080
+ c_ulonglong,
1081
+ c_ulonglong,
1082
+ POINTER(c_ulonglong),
1083
+ c_ulonglong,
1084
+ POINTER(c_ulonglong),
1085
+ POINTER(c_ulonglong),
1086
+ c_ulonglong,
1087
+ POINTER(c_ulonglong),
1088
+ POINTER(c_ulonglong)
1089
+ ]
1090
+
1091
+ self.qrack_lib.MCPOWN.restype = None
1092
+ self.qrack_lib.MCPOWN.argtypes = [
1093
+ c_ulonglong,
1094
+ c_ulonglong,
1095
+ POINTER(c_ulonglong),
1096
+ c_ulonglong,
1097
+ POINTER(c_ulonglong),
1098
+ POINTER(c_ulonglong),
1099
+ c_ulonglong,
1100
+ POINTER(c_ulonglong),
1101
+ POINTER(c_ulonglong)
1102
+ ]
1103
+
1104
+ self.qrack_lib.LDA.restype = None
1105
+ self.qrack_lib.LDA.argType = [
1106
+ c_ulonglong,
1107
+ c_ulonglong,
1108
+ POINTER(c_ulonglong),
1109
+ c_ulonglong,
1110
+ POINTER(c_ulonglong),
1111
+ POINTER(c_ubyte)
1112
+ ]
1113
+
1114
+ self.qrack_lib.ADC.restype = None
1115
+ self.qrack_lib.ADC.argType = [
1116
+ c_ulonglong,
1117
+ c_ulonglong,
1118
+ c_ulonglong,
1119
+ POINTER(c_ulonglong),
1120
+ c_ulonglong,
1121
+ POINTER(c_ulonglong),
1122
+ POINTER(c_ubyte)
1123
+ ]
1124
+
1125
+ self.qrack_lib.SBC.restype = None
1126
+ self.qrack_lib.SBC.argType = [
1127
+ c_ulonglong,
1128
+ c_ulonglong,
1129
+ c_ulonglong,
1130
+ POINTER(c_ulonglong),
1131
+ c_ulonglong,
1132
+ POINTER(c_ulonglong),
1133
+ POINTER(c_ubyte)
1134
+ ]
1135
+
1136
+ self.qrack_lib.Hash.restype = None
1137
+ self.qrack_lib.Hash.argType = [
1138
+ c_ulonglong,
1139
+ c_ulonglong,
1140
+ POINTER(c_ulonglong),
1141
+ POINTER(c_ubyte)
1142
+ ]
1143
+
1144
+ # miscellaneous
1145
+
1146
+ self.qrack_lib.TrySeparate1Qb.restype = c_bool
1147
+ self.qrack_lib.TrySeparate1Qb.argtypes = [c_ulonglong, c_ulonglong]
1148
+
1149
+ self.qrack_lib.TrySeparate2Qb.restype = c_bool
1150
+ self.qrack_lib.TrySeparate2Qb.argtypes = [c_ulonglong, c_ulonglong, c_ulonglong]
1151
+
1152
+ self.qrack_lib.TrySeparateTol.restype = c_bool
1153
+ self.qrack_lib.TrySeparateTol.argtypes = [
1154
+ c_ulonglong,
1155
+ c_ulonglong,
1156
+ POINTER(c_ulonglong),
1157
+ c_double
1158
+ ]
1159
+
1160
+ self.qrack_lib.Separate.restype = None
1161
+ self.qrack_lib.Separate.argtypes = [
1162
+ c_ulonglong,
1163
+ c_ulonglong,
1164
+ POINTER(c_ulonglong)
1165
+ ]
1166
+
1167
+ self.qrack_lib.GetUnitaryFidelity.restype = c_double
1168
+ self.qrack_lib.GetUnitaryFidelity.argtypes = [c_ulonglong]
1169
+
1170
+ self.qrack_lib.ResetUnitaryFidelity.restype = None
1171
+ self.qrack_lib.ResetUnitaryFidelity.argtypes = [c_ulonglong]
1172
+
1173
+ self.qrack_lib.SetSdrp.restype = None
1174
+ self.qrack_lib.SetSdrp.argtypes = [c_ulonglong, c_double]
1175
+
1176
+ self.qrack_lib.SetNcrp.restype = None
1177
+ self.qrack_lib.SetNcrp.argtypes = [c_ulonglong, c_double]
1178
+
1179
+ self.qrack_lib.SetReactiveSeparate.restype = None
1180
+ self.qrack_lib.SetReactiveSeparate.argtypes = [c_ulonglong, c_bool]
1181
+
1182
+ self.qrack_lib.SetTInjection.restype = None
1183
+ self.qrack_lib.SetTInjection.argtypes = [c_ulonglong, c_bool]
1184
+
1185
+ self.qrack_lib.SetNoiseParameter.restype = None
1186
+ self.qrack_lib.SetNoiseParameter.argtypes = [c_ulonglong, c_double]
1187
+
1188
+ self.qrack_lib.Normalize.restype = None
1189
+ self.qrack_lib.Normalize.argtypes = [c_ulonglong]
1190
+
1191
+ self.qrack_lib.qstabilizer_out_to_file.restype = None
1192
+ self.qrack_lib.qstabilizer_out_to_file.argtypes = [c_ulonglong, c_char_p]
1193
+
1194
+ self.qrack_lib.qstabilizer_in_from_file.restype = None
1195
+ self.qrack_lib.qstabilizer_in_from_file.argtypes = [c_ulonglong, c_char_p]
1196
+
1197
+ self.qrack_lib.init_qneuron.restype = c_ulonglong
1198
+ self.qrack_lib.init_qneuron.argtypes = [c_ulonglong, c_ulonglong, POINTER(c_ulonglong), c_ulonglong, c_ulonglong, c_double, c_double]
1199
+
1200
+ self.qrack_lib.clone_qneuron.restype = c_ulonglong
1201
+ self.qrack_lib.clone_qneuron.argtypes = [c_ulonglong]
1202
+
1203
+ self.qrack_lib.destroy_qneuron.restype = None
1204
+ self.qrack_lib.destroy_qneuron.argtypes = [c_ulonglong]
1205
+
1206
+ self.qrack_lib.set_qneuron_angles.restype = None
1207
+ self.qrack_lib.get_qneuron_angles.restype = None
1208
+
1209
+ if self.fppow == 5:
1210
+ self.qrack_lib.set_qneuron_angles.argtypes = [c_ulonglong, POINTER(c_float)]
1211
+ self.qrack_lib.get_qneuron_angles.argtypes = [c_ulonglong, POINTER(c_float)]
1212
+ elif self.fppow == 6:
1213
+ self.qrack_lib.set_qneuron_angles.argtypes = [c_ulonglong, POINTER(c_double)]
1214
+ self.qrack_lib.get_qneuron_angles.argtypes = [c_ulonglong, POINTER(c_double)]
1215
+
1216
+ self.qrack_lib.set_qneuron_alpha.restype = None
1217
+ self.qrack_lib.set_qneuron_alpha.argtypes = [c_ulonglong, c_double]
1218
+
1219
+ self.qrack_lib.get_qneuron_alpha.restype = c_double
1220
+ self.qrack_lib.get_qneuron_alpha.argtypes = [c_ulonglong]
1221
+
1222
+ self.qrack_lib.set_qneuron_activation_fn.restype = None
1223
+ self.qrack_lib.set_qneuron_activation_fn.argtypes = [c_ulonglong, c_ulonglong]
1224
+
1225
+ self.qrack_lib.get_qneuron_activation_fn.restype = c_ulonglong
1226
+ self.qrack_lib.get_qneuron_activation_fn.argtypes = [c_ulonglong]
1227
+
1228
+ self.qrack_lib.qneuron_predict.restype = c_double
1229
+ self.qrack_lib.qneuron_predict.argtypes = [c_ulonglong, c_bool, c_bool]
1230
+
1231
+ self.qrack_lib.qneuron_unpredict.restype = c_double
1232
+ self.qrack_lib.qneuron_unpredict.argtypes = [c_ulonglong, c_bool]
1233
+
1234
+ self.qrack_lib.qneuron_learn_cycle.restype = c_double
1235
+ self.qrack_lib.qneuron_learn_cycle.argtypes = [c_ulonglong, c_bool]
1236
+
1237
+ self.qrack_lib.qneuron_learn.restype = None
1238
+ self.qrack_lib.qneuron_learn.argtypes = [c_ulonglong, c_double, c_bool, c_bool]
1239
+
1240
+ self.qrack_lib.qneuron_learn_permutation.restype = None
1241
+ self.qrack_lib.qneuron_learn_permutation.argtypes = [c_ulonglong, c_double, c_bool, c_bool]
1242
+
1243
+ self.qrack_lib.init_qcircuit.restype = c_ulonglong
1244
+ self.qrack_lib.init_qcircuit.argtypes = [c_bool, c_bool]
1245
+
1246
+ self.qrack_lib.init_qcircuit_clone.restype = c_ulonglong
1247
+ self.qrack_lib.init_qcircuit_clone.argtypes = [c_ulonglong]
1248
+
1249
+ self.qrack_lib.qcircuit_inverse.restype = c_ulonglong
1250
+ self.qrack_lib.qcircuit_inverse.argtypes = [c_ulonglong]
1251
+
1252
+ self.qrack_lib.qcircuit_past_light_cone.restype = c_ulonglong
1253
+ self.qrack_lib.qcircuit_past_light_cone.argtypes = [c_ulonglong, c_ulonglong, POINTER(c_ulonglong)]
1254
+
1255
+ self.qrack_lib.destroy_qcircuit.restype = None
1256
+ self.qrack_lib.destroy_qcircuit.argtypes = [c_ulonglong]
1257
+
1258
+ self.qrack_lib.get_qcircuit_qubit_count.restype = c_ulonglong
1259
+ self.qrack_lib.get_qcircuit_qubit_count.argtypes = [c_ulonglong]
1260
+
1261
+ self.qrack_lib.qcircuit_swap.restype = None
1262
+ self.qrack_lib.qcircuit_swap.argtypes = [c_ulonglong, c_ulonglong, c_ulonglong]
1263
+
1264
+ self.qrack_lib.qcircuit_append_1qb.restype = None
1265
+ self.qrack_lib.qcircuit_append_1qb.argtypes = [c_ulonglong, POINTER(c_double), c_ulonglong]
1266
+
1267
+ self.qrack_lib.qcircuit_append_mc.restype = None
1268
+ self.qrack_lib.qcircuit_append_mc.argtypes = [c_ulonglong, POINTER(c_double), c_ulonglong, POINTER(c_ulonglong), c_ulonglong, c_ulonglong]
1269
+
1270
+ self.qrack_lib.qcircuit_run.restype = None
1271
+ self.qrack_lib.qcircuit_run.argtypes = [c_ulonglong, c_ulonglong]
1272
+
1273
+ self.qrack_lib.qcircuit_out_to_file.restype = None
1274
+ self.qrack_lib.qcircuit_out_to_file.argtypes = [c_ulonglong, c_char_p]
1275
+
1276
+ self.qrack_lib.qcircuit_in_from_file.restype = None
1277
+ self.qrack_lib.qcircuit_in_from_file.argtypes = [c_ulonglong, c_char_p]