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