pyqrack-cpu-complex128 1.69.0__py3-none-win_amd64.whl → 1.78.3__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.
@@ -60,6 +60,7 @@ class QrackSimulator:
60
60
  isHostPointer=(
61
61
  True if os.environ.get("PYQRACK_HOST_POINTER_DEFAULT_ON") else False
62
62
  ),
63
+ isSparse=False,
63
64
  noise=0,
64
65
  pyzxCircuit=None,
65
66
  qiskitCircuit=None,
@@ -99,6 +100,7 @@ class QrackSimulator:
99
100
  isCpuGpuHybrid,
100
101
  isOpenCL,
101
102
  isHostPointer,
103
+ isSparse
102
104
  )
103
105
 
104
106
  self._throw_if_error()
@@ -116,36 +118,45 @@ class QrackSimulator:
116
118
  Qrack.qrack_lib.destroy(self.sid)
117
119
  self.sid = None
118
120
 
119
- def _int_byref(self, a):
121
+ @staticmethod
122
+ def _int_byref(a):
120
123
  return (ctypes.c_int * len(a))(*a)
121
124
 
122
- def _ulonglong_byref(self, a):
125
+ @staticmethod
126
+ def _ulonglong_byref(a):
123
127
  return (ctypes.c_ulonglong * len(a))(*a)
124
128
 
125
- def _longlong_byref(self, a):
129
+ @staticmethod
130
+ def _longlong_byref(a):
126
131
  return (ctypes.c_longlong * len(a))(*a)
127
132
 
128
- def _double_byref(self, a):
133
+ @staticmethod
134
+ def _double_byref(a):
129
135
  return (ctypes.c_double * len(a))(*a)
130
136
 
131
- def _complex_byref(self, a):
137
+ @staticmethod
138
+ def _complex_byref(a):
132
139
  t = [(c.real, c.imag) for c in a]
133
- return self._double_byref([float(item) for sublist in t for item in sublist])
140
+ return QrackSimulator._double_byref([float(item) for sublist in t for item in sublist])
134
141
 
135
- def _real1_byref(self, a):
142
+ @staticmethod
143
+ def _real1_byref(a):
136
144
  # This needs to be c_double, if PyQrack is built with fp64.
137
145
  if Qrack.fppow < 6:
138
146
  return (ctypes.c_float * len(a))(*a)
139
147
  return (ctypes.c_double * len(a))(*a)
140
148
 
141
- def _bool_byref(self, a):
149
+ @staticmethod
150
+ def _bool_byref(a):
142
151
  return (ctypes.c_bool * len(a))(*a)
143
152
 
144
- def _qrack_complex_byref(self, a):
153
+ @staticmethod
154
+ def _qrack_complex_byref(a):
145
155
  t = [(c.real, c.imag) for c in a]
146
- return self._real1_byref([float(item) for sublist in t for item in sublist])
156
+ return QrackSimulator._real1_byref([float(item) for sublist in t for item in sublist])
147
157
 
148
- def _to_ubyte(self, nv, v):
158
+ @staticmethod
159
+ def _to_ubyte(nv, v):
149
160
  c = math.floor((nv - 1) / 8) + 1
150
161
  b = (ctypes.c_ubyte * (c * (1 << nv)))()
151
162
  n = 0
@@ -157,7 +168,8 @@ class QrackSimulator:
157
168
 
158
169
  return b
159
170
 
160
- def _to_ulonglong(self, m, v):
171
+ @staticmethod
172
+ def _to_ulonglong(m, v):
161
173
  b = (ctypes.c_ulonglong * (m * len(v)))()
162
174
  n = 0
163
175
  for u in v:
@@ -169,7 +181,8 @@ class QrackSimulator:
169
181
  return b
170
182
 
171
183
  # See https://stackoverflow.com/questions/5389507/iterating-over-every-two-elements-in-a-list#answer-30426000
172
- def _pairwise(self, it):
184
+ @staticmethod
185
+ def _pairwise(it):
173
186
  it = iter(it)
174
187
  while True:
175
188
  try:
@@ -195,7 +208,7 @@ class QrackSimulator:
195
208
 
196
209
  def set_device_list(self, d):
197
210
  """Set the GPU device ID"""
198
- Qrack.qrack_lib.set_device_list(self.sid, len(d), self._longlong_byref(d))
211
+ Qrack.qrack_lib.set_device_list(self.sid, len(d), QrackSimulator._longlong_byref(d))
199
212
  self._throw_if_error()
200
213
 
201
214
  def clone(self):
@@ -359,7 +372,7 @@ class QrackSimulator:
359
372
  raise ValueError(
360
373
  "2x2 matrix 'm' in QrackSimulator.mtrx() must contain at least 4 elements."
361
374
  )
362
- Qrack.qrack_lib.Mtrx(self.sid, self._complex_byref(m), q)
375
+ Qrack.qrack_lib.Mtrx(self.sid, QrackSimulator._complex_byref(m), q)
363
376
  self._throw_if_error()
364
377
 
365
378
  def r(self, b, ph, q):
@@ -399,9 +412,9 @@ class QrackSimulator:
399
412
  Qrack.qrack_lib.Exp(
400
413
  self.sid,
401
414
  len(b),
402
- self._ulonglong_byref(b),
415
+ QrackSimulator._ulonglong_byref(b),
403
416
  ctypes.c_double(ph),
404
- self._ulonglong_byref(q),
417
+ QrackSimulator._ulonglong_byref(q),
405
418
  )
406
419
  self._throw_if_error()
407
420
 
@@ -418,7 +431,7 @@ class QrackSimulator:
418
431
  Raises:
419
432
  RuntimeError: QrackSimulator raised an exception.
420
433
  """
421
- Qrack.qrack_lib.MCX(self.sid, len(c), self._ulonglong_byref(c), q)
434
+ Qrack.qrack_lib.MCX(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
422
435
  self._throw_if_error()
423
436
 
424
437
  def mcy(self, c, q):
@@ -434,7 +447,7 @@ class QrackSimulator:
434
447
  Raises:
435
448
  RuntimeError: QrackSimulator raised an exception.
436
449
  """
437
- Qrack.qrack_lib.MCY(self.sid, len(c), self._ulonglong_byref(c), q)
450
+ Qrack.qrack_lib.MCY(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
438
451
  self._throw_if_error()
439
452
 
440
453
  def mcz(self, c, q):
@@ -450,7 +463,7 @@ class QrackSimulator:
450
463
  Raises:
451
464
  RuntimeError: QrackSimulator raised an exception.
452
465
  """
453
- Qrack.qrack_lib.MCZ(self.sid, len(c), self._ulonglong_byref(c), q)
466
+ Qrack.qrack_lib.MCZ(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
454
467
  self._throw_if_error()
455
468
 
456
469
  def mch(self, c, q):
@@ -466,7 +479,7 @@ class QrackSimulator:
466
479
  Raises:
467
480
  RuntimeError: QrackSimulator raised an exception.
468
481
  """
469
- Qrack.qrack_lib.MCH(self.sid, len(c), self._ulonglong_byref(c), q)
482
+ Qrack.qrack_lib.MCH(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
470
483
  self._throw_if_error()
471
484
 
472
485
  def mcs(self, c, q):
@@ -482,7 +495,7 @@ class QrackSimulator:
482
495
  Raises:
483
496
  RuntimeError: QrackSimulator raised an exception.
484
497
  """
485
- Qrack.qrack_lib.MCS(self.sid, len(c), self._ulonglong_byref(c), q)
498
+ Qrack.qrack_lib.MCS(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
486
499
  self._throw_if_error()
487
500
 
488
501
  def mct(self, c, q):
@@ -498,7 +511,7 @@ class QrackSimulator:
498
511
  Raises:
499
512
  RuntimeError: QrackSimulator raised an exception.
500
513
  """
501
- Qrack.qrack_lib.MCT(self.sid, len(c), self._ulonglong_byref(c), q)
514
+ Qrack.qrack_lib.MCT(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
502
515
  self._throw_if_error()
503
516
 
504
517
  def mcadjs(self, c, q):
@@ -514,7 +527,7 @@ class QrackSimulator:
514
527
  Raises:
515
528
  RuntimeError: QrackSimulator raised an exception.
516
529
  """
517
- Qrack.qrack_lib.MCAdjS(self.sid, len(c), self._ulonglong_byref(c), q)
530
+ Qrack.qrack_lib.MCAdjS(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
518
531
  self._throw_if_error()
519
532
 
520
533
  def mcadjt(self, c, q):
@@ -530,7 +543,7 @@ class QrackSimulator:
530
543
  Raises:
531
544
  RuntimeError: QrackSimulator raised an exception.
532
545
  """
533
- Qrack.qrack_lib.MCAdjT(self.sid, len(c), self._ulonglong_byref(c), q)
546
+ Qrack.qrack_lib.MCAdjT(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
534
547
  self._throw_if_error()
535
548
 
536
549
  def mcu(self, c, q, th, ph, la):
@@ -552,7 +565,7 @@ class QrackSimulator:
552
565
  Qrack.qrack_lib.MCU(
553
566
  self.sid,
554
567
  len(c),
555
- self._ulonglong_byref(c),
568
+ QrackSimulator._ulonglong_byref(c),
556
569
  q,
557
570
  ctypes.c_double(th),
558
571
  ctypes.c_double(ph),
@@ -580,7 +593,7 @@ class QrackSimulator:
580
593
  "2x2 matrix 'm' in QrackSimulator.mcmtrx() must contain at least 4 elements."
581
594
  )
582
595
  Qrack.qrack_lib.MCMtrx(
583
- self.sid, len(c), self._ulonglong_byref(c), self._complex_byref(m), q
596
+ self.sid, len(c), QrackSimulator._ulonglong_byref(c), QrackSimulator._complex_byref(m), q
584
597
  )
585
598
  self._throw_if_error()
586
599
 
@@ -596,7 +609,7 @@ class QrackSimulator:
596
609
  Raises:
597
610
  RuntimeError: QrackSimulator raised an exception.
598
611
  """
599
- Qrack.qrack_lib.MACX(self.sid, len(c), self._ulonglong_byref(c), q)
612
+ Qrack.qrack_lib.MACX(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
600
613
  self._throw_if_error()
601
614
 
602
615
  def macy(self, c, q):
@@ -612,7 +625,7 @@ class QrackSimulator:
612
625
  Raises:
613
626
  RuntimeError: QrackSimulator raised an exception.
614
627
  """
615
- Qrack.qrack_lib.MACY(self.sid, len(c), self._ulonglong_byref(c), q)
628
+ Qrack.qrack_lib.MACY(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
616
629
  self._throw_if_error()
617
630
 
618
631
  def macz(self, c, q):
@@ -628,7 +641,7 @@ class QrackSimulator:
628
641
  Raises:
629
642
  RuntimeError: QrackSimulator raised an exception.
630
643
  """
631
- Qrack.qrack_lib.MACZ(self.sid, len(c), self._ulonglong_byref(c), q)
644
+ Qrack.qrack_lib.MACZ(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
632
645
  self._throw_if_error()
633
646
 
634
647
  def mach(self, c, q):
@@ -644,7 +657,7 @@ class QrackSimulator:
644
657
  Raises:
645
658
  RuntimeError: QrackSimulator raised an exception.
646
659
  """
647
- Qrack.qrack_lib.MACH(self.sid, len(c), self._ulonglong_byref(c), q)
660
+ Qrack.qrack_lib.MACH(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
648
661
  self._throw_if_error()
649
662
 
650
663
  def macs(self, c, q):
@@ -660,7 +673,7 @@ class QrackSimulator:
660
673
  Raises:
661
674
  RuntimeError: QrackSimulator raised an exception.
662
675
  """
663
- Qrack.qrack_lib.MACS(self.sid, len(c), self._ulonglong_byref(c), q)
676
+ Qrack.qrack_lib.MACS(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
664
677
  self._throw_if_error()
665
678
 
666
679
  def mact(self, c, q):
@@ -676,7 +689,7 @@ class QrackSimulator:
676
689
  Raises:
677
690
  RuntimeError: QrackSimulator raised an exception.
678
691
  """
679
- Qrack.qrack_lib.MACT(self.sid, len(c), self._ulonglong_byref(c), q)
692
+ Qrack.qrack_lib.MACT(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
680
693
  self._throw_if_error()
681
694
 
682
695
  def macadjs(self, c, q):
@@ -692,7 +705,7 @@ class QrackSimulator:
692
705
  Raises:
693
706
  RuntimeError: QrackSimulator raised an exception.
694
707
  """
695
- Qrack.qrack_lib.MACAdjS(self.sid, len(c), self._ulonglong_byref(c), q)
708
+ Qrack.qrack_lib.MACAdjS(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
696
709
  self._throw_if_error()
697
710
 
698
711
  def macadjt(self, c, q):
@@ -708,7 +721,7 @@ class QrackSimulator:
708
721
  Raises:
709
722
  RuntimeError: QrackSimulator raised an exception.
710
723
  """
711
- Qrack.qrack_lib.MACAdjT(self.sid, len(c), self._ulonglong_byref(c), q)
724
+ Qrack.qrack_lib.MACAdjT(self.sid, len(c), QrackSimulator._ulonglong_byref(c), q)
712
725
  self._throw_if_error()
713
726
 
714
727
  def macu(self, c, q, th, ph, la):
@@ -730,7 +743,7 @@ class QrackSimulator:
730
743
  Qrack.qrack_lib.MACU(
731
744
  self.sid,
732
745
  len(c),
733
- self._ulonglong_byref(c),
746
+ QrackSimulator._ulonglong_byref(c),
734
747
  q,
735
748
  ctypes.c_double(th),
736
749
  ctypes.c_double(ph),
@@ -758,7 +771,7 @@ class QrackSimulator:
758
771
  "2x2 matrix 'm' in QrackSimulator.macmtrx() must contain at least 4 elements."
759
772
  )
760
773
  Qrack.qrack_lib.MACMtrx(
761
- self.sid, len(c), self._ulonglong_byref(c), self._complex_byref(m), q
774
+ self.sid, len(c), QrackSimulator._ulonglong_byref(c), QrackSimulator._complex_byref(m), q
762
775
  )
763
776
  self._throw_if_error()
764
777
 
@@ -783,7 +796,7 @@ class QrackSimulator:
783
796
  "2x2 matrix 'm' in QrackSimulator.ucmtrx() must contain at least 4 elements."
784
797
  )
785
798
  Qrack.qrack_lib.UCMtrx(
786
- self.sid, len(c), self._ulonglong_byref(c), self._complex_byref(m), q, p
799
+ self.sid, len(c), QrackSimulator._ulonglong_byref(c), QrackSimulator._complex_byref(m), q, p
787
800
  )
788
801
  self._throw_if_error()
789
802
 
@@ -807,7 +820,7 @@ class QrackSimulator:
807
820
  "Multiplex matrix 'm' in QrackSimulator.multiplex1_mtrx() must contain at least (4 * 2 ** len(c)) elements."
808
821
  )
809
822
  Qrack.qrack_lib.Multiplex1Mtrx(
810
- self.sid, len(c), self._ulonglong_byref(c), q, self._complex_byref(m)
823
+ self.sid, len(c), QrackSimulator._ulonglong_byref(c), q, QrackSimulator._complex_byref(m)
811
824
  )
812
825
  self._throw_if_error()
813
826
 
@@ -822,7 +835,7 @@ class QrackSimulator:
822
835
  Raises:
823
836
  RuntimeError: QrackSimulator raised an exception.
824
837
  """
825
- Qrack.qrack_lib.MX(self.sid, len(q), self._ulonglong_byref(q))
838
+ Qrack.qrack_lib.MX(self.sid, len(q), QrackSimulator._ulonglong_byref(q))
826
839
  self._throw_if_error()
827
840
 
828
841
  def my(self, q):
@@ -836,7 +849,7 @@ class QrackSimulator:
836
849
  Raises:
837
850
  RuntimeError: QrackSimulator raised an exception.
838
851
  """
839
- Qrack.qrack_lib.MY(self.sid, len(q), self._ulonglong_byref(q))
852
+ Qrack.qrack_lib.MY(self.sid, len(q), QrackSimulator._ulonglong_byref(q))
840
853
  self._throw_if_error()
841
854
 
842
855
  def mz(self, q):
@@ -850,7 +863,7 @@ class QrackSimulator:
850
863
  Raises:
851
864
  RuntimeError: QrackSimulator raised an exception.
852
865
  """
853
- Qrack.qrack_lib.MZ(self.sid, len(q), self._ulonglong_byref(q))
866
+ Qrack.qrack_lib.MZ(self.sid, len(q), QrackSimulator._ulonglong_byref(q))
854
867
  self._throw_if_error()
855
868
 
856
869
  def mcr(self, b, ph, c, q):
@@ -873,7 +886,7 @@ class QrackSimulator:
873
886
  ctypes.c_ulonglong(b),
874
887
  ctypes.c_double(ph),
875
888
  len(c),
876
- self._ulonglong_byref(c),
889
+ QrackSimulator._ulonglong_byref(c),
877
890
  q,
878
891
  )
879
892
  self._throw_if_error()
@@ -897,11 +910,11 @@ class QrackSimulator:
897
910
  Qrack.qrack_lib.MCExp(
898
911
  self.sid,
899
912
  len(b),
900
- self._ulonglong_byref(b),
913
+ QrackSimulator._ulonglong_byref(b),
901
914
  ctypes.c_double(ph),
902
915
  len(cs),
903
- self._ulonglong_byref(cs),
904
- self._ulonglong_byref(q),
916
+ QrackSimulator._ulonglong_byref(cs),
917
+ QrackSimulator._ulonglong_byref(q),
905
918
  )
906
919
  self._throw_if_error()
907
920
 
@@ -983,7 +996,7 @@ class QrackSimulator:
983
996
  Raises:
984
997
  RuntimeError: QrackSimulator raised an exception.
985
998
  """
986
- Qrack.qrack_lib.CSWAP(self.sid, len(c), self._ulonglong_byref(c), qi1, qi2)
999
+ Qrack.qrack_lib.CSWAP(self.sid, len(c), QrackSimulator._ulonglong_byref(c), qi1, qi2)
987
1000
  self._throw_if_error()
988
1001
 
989
1002
  def acswap(self, c, qi1, qi2):
@@ -999,7 +1012,7 @@ class QrackSimulator:
999
1012
  Raises:
1000
1013
  RuntimeError: QrackSimulator raised an exception.
1001
1014
  """
1002
- Qrack.qrack_lib.ACSWAP(self.sid, len(c), self._ulonglong_byref(c), qi1, qi2)
1015
+ Qrack.qrack_lib.ACSWAP(self.sid, len(c), QrackSimulator._ulonglong_byref(c), qi1, qi2)
1003
1016
  self._throw_if_error()
1004
1017
 
1005
1018
  # standard operations
@@ -1083,7 +1096,7 @@ class QrackSimulator:
1083
1096
  if len(b) != len(q):
1084
1097
  raise RuntimeError("Lengths of list parameters are mismatched.")
1085
1098
  result = Qrack.qrack_lib.Measure(
1086
- self.sid, len(b), self._int_byref(b), self._ulonglong_byref(q)
1099
+ self.sid, len(b), QrackSimulator._int_byref(b), QrackSimulator._ulonglong_byref(q)
1087
1100
  )
1088
1101
  self._throw_if_error()
1089
1102
  return result
@@ -1104,8 +1117,8 @@ class QrackSimulator:
1104
1117
  Returns:
1105
1118
  list of measurement result.
1106
1119
  """
1107
- m = self._ulonglong_byref([0] * s)
1108
- Qrack.qrack_lib.MeasureShots(self.sid, len(q), self._ulonglong_byref(q), s, m)
1120
+ m = QrackSimulator._ulonglong_byref([0] * s)
1121
+ Qrack.qrack_lib.MeasureShots(self.sid, len(q), QrackSimulator._ulonglong_byref(q), s, m)
1109
1122
  self._throw_if_error()
1110
1123
  return [m[i] for i in range(s)]
1111
1124
 
@@ -1121,7 +1134,8 @@ class QrackSimulator:
1121
1134
  self._throw_if_error()
1122
1135
 
1123
1136
  # arithmetic-logic-unit (ALU)
1124
- def _split_longs(self, a):
1137
+ @staticmethod
1138
+ def _split_longs(a):
1125
1139
  """Split operation
1126
1140
 
1127
1141
  Splits the given integer into 64 bit numbers.
@@ -1144,7 +1158,8 @@ class QrackSimulator:
1144
1158
  a = a >> 64
1145
1159
  return aParts
1146
1160
 
1147
- def _split_longs_2(self, a, m):
1161
+ @staticmethod
1162
+ def _split_longs_2(a, m):
1148
1163
  """Split simultanoues operation
1149
1164
 
1150
1165
  Splits 2 integers into same number of 64 bit numbers.
@@ -1183,13 +1198,13 @@ class QrackSimulator:
1183
1198
  Raises:
1184
1199
  RuntimeError: QrackSimulator raised an exception.
1185
1200
  """
1186
- aParts = self._split_longs(a)
1201
+ aParts = QrackSimulator._split_longs(a)
1187
1202
  Qrack.qrack_lib.ADD(
1188
1203
  self.sid,
1189
1204
  len(aParts),
1190
- self._ulonglong_byref(aParts),
1205
+ QrackSimulator._ulonglong_byref(aParts),
1191
1206
  len(q),
1192
- self._ulonglong_byref(q),
1207
+ QrackSimulator._ulonglong_byref(q),
1193
1208
  )
1194
1209
  self._throw_if_error()
1195
1210
 
@@ -1205,13 +1220,13 @@ class QrackSimulator:
1205
1220
  Raises:
1206
1221
  RuntimeError: QrackSimulator raised an exception.
1207
1222
  """
1208
- aParts = self._split_longs(a)
1223
+ aParts = QrackSimulator._split_longs(a)
1209
1224
  Qrack.qrack_lib.SUB(
1210
1225
  self.sid,
1211
1226
  len(aParts),
1212
- self._ulonglong_byref(aParts),
1227
+ QrackSimulator._ulonglong_byref(aParts),
1213
1228
  len(q),
1214
- self._ulonglong_byref(q),
1229
+ QrackSimulator._ulonglong_byref(q),
1215
1230
  )
1216
1231
  self._throw_if_error()
1217
1232
 
@@ -1229,14 +1244,14 @@ class QrackSimulator:
1229
1244
  Raises:
1230
1245
  RuntimeError: QrackSimulator raised an exception.
1231
1246
  """
1232
- aParts = self._split_longs(a)
1247
+ aParts = QrackSimulator._split_longs(a)
1233
1248
  Qrack.qrack_lib.ADDS(
1234
1249
  self.sid,
1235
1250
  len(aParts),
1236
- self._ulonglong_byref(aParts),
1251
+ QrackSimulator._ulonglong_byref(aParts),
1237
1252
  s,
1238
1253
  len(q),
1239
- self._ulonglong_byref(q),
1254
+ QrackSimulator._ulonglong_byref(q),
1240
1255
  )
1241
1256
  self._throw_if_error()
1242
1257
 
@@ -1254,14 +1269,14 @@ class QrackSimulator:
1254
1269
  Raises:
1255
1270
  RuntimeError: QrackSimulator raised an exception.
1256
1271
  """
1257
- aParts = self._split_longs(a)
1272
+ aParts = QrackSimulator._split_longs(a)
1258
1273
  Qrack.qrack_lib.SUBS(
1259
1274
  self.sid,
1260
1275
  len(aParts),
1261
- self._ulonglong_byref(aParts),
1276
+ QrackSimulator._ulonglong_byref(aParts),
1262
1277
  s,
1263
1278
  len(q),
1264
- self._ulonglong_byref(q),
1279
+ QrackSimulator._ulonglong_byref(q),
1265
1280
  )
1266
1281
  self._throw_if_error()
1267
1282
 
@@ -1292,14 +1307,14 @@ class QrackSimulator:
1292
1307
 
1293
1308
  if len(q) != len(o):
1294
1309
  raise RuntimeError("Lengths of list parameters are mismatched.")
1295
- aParts = self._split_longs(a)
1310
+ aParts = QrackSimulator._split_longs(a)
1296
1311
  Qrack.qrack_lib.MUL(
1297
1312
  self.sid,
1298
1313
  len(aParts),
1299
- self._ulonglong_byref(aParts),
1314
+ QrackSimulator._ulonglong_byref(aParts),
1300
1315
  len(q),
1301
- self._ulonglong_byref(q),
1302
- self._ulonglong_byref(o),
1316
+ QrackSimulator._ulonglong_byref(q),
1317
+ QrackSimulator._ulonglong_byref(o),
1303
1318
  )
1304
1319
  self._throw_if_error()
1305
1320
 
@@ -1331,14 +1346,14 @@ class QrackSimulator:
1331
1346
 
1332
1347
  if len(q) != len(o):
1333
1348
  raise RuntimeError("Lengths of list parameters are mismatched.")
1334
- aParts = self._split_longs(a)
1349
+ aParts = QrackSimulator._split_longs(a)
1335
1350
  Qrack.qrack_lib.DIV(
1336
1351
  self.sid,
1337
1352
  len(aParts),
1338
- self._ulonglong_byref(aParts),
1353
+ QrackSimulator._ulonglong_byref(aParts),
1339
1354
  len(q),
1340
- self._ulonglong_byref(q),
1341
- self._ulonglong_byref(o),
1355
+ QrackSimulator._ulonglong_byref(q),
1356
+ QrackSimulator._ulonglong_byref(o),
1342
1357
  )
1343
1358
  self._throw_if_error()
1344
1359
 
@@ -1359,15 +1374,15 @@ class QrackSimulator:
1359
1374
  """
1360
1375
  if len(q) != len(o):
1361
1376
  raise RuntimeError("Lengths of list parameters are mismatched.")
1362
- aParts, mParts = self._split_longs_2(a, m)
1377
+ aParts, mParts = QrackSimulator._split_longs_2(a, m)
1363
1378
  Qrack.qrack_lib.MULN(
1364
1379
  self.sid,
1365
1380
  len(aParts),
1366
- self._ulonglong_byref(aParts),
1367
- self._ulonglong_byref(mParts),
1381
+ QrackSimulator._ulonglong_byref(aParts),
1382
+ QrackSimulator._ulonglong_byref(mParts),
1368
1383
  len(q),
1369
- self._ulonglong_byref(q),
1370
- self._ulonglong_byref(o),
1384
+ QrackSimulator._ulonglong_byref(q),
1385
+ QrackSimulator._ulonglong_byref(o),
1371
1386
  )
1372
1387
  self._throw_if_error()
1373
1388
 
@@ -1389,15 +1404,15 @@ class QrackSimulator:
1389
1404
  """
1390
1405
  if len(q) != len(o):
1391
1406
  raise RuntimeError("Lengths of list parameters are mismatched.")
1392
- aParts, mParts = self._split_longs_2(a, m)
1407
+ aParts, mParts = QrackSimulator._split_longs_2(a, m)
1393
1408
  Qrack.qrack_lib.DIVN(
1394
1409
  self.sid,
1395
1410
  len(aParts),
1396
- self._ulonglong_byref(aParts),
1397
- self._ulonglong_byref(mParts),
1411
+ QrackSimulator._ulonglong_byref(aParts),
1412
+ QrackSimulator._ulonglong_byref(mParts),
1398
1413
  len(q),
1399
- self._ulonglong_byref(q),
1400
- self._ulonglong_byref(o),
1414
+ QrackSimulator._ulonglong_byref(q),
1415
+ QrackSimulator._ulonglong_byref(o),
1401
1416
  )
1402
1417
  self._throw_if_error()
1403
1418
 
@@ -1428,15 +1443,15 @@ class QrackSimulator:
1428
1443
 
1429
1444
  if len(q) != len(o):
1430
1445
  raise RuntimeError("Lengths of list parameters are mismatched.")
1431
- aParts, mParts = self._split_longs_2(a, m)
1446
+ aParts, mParts = QrackSimulator._split_longs_2(a, m)
1432
1447
  Qrack.qrack_lib.POWN(
1433
1448
  self.sid,
1434
1449
  len(aParts),
1435
- self._ulonglong_byref(aParts),
1436
- self._ulonglong_byref(mParts),
1450
+ QrackSimulator._ulonglong_byref(aParts),
1451
+ QrackSimulator._ulonglong_byref(mParts),
1437
1452
  len(q),
1438
- self._ulonglong_byref(q),
1439
- self._ulonglong_byref(o),
1453
+ QrackSimulator._ulonglong_byref(q),
1454
+ QrackSimulator._ulonglong_byref(o),
1440
1455
  )
1441
1456
  self._throw_if_error()
1442
1457
 
@@ -1454,15 +1469,15 @@ class QrackSimulator:
1454
1469
  Raises:
1455
1470
  RuntimeError: QrackSimulator raised an exception.
1456
1471
  """
1457
- aParts = self._split_longs(a)
1472
+ aParts = QrackSimulator._split_longs(a)
1458
1473
  Qrack.qrack_lib.MCADD(
1459
1474
  self.sid,
1460
1475
  len(aParts),
1461
- self._ulonglong_byref(aParts),
1476
+ QrackSimulator._ulonglong_byref(aParts),
1462
1477
  len(c),
1463
- self._ulonglong_byref(c),
1478
+ QrackSimulator._ulonglong_byref(c),
1464
1479
  len(q),
1465
- self._ulonglong_byref(q),
1480
+ QrackSimulator._ulonglong_byref(q),
1466
1481
  )
1467
1482
  self._throw_if_error()
1468
1483
 
@@ -1480,15 +1495,15 @@ class QrackSimulator:
1480
1495
  Raises:
1481
1496
  RuntimeError: QrackSimulator raised an exception.
1482
1497
  """
1483
- aParts = self._split_longs(a)
1498
+ aParts = QrackSimulator._split_longs(a)
1484
1499
  Qrack.qrack_lib.MCSUB(
1485
1500
  self.sid,
1486
1501
  len(aParts),
1487
- self._ulonglong_byref(aParts),
1502
+ QrackSimulator._ulonglong_byref(aParts),
1488
1503
  len(c),
1489
- self._ulonglong_byref(c),
1504
+ QrackSimulator._ulonglong_byref(c),
1490
1505
  len(q),
1491
- self._ulonglong_byref(q),
1506
+ QrackSimulator._ulonglong_byref(q),
1492
1507
  )
1493
1508
  self._throw_if_error()
1494
1509
 
@@ -1521,15 +1536,15 @@ class QrackSimulator:
1521
1536
 
1522
1537
  if len(q) != len(o):
1523
1538
  raise RuntimeError("Lengths of list parameters are mismatched.")
1524
- aParts = self._split_longs(a)
1539
+ aParts = QrackSimulator._split_longs(a)
1525
1540
  Qrack.qrack_lib.MCMUL(
1526
1541
  self.sid,
1527
1542
  len(aParts),
1528
- self._ulonglong_byref(aParts),
1543
+ QrackSimulator._ulonglong_byref(aParts),
1529
1544
  len(c),
1530
- self._ulonglong_byref(c),
1545
+ QrackSimulator._ulonglong_byref(c),
1531
1546
  len(q),
1532
- self._ulonglong_byref(q),
1547
+ QrackSimulator._ulonglong_byref(q),
1533
1548
  )
1534
1549
  self._throw_if_error()
1535
1550
 
@@ -1563,15 +1578,15 @@ class QrackSimulator:
1563
1578
 
1564
1579
  if len(q) != len(o):
1565
1580
  raise RuntimeError("Lengths of list parameters are mismatched.")
1566
- aParts = self._split_longs(a)
1581
+ aParts = QrackSimulator._split_longs(a)
1567
1582
  Qrack.qrack_lib.MCDIV(
1568
1583
  self.sid,
1569
1584
  len(aParts),
1570
- self._ulonglong_byref(aParts),
1585
+ QrackSimulator._ulonglong_byref(aParts),
1571
1586
  len(c),
1572
- self._ulonglong_byref(c),
1587
+ QrackSimulator._ulonglong_byref(c),
1573
1588
  len(q),
1574
- self._ulonglong_byref(q),
1589
+ QrackSimulator._ulonglong_byref(q),
1575
1590
  )
1576
1591
  self._throw_if_error()
1577
1592
 
@@ -1594,17 +1609,17 @@ class QrackSimulator:
1594
1609
  """
1595
1610
  if len(q) != len(o):
1596
1611
  raise RuntimeError("Lengths of list parameters are mismatched.")
1597
- aParts, mParts = self._split_longs_2(a, m)
1612
+ aParts, mParts = QrackSimulator._split_longs_2(a, m)
1598
1613
  Qrack.qrack_lib.MCMULN(
1599
1614
  self.sid,
1600
1615
  len(aParts),
1601
- self._ulonglong_byref(aParts),
1616
+ QrackSimulator._ulonglong_byref(aParts),
1602
1617
  len(c),
1603
- self._ulonglong_byref(c),
1604
- self._ulonglong_byref(mParts),
1618
+ QrackSimulator._ulonglong_byref(c),
1619
+ QrackSimulator._ulonglong_byref(mParts),
1605
1620
  len(q),
1606
- self._ulonglong_byref(q),
1607
- self._ulonglong_byref(o),
1621
+ QrackSimulator._ulonglong_byref(q),
1622
+ QrackSimulator._ulonglong_byref(o),
1608
1623
  )
1609
1624
  self._throw_if_error()
1610
1625
 
@@ -1628,17 +1643,17 @@ class QrackSimulator:
1628
1643
  """
1629
1644
  if len(q) != len(o):
1630
1645
  raise RuntimeError("Lengths of list parameters are mismatched.")
1631
- aParts, mParts = self._split_longs_2(a, m)
1646
+ aParts, mParts = QrackSimulator._split_longs_2(a, m)
1632
1647
  Qrack.qrack_lib.MCDIVN(
1633
1648
  self.sid,
1634
1649
  len(aParts),
1635
- self._ulonglong_byref(aParts),
1650
+ QrackSimulator._ulonglong_byref(aParts),
1636
1651
  len(c),
1637
- self._ulonglong_byref(c),
1638
- self._ulonglong_byref(mParts),
1652
+ QrackSimulator._ulonglong_byref(c),
1653
+ QrackSimulator._ulonglong_byref(mParts),
1639
1654
  len(q),
1640
- self._ulonglong_byref(q),
1641
- self._ulonglong_byref(o),
1655
+ QrackSimulator._ulonglong_byref(q),
1656
+ QrackSimulator._ulonglong_byref(o),
1642
1657
  )
1643
1658
  self._throw_if_error()
1644
1659
 
@@ -1671,17 +1686,17 @@ class QrackSimulator:
1671
1686
 
1672
1687
  if len(q) != len(o):
1673
1688
  raise RuntimeError("Lengths of list parameters are mismatched.")
1674
- aParts, mParts = self._split_longs_2(a, m)
1689
+ aParts, mParts = QrackSimulator._split_longs_2(a, m)
1675
1690
  Qrack.qrack_lib.MCPOWN(
1676
1691
  self.sid,
1677
1692
  len(aParts),
1678
- self._ulonglong_byref(aParts),
1693
+ QrackSimulator._ulonglong_byref(aParts),
1679
1694
  len(c),
1680
- self._ulonglong_byref(c),
1681
- self._ulonglong_byref(mParts),
1695
+ QrackSimulator._ulonglong_byref(c),
1696
+ QrackSimulator._ulonglong_byref(mParts),
1682
1697
  len(q),
1683
- self._ulonglong_byref(q),
1684
- self._ulonglong_byref(o),
1698
+ QrackSimulator._ulonglong_byref(q),
1699
+ QrackSimulator._ulonglong_byref(o),
1685
1700
  )
1686
1701
  self._throw_if_error()
1687
1702
 
@@ -1713,10 +1728,10 @@ class QrackSimulator:
1713
1728
  Qrack.qrack_lib.LDA(
1714
1729
  self.sid,
1715
1730
  len(qi),
1716
- self._ulonglong_byref(qi),
1731
+ QrackSimulator._ulonglong_byref(qi),
1717
1732
  len(qv),
1718
- self._ulonglong_byref(qv),
1719
- self._to_ubyte(len(qv), t),
1733
+ QrackSimulator._ulonglong_byref(qv),
1734
+ QrackSimulator._to_ubyte(len(qv), t),
1720
1735
  )
1721
1736
  self._throw_if_error()
1722
1737
 
@@ -1748,10 +1763,10 @@ class QrackSimulator:
1748
1763
  self.sid,
1749
1764
  s,
1750
1765
  len(qi),
1751
- self._ulonglong_byref(qi),
1766
+ QrackSimulator._ulonglong_byref(qi),
1752
1767
  len(qv),
1753
- self._ulonglong_byref(qv),
1754
- self._to_ubyte(len(qv), t),
1768
+ QrackSimulator._ulonglong_byref(qv),
1769
+ QrackSimulator._to_ubyte(len(qv), t),
1755
1770
  )
1756
1771
  self._throw_if_error()
1757
1772
 
@@ -1783,10 +1798,10 @@ class QrackSimulator:
1783
1798
  self.sid,
1784
1799
  s,
1785
1800
  len(qi),
1786
- self._ulonglong_byref(qi),
1801
+ QrackSimulator._ulonglong_byref(qi),
1787
1802
  len(qv),
1788
- self._ulonglong_byref(qv),
1789
- self._to_ubyte(len(qv), t),
1803
+ QrackSimulator._ulonglong_byref(qv),
1804
+ QrackSimulator._to_ubyte(len(qv), t),
1790
1805
  )
1791
1806
  self._throw_if_error()
1792
1807
 
@@ -1816,7 +1831,7 @@ class QrackSimulator:
1816
1831
  )
1817
1832
 
1818
1833
  Qrack.qrack_lib.Hash(
1819
- self.sid, len(q), self._ulonglong_byref(q), self._to_ubyte(len(q), t)
1834
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._to_ubyte(len(q), t)
1820
1835
  )
1821
1836
  self._throw_if_error()
1822
1837
 
@@ -2037,7 +2052,7 @@ class QrackSimulator:
2037
2052
  Raises:
2038
2053
  RuntimeError: QrackSimulator raised an exception.
2039
2054
  """
2040
- Qrack.qrack_lib.QFT(self.sid, len(qs), self._ulonglong_byref(qs))
2055
+ Qrack.qrack_lib.QFT(self.sid, len(qs), QrackSimulator._ulonglong_byref(qs))
2041
2056
  self._throw_if_error()
2042
2057
 
2043
2058
  def iqft(self, qs):
@@ -2052,7 +2067,7 @@ class QrackSimulator:
2052
2067
  Raises:
2053
2068
  RuntimeError: QrackSimulator raised an exception.
2054
2069
  """
2055
- Qrack.qrack_lib.IQFT(self.sid, len(qs), self._ulonglong_byref(qs))
2070
+ Qrack.qrack_lib.IQFT(self.sid, len(qs), QrackSimulator._ulonglong_byref(qs))
2056
2071
  self._throw_if_error()
2057
2072
 
2058
2073
  # pseudo-quantum
@@ -2126,7 +2141,7 @@ class QrackSimulator:
2126
2141
  "QrackSimulator with isTensorNetwork=True option cannot compose()! (Turn off just this option, in the constructor.)"
2127
2142
  )
2128
2143
 
2129
- Qrack.qrack_lib.Compose(self.sid, other.sid, self._ulonglong_byref(q))
2144
+ Qrack.qrack_lib.Compose(self.sid, other.sid, QrackSimulator._ulonglong_byref(q))
2130
2145
  self._throw_if_error()
2131
2146
 
2132
2147
  def decompose(self, q):
@@ -2152,7 +2167,7 @@ class QrackSimulator:
2152
2167
  other = QrackSimulator()
2153
2168
  Qrack.qrack_lib.destroy(other.sid)
2154
2169
  l = len(q)
2155
- other.sid = Qrack.qrack_lib.Decompose(self.sid, l, self._ulonglong_byref(q))
2170
+ other.sid = Qrack.qrack_lib.Decompose(self.sid, l, QrackSimulator._ulonglong_byref(q))
2156
2171
  self._throw_if_error()
2157
2172
  return other
2158
2173
 
@@ -2175,7 +2190,7 @@ class QrackSimulator:
2175
2190
  )
2176
2191
 
2177
2192
  l = len(q)
2178
- Qrack.qrack_lib.Dispose(self.sid, l, self._ulonglong_byref(q))
2193
+ Qrack.qrack_lib.Dispose(self.sid, l, QrackSimulator._ulonglong_byref(q))
2179
2194
  self._throw_if_error()
2180
2195
 
2181
2196
  ## miscellaneous
@@ -2245,7 +2260,7 @@ class QrackSimulator:
2245
2260
  Raises:
2246
2261
  RuntimeError: QrackSimulator raised an exception.
2247
2262
  """
2248
- Qrack.qrack_lib.InKet(self.sid, self._qrack_complex_byref(ket))
2263
+ Qrack.qrack_lib.InKet(self.sid, QrackSimulator._qrack_complex_byref(ket))
2249
2264
  self._throw_if_error()
2250
2265
 
2251
2266
  def out_ket(self):
@@ -2262,10 +2277,10 @@ class QrackSimulator:
2262
2277
  list representing the state vector.
2263
2278
  """
2264
2279
  amp_count = 1 << self.num_qubits()
2265
- ket = self._qrack_complex_byref([complex(0, 0)] * amp_count)
2280
+ ket = QrackSimulator._qrack_complex_byref([complex(0, 0)] * amp_count)
2266
2281
  Qrack.qrack_lib.OutKet(self.sid, ket)
2267
2282
  self._throw_if_error()
2268
- return [complex(r, i) for r, i in self._pairwise(ket)]
2283
+ return [complex(r, i) for r, i in QrackSimulator._pairwise(ket)]
2269
2284
 
2270
2285
  def out_probs(self):
2271
2286
  """Get basis dimension probabilities
@@ -2280,7 +2295,7 @@ class QrackSimulator:
2280
2295
  list representing the basis dimension probabilities.
2281
2296
  """
2282
2297
  prob_count = 1 << self.num_qubits()
2283
- probs = self._real1_byref([0.0] * prob_count)
2298
+ probs = QrackSimulator._real1_byref([0.0] * prob_count)
2284
2299
  Qrack.qrack_lib.OutProbs(self.sid, probs)
2285
2300
  self._throw_if_error()
2286
2301
  return list(probs)
@@ -2300,10 +2315,10 @@ class QrackSimulator:
2300
2315
  """
2301
2316
  amp_count = 1 << len(q)
2302
2317
  sqr_amp_count = amp_count * amp_count
2303
- flat_rdm = self._qrack_complex_byref([complex(0, 0)] * sqr_amp_count)
2304
- Qrack.qrack_lib.OutReducedDensityMatrix(self.sid, len(q), self._ulonglong_byref(q), flat_rdm)
2318
+ flat_rdm = QrackSimulator._qrack_complex_byref([complex(0, 0)] * sqr_amp_count)
2319
+ Qrack.qrack_lib.OutReducedDensityMatrix(self.sid, len(q), QrackSimulator._ulonglong_byref(q), flat_rdm)
2305
2320
  self._throw_if_error()
2306
- return [complex(r, i) for r, i in self._pairwise(flat_rdm)]
2321
+ return [complex(r, i) for r, i in QrackSimulator._pairwise(flat_rdm)]
2307
2322
 
2308
2323
  def highest_prob_perm(self):
2309
2324
  """Get the permutation (bit string) with the highest probability
@@ -2365,8 +2380,8 @@ class QrackSimulator:
2365
2380
  Returns:
2366
2381
  list representing the state vector.
2367
2382
  """
2368
- probs = self._real1_byref([0.0] * (1 << len(q)))
2369
- Qrack.qrack_lib.ProbAll(self.sid, len(q), self._ulonglong_byref(q), probs)
2383
+ probs = QrackSimulator._real1_byref([0.0] * (1 << len(q)))
2384
+ Qrack.qrack_lib.ProbAll(self.sid, len(q), QrackSimulator._ulonglong_byref(q), probs)
2370
2385
  self._throw_if_error()
2371
2386
  return list(probs)
2372
2387
 
@@ -2428,7 +2443,7 @@ class QrackSimulator:
2428
2443
  if len(q) != len(c):
2429
2444
  raise RuntimeError("prob_perm argument lengths do not match.")
2430
2445
  result = Qrack.qrack_lib.PermutationProb(
2431
- self.sid, len(q), self._ulonglong_byref(q), self._bool_byref(c)
2446
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._bool_byref(c)
2432
2447
  )
2433
2448
  self._throw_if_error()
2434
2449
  return result
@@ -2456,7 +2471,7 @@ class QrackSimulator:
2456
2471
  if len(q) != len(c):
2457
2472
  raise RuntimeError("prob_perm argument lengths do not match.")
2458
2473
  result = Qrack.qrack_lib.PermutationProbRdm(
2459
- self.sid, len(q), self._ulonglong_byref(q), self._bool_byref(c), r
2474
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._bool_byref(c), r
2460
2475
  )
2461
2476
  self._throw_if_error()
2462
2477
  return result
@@ -2477,7 +2492,7 @@ class QrackSimulator:
2477
2492
  Expectation value
2478
2493
  """
2479
2494
  result = Qrack.qrack_lib.PermutationExpectation(
2480
- self.sid, len(q), self._ulonglong_byref(q)
2495
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q)
2481
2496
  )
2482
2497
  self._throw_if_error()
2483
2498
  return result
@@ -2500,7 +2515,7 @@ class QrackSimulator:
2500
2515
  Expectation value
2501
2516
  """
2502
2517
  result = Qrack.qrack_lib.PermutationExpectationRdm(
2503
- self.sid, len(q), self._ulonglong_byref(q), r
2518
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), r
2504
2519
  )
2505
2520
  self._throw_if_error()
2506
2521
  return result
@@ -2526,7 +2541,7 @@ class QrackSimulator:
2526
2541
  raise RuntimeError("factorized_expectation argument lengths do not match.")
2527
2542
  m = max([(x.bit_length() + 63) // 64 for x in c])
2528
2543
  result = Qrack.qrack_lib.FactorizedExpectation(
2529
- self.sid, len(q), self._ulonglong_byref(q), m, self._to_ulonglong(m, c)
2544
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), m, QrackSimulator._to_ulonglong(m, c)
2530
2545
  )
2531
2546
  self._throw_if_error()
2532
2547
  return result
@@ -2556,7 +2571,7 @@ class QrackSimulator:
2556
2571
  )
2557
2572
  m = max([(x.bit_length() + 63) // 64 for x in c])
2558
2573
  result = Qrack.qrack_lib.FactorizedExpectationRdm(
2559
- self.sid, len(q), self._ulonglong_byref(q), m, self._to_ulonglong(m, c), r
2574
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), m, QrackSimulator._to_ulonglong(m, c), r
2560
2575
  )
2561
2576
  self._throw_if_error()
2562
2577
  return result
@@ -2583,7 +2598,7 @@ class QrackSimulator:
2583
2598
  "factorized_expectation_rdm argument lengths do not match."
2584
2599
  )
2585
2600
  result = Qrack.qrack_lib.FactorizedExpectationFp(
2586
- self.sid, len(q), self._ulonglong_byref(q), self._real1_byref(c)
2601
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._real1_byref(c)
2587
2602
  )
2588
2603
  self._throw_if_error()
2589
2604
  return result
@@ -2612,7 +2627,7 @@ class QrackSimulator:
2612
2627
  "factorized_expectation_fp_rdm argument lengths do not match."
2613
2628
  )
2614
2629
  result = Qrack.qrack_lib.FactorizedExpectationFpRdm(
2615
- self.sid, len(q), self._ulonglong_byref(q), self._real1_byref(c), r
2630
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._real1_byref(c), r
2616
2631
  )
2617
2632
  self._throw_if_error()
2618
2633
  return result
@@ -2636,7 +2651,7 @@ class QrackSimulator:
2636
2651
  if (3 * len(q)) != len(b):
2637
2652
  raise RuntimeError("unitary_expectation argument lengths do not match.")
2638
2653
  result = Qrack.qrack_lib.UnitaryExpectation(
2639
- self.sid, len(q), self._ulonglong_byref(q), self._real1_byref(b)
2654
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._real1_byref(b)
2640
2655
  )
2641
2656
  self._throw_if_error()
2642
2657
  return result
@@ -2660,7 +2675,7 @@ class QrackSimulator:
2660
2675
  if (len(q) << 2) != len(b):
2661
2676
  raise RuntimeError("matrix_expectation argument lengths do not match.")
2662
2677
  result = Qrack.qrack_lib.MatrixExpectation(
2663
- self.sid, len(q), self._ulonglong_byref(q), self._complex_byref(b)
2678
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._complex_byref(b)
2664
2679
  )
2665
2680
  self._throw_if_error()
2666
2681
  return result
@@ -2692,9 +2707,9 @@ class QrackSimulator:
2692
2707
  result = Qrack.qrack_lib.UnitaryExpectationEigenVal(
2693
2708
  self.sid,
2694
2709
  len(q),
2695
- self._ulonglong_byref(q),
2696
- self._real1_byref(b),
2697
- self._real1_byref(e),
2710
+ QrackSimulator._ulonglong_byref(q),
2711
+ QrackSimulator._real1_byref(b),
2712
+ QrackSimulator._real1_byref(e),
2698
2713
  )
2699
2714
  self._throw_if_error()
2700
2715
  return result
@@ -2726,9 +2741,9 @@ class QrackSimulator:
2726
2741
  result = Qrack.qrack_lib.MatrixExpectationEigenVal(
2727
2742
  self.sid,
2728
2743
  len(q),
2729
- self._ulonglong_byref(q),
2730
- self._complex_byref(b),
2731
- self._real1_byref(e),
2744
+ QrackSimulator._ulonglong_byref(q),
2745
+ QrackSimulator._complex_byref(b),
2746
+ QrackSimulator._real1_byref(e),
2732
2747
  )
2733
2748
  self._throw_if_error()
2734
2749
  return result
@@ -2753,7 +2768,7 @@ class QrackSimulator:
2753
2768
  if len(q) != len(b):
2754
2769
  raise RuntimeError("pauli_expectation argument lengths do not match.")
2755
2770
  result = Qrack.qrack_lib.PauliExpectation(
2756
- self.sid, len(q), self._ulonglong_byref(q), self._ulonglong_byref(b)
2771
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._ulonglong_byref(b)
2757
2772
  )
2758
2773
  self._throw_if_error()
2759
2774
  return result
@@ -2773,7 +2788,7 @@ class QrackSimulator:
2773
2788
  Returns:
2774
2789
  float variance
2775
2790
  """
2776
- result = Qrack.qrack_lib.Variance(self.sid, len(q), self._ulonglong_byref(q))
2791
+ result = Qrack.qrack_lib.Variance(self.sid, len(q), QrackSimulator._ulonglong_byref(q))
2777
2792
  self._throw_if_error()
2778
2793
  return result
2779
2794
 
@@ -2795,7 +2810,7 @@ class QrackSimulator:
2795
2810
  variance
2796
2811
  """
2797
2812
  result = Qrack.qrack_lib.VarianceRdm(
2798
- self.sid, len(q), self._ulonglong_byref(q), r
2813
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), r
2799
2814
  )
2800
2815
  self._throw_if_error()
2801
2816
  return result
@@ -2821,7 +2836,7 @@ class QrackSimulator:
2821
2836
  raise RuntimeError("factorized_variance argument lengths do not match.")
2822
2837
  m = max([(x.bit_length() + 63) // 64 for x in c])
2823
2838
  result = Qrack.qrack_lib.FactorizedVariance(
2824
- self.sid, len(q), self._ulonglong_byref(q), m, self._to_ulonglong(m, c)
2839
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), m, QrackSimulator._to_ulonglong(m, c)
2825
2840
  )
2826
2841
  self._throw_if_error()
2827
2842
  return result
@@ -2849,7 +2864,7 @@ class QrackSimulator:
2849
2864
  raise RuntimeError("factorized_variance_rdm argument lengths do not match.")
2850
2865
  m = max([(x.bit_length() + 63) // 64 for x in c])
2851
2866
  result = Qrack.qrack_lib.FactorizedVarianceRdm(
2852
- self.sid, len(q), self._ulonglong_byref(q), m, self._to_ulonglong(m, c), r
2867
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), m, QrackSimulator._to_ulonglong(m, c), r
2853
2868
  )
2854
2869
  self._throw_if_error()
2855
2870
  return result
@@ -2874,7 +2889,7 @@ class QrackSimulator:
2874
2889
  if (len(q) << 1) != len(c):
2875
2890
  raise RuntimeError("factorized_variance_rdm argument lengths do not match.")
2876
2891
  result = Qrack.qrack_lib.FactorizedVarianceFp(
2877
- self.sid, len(q), self._ulonglong_byref(q), self._real1_byref(c)
2892
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._real1_byref(c)
2878
2893
  )
2879
2894
  self._throw_if_error()
2880
2895
  return result
@@ -2903,7 +2918,7 @@ class QrackSimulator:
2903
2918
  "factorized_variance_fp_rdm argument lengths do not match."
2904
2919
  )
2905
2920
  result = Qrack.qrack_lib.FactorizedVarianceFpRdm(
2906
- self.sid, len(q), self._ulonglong_byref(q), self._real1_byref(c), r
2921
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._real1_byref(c), r
2907
2922
  )
2908
2923
  self._throw_if_error()
2909
2924
  return result
@@ -2927,7 +2942,7 @@ class QrackSimulator:
2927
2942
  if (3 * len(q)) != len(b):
2928
2943
  raise RuntimeError("unitary_variance argument lengths do not match.")
2929
2944
  result = Qrack.qrack_lib.UnitaryVariance(
2930
- self.sid, len(q), self._ulonglong_byref(q), self._real1_byref(b)
2945
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._real1_byref(b)
2931
2946
  )
2932
2947
  self._throw_if_error()
2933
2948
  return result
@@ -2951,7 +2966,7 @@ class QrackSimulator:
2951
2966
  if (len(q) << 2) != len(b):
2952
2967
  raise RuntimeError("matrix_variance argument lengths do not match.")
2953
2968
  result = Qrack.qrack_lib.MatrixVariance(
2954
- self.sid, len(q), self._ulonglong_byref(q), self._complex_byref(b)
2969
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._complex_byref(b)
2955
2970
  )
2956
2971
  self._throw_if_error()
2957
2972
  return result
@@ -2983,9 +2998,9 @@ class QrackSimulator:
2983
2998
  result = Qrack.qrack_lib.UnitaryVarianceEigenVal(
2984
2999
  self.sid,
2985
3000
  len(q),
2986
- self._ulonglong_byref(q),
2987
- self._real1_byref(b),
2988
- self._real1_byref(e),
3001
+ QrackSimulator._ulonglong_byref(q),
3002
+ QrackSimulator._real1_byref(b),
3003
+ QrackSimulator._real1_byref(e),
2989
3004
  )
2990
3005
  self._throw_if_error()
2991
3006
  return result
@@ -3017,9 +3032,9 @@ class QrackSimulator:
3017
3032
  result = Qrack.qrack_lib.MatrixVarianceEigenVal(
3018
3033
  self.sid,
3019
3034
  len(q),
3020
- self._ulonglong_byref(q),
3021
- self._complex_byref(b),
3022
- self._real1_byref(e),
3035
+ QrackSimulator._ulonglong_byref(q),
3036
+ QrackSimulator._complex_byref(b),
3037
+ QrackSimulator._real1_byref(e),
3023
3038
  )
3024
3039
  self._throw_if_error()
3025
3040
  return result
@@ -3044,7 +3059,7 @@ class QrackSimulator:
3044
3059
  if len(q) != len(b):
3045
3060
  raise RuntimeError("pauli_variance argument lengths do not match.")
3046
3061
  result = Qrack.qrack_lib.PauliVariance(
3047
- self.sid, len(q), self._ulonglong_byref(q), self._ulonglong_byref(b)
3062
+ self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._ulonglong_byref(b)
3048
3063
  )
3049
3064
  self._throw_if_error()
3050
3065
  return result
@@ -3068,7 +3083,7 @@ class QrackSimulator:
3068
3083
  if len(b) != len(q):
3069
3084
  raise RuntimeError("Lengths of list parameters are mismatched.")
3070
3085
  result = Qrack.qrack_lib.JointEnsembleProbability(
3071
- self.sid, len(b), self._ulonglong_byref(b), q
3086
+ self.sid, len(b), QrackSimulator._ulonglong_byref(b), q
3072
3087
  )
3073
3088
  self._throw_if_error()
3074
3089
  return result
@@ -3097,7 +3112,7 @@ class QrackSimulator:
3097
3112
  )
3098
3113
 
3099
3114
  Qrack.qrack_lib.PhaseParity(
3100
- self.sid, ctypes.c_double(la), len(q), self._ulonglong_byref(q)
3115
+ self.sid, ctypes.c_double(la), len(q), QrackSimulator._ulonglong_byref(q)
3101
3116
  )
3102
3117
  self._throw_if_error()
3103
3118
 
@@ -3123,7 +3138,7 @@ class QrackSimulator:
3123
3138
  "QrackStabilizer cannot phase_root_n()! (Create a QrackSimulator instead, also with isTensorNetwork=False.)"
3124
3139
  )
3125
3140
 
3126
- Qrack.qrack_lib.PhaseRootN(self.sid, n, len(q), self._ulonglong_byref(q))
3141
+ Qrack.qrack_lib.PhaseRootN(self.sid, n, len(q), QrackSimulator._ulonglong_byref(q))
3127
3142
  self._throw_if_error()
3128
3143
 
3129
3144
  def try_separate_1qb(self, qi1):
@@ -3180,7 +3195,7 @@ class QrackSimulator:
3180
3195
  State of all the qubits.
3181
3196
  """
3182
3197
  result = Qrack.qrack_lib.TrySeparateTol(
3183
- self.sid, len(qs), self._ulonglong_byref(qs), t
3198
+ self.sid, len(qs), QrackSimulator._ulonglong_byref(qs), t
3184
3199
  )
3185
3200
  self._throw_if_error()
3186
3201
  return result
@@ -3196,7 +3211,7 @@ class QrackSimulator:
3196
3211
  Raises:
3197
3212
  Runtimeerror: QrackSimulator raised an exception.
3198
3213
  """
3199
- result = Qrack.qrack_lib.Separate(self.sid, len(qs), self._ulonglong_byref(qs))
3214
+ result = Qrack.qrack_lib.Separate(self.sid, len(qs), QrackSimulator._ulonglong_byref(qs))
3200
3215
  self._throw_if_error()
3201
3216
 
3202
3217
  def get_unitary_fidelity(self):
@@ -3320,6 +3335,41 @@ class QrackSimulator:
3320
3335
  Qrack.qrack_lib.SetNoiseParameter(self.sid, np)
3321
3336
  self._throw_if_error()
3322
3337
 
3338
+ def set_ace_max_qb(self, qb):
3339
+ """Set "automatic circuit elision" (ACE) max qubits
3340
+
3341
+ If isSchmidtDecompose=True, maximum entangled subsytem size
3342
+ of this simulator will be capped to 'qb', and entangling
3343
+ gates that would exceed that size are replaced with gate
3344
+ shadows.
3345
+
3346
+ Args:
3347
+ qb: maximum subsystem qubits
3348
+
3349
+ Raises:
3350
+ RuntimeError: QrackSimulator raised an exception.
3351
+ """
3352
+ Qrack.qrack_lib.SetAceMaxQb(self.sid, qb)
3353
+ self._throw_if_error()
3354
+
3355
+ def set_sparse_ace_max_mb(self, mb):
3356
+ """Set sparse "automatic circuit elision" (ACE) max memory
3357
+
3358
+ If isSchmidtDecompose=True, isSparse=True, and
3359
+ isOpenCL=False, maximum subsytem size memory MB of this
3360
+ simulator will be capped to 'mb', and entangling gates
3361
+ that would exceed that size are replaced with gate
3362
+ shadows.
3363
+
3364
+ Args:
3365
+ mb: maximum subsystem memory in MB
3366
+
3367
+ Raises:
3368
+ RuntimeError: QrackSimulator raised an exception.
3369
+ """
3370
+ Qrack.qrack_lib.SetSparseAceMaxMb(self.sid, mb)
3371
+ self._throw_if_error()
3372
+
3323
3373
  def normalize(self):
3324
3374
  """Normalize the state
3325
3375
 
@@ -4455,6 +4505,7 @@ class QrackSimulator:
4455
4505
 
4456
4506
  return _data
4457
4507
 
4508
+ @staticmethod
4458
4509
  def get_qiskit_basis_gates():
4459
4510
  return [
4460
4511
  "id",