pyqrack-cpu-complex128 1.58.0__py3-none-win_amd64.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-complex128 might be problematic. Click here for more details.

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