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