50#include <unordered_map>
59 GpuLibrary(
const GpuLibrary &) =
delete;
60 GpuLibrary &operator=(
const GpuLibrary &) =
delete;
62 GpuLibrary(GpuLibrary &&) =
default;
63 GpuLibrary &operator=(GpuLibrary &&) =
default;
65 GpuLibrary()
noexcept {}
67 virtual ~GpuLibrary() {
68 if (LibraryHandle) FreeLib();
71 bool Init(
const char *libName)
noexcept override {
76 fValidateLicense = (int (*)(
const char *))GetFunction(
"ValidateLicense");
77 if (!fValidateLicense) {
79 std::cerr <<
"GpuLibrary: License validation symbol not found. "
80 "The GPU library must export ValidateLicense."
84 const char *licenseKey = std::getenv(
"MAESTRO_LICENSE_KEY");
85 int licenseStatus = fValidateLicense(licenseKey);
86 if (licenseStatus != 1) {
88 std::cerr <<
"GpuLibrary: License validation failed. ";
90 std::cerr <<
"Set MAESTRO_LICENSE_KEY environment variable "
91 "or activate the license first."
94 std::cerr <<
"Check that your license key is correct." << std::endl;
99 InitLib = (
void *(*)())GetFunction(
"InitLib");
100 CheckFunction((
void *)InitLib, __LINE__);
102 LibraryHandle = InitLib();
104 FreeLib = (void (*)())GetFunction(
"FreeLib");
105 CheckFunction((
void *)FreeLib, __LINE__);
110 (
void *(*)(
void *))GetFunction(
"CreateStateVector");
111 CheckFunction((
void *)fCreateStateVector, __LINE__);
112 fDestroyStateVector =
113 (void (*)(
void *))GetFunction(
"DestroyStateVector");
114 CheckFunction((
void *)fDestroyStateVector, __LINE__);
116 fCreate = (int (*)(
void *,
unsigned int))GetFunction(
"Create");
117 CheckFunction((
void *)fCreate, __LINE__);
119 (int (*)(
void *,
unsigned int,
const double *))GetFunction(
121 CheckFunction((
void *)fCreateWithState, __LINE__);
122 fReset = (int (*)(
void *))GetFunction(
"Reset");
123 CheckFunction((
void *)fReset, __LINE__);
125 fSetDataType = (int (*)(
void *, int))GetFunction(
"SetDataType");
126 CheckFunction((
void *)fSetDataType, __LINE__);
128 (int (*)(
void *))GetFunction(
"IsDoublePrecision");
129 CheckFunction((
void *)fIsDoublePrecision, __LINE__);
130 fGetNrQubits = (int (*)(
void *))GetFunction(
"GetNrQubits");
131 CheckFunction((
void *)fGetNrQubits, __LINE__);
133 fMeasureQubitCollapse =
134 (int (*)(
void *, int))GetFunction(
"MeasureQubitCollapse");
135 CheckFunction((
void *)fMeasureQubitCollapse, __LINE__);
136 fMeasureQubitNoCollapse =
137 (int (*)(
void *, int))GetFunction(
"MeasureQubitNoCollapse");
138 CheckFunction((
void *)fMeasureQubitNoCollapse, __LINE__);
139 fMeasureQubitsCollapse = (int (*)(
140 void *,
int *,
int *, int))GetFunction(
"MeasureQubitsCollapse");
141 CheckFunction((
void *)fMeasureQubitsCollapse, __LINE__);
142 fMeasureQubitsNoCollapse = (int (*)(
143 void *,
int *,
int *, int))GetFunction(
"MeasureQubitsNoCollapse");
144 CheckFunction((
void *)fMeasureQubitsNoCollapse, __LINE__);
145 fMeasureAllQubitsCollapse = (
unsigned long long (*)(
146 void *))GetFunction(
"MeasureAllQubitsCollapse");
147 CheckFunction((
void *)fMeasureAllQubitsCollapse, __LINE__);
148 fMeasureAllQubitsNoCollapse = (
unsigned long long (*)(
149 void *))GetFunction(
"MeasureAllQubitsNoCollapse");
150 CheckFunction((
void *)fMeasureAllQubitsNoCollapse, __LINE__);
152 fSaveState = (int (*)(
void *))GetFunction(
"SaveState");
153 CheckFunction((
void *)fSaveState, __LINE__);
154 fSaveStateToHost = (int (*)(
void *))GetFunction(
"SaveStateToHost");
155 CheckFunction((
void *)fSaveStateToHost, __LINE__);
156 fSaveStateDestructive =
157 (int (*)(
void *))GetFunction(
"SaveStateDestructive");
158 CheckFunction((
void *)fSaveStateDestructive, __LINE__);
159 fRestoreStateFreeSaved =
160 (int (*)(
void *))GetFunction(
"RestoreStateFreeSaved");
161 CheckFunction((
void *)fRestoreStateFreeSaved, __LINE__);
162 fRestoreStateNoFreeSaved =
163 (int (*)(
void *))GetFunction(
"RestoreStateNoFreeSaved");
164 CheckFunction((
void *)fRestoreStateNoFreeSaved, __LINE__);
165 fFreeSavedState = (void (*)(
void *))GetFunction(
"FreeSavedState");
166 CheckFunction((
void *)fFreeSavedState, __LINE__);
167 fClone = (
void *(*)(
void *))GetFunction(
"Clone");
168 CheckFunction((
void *)fClone, __LINE__);
170 fSample = (int (*)(
void *,
unsigned int,
long int *,
unsigned int,
171 int *))GetFunction(
"Sample");
172 CheckFunction((
void *)fSample, __LINE__);
173 fSampleAll = (int (*)(
void *,
unsigned int,
long int *))GetFunction(
175 CheckFunction((
void *)fSampleAll, __LINE__);
176 fAmplitude = (int (*)(
void *,
long long int,
double *,
177 double *))GetFunction(
"Amplitude");
178 CheckFunction((
void *)fAmplitude, __LINE__);
180 (double (*)(
void *,
int *,
int *, int))GetFunction(
"Probability");
181 CheckFunction((
void *)fProbability, __LINE__);
182 fBasisStateProbability = (double (*)(
183 void *,
long long int))GetFunction(
"BasisStateProbability");
184 CheckFunction((
void *)fBasisStateProbability, __LINE__);
185 fAllProbabilities = (int (*)(
186 void *obj,
double *probabilities))GetFunction(
"AllProbabilities");
187 CheckFunction((
void *)fAllProbabilities, __LINE__);
188 fExpectationValue = (double (*)(
void *,
const char *,
189 int))GetFunction(
"ExpectationValue");
190 CheckFunction((
void *)fExpectationValue, __LINE__);
192 fApplyX = (int (*)(
void *, int))GetFunction(
"ApplyX");
193 CheckFunction((
void *)fApplyX, __LINE__);
194 fApplyY = (int (*)(
void *, int))GetFunction(
"ApplyY");
195 CheckFunction((
void *)fApplyY, __LINE__);
196 fApplyZ = (int (*)(
void *, int))GetFunction(
"ApplyZ");
197 CheckFunction((
void *)fApplyZ, __LINE__);
198 fApplyH = (int (*)(
void *, int))GetFunction(
"ApplyH");
199 CheckFunction((
void *)fApplyH, __LINE__);
200 fApplyS = (int (*)(
void *, int))GetFunction(
"ApplyS");
201 CheckFunction((
void *)fApplyS, __LINE__);
202 fApplySDG = (int (*)(
void *, int))GetFunction(
"ApplySDG");
203 CheckFunction((
void *)fApplySDG, __LINE__);
204 fApplyT = (int (*)(
void *, int))GetFunction(
"ApplyT");
205 CheckFunction((
void *)fApplyT, __LINE__);
206 fApplyTDG = (int (*)(
void *, int))GetFunction(
"ApplyTDG");
207 CheckFunction((
void *)fApplyTDG, __LINE__);
208 fApplySX = (int (*)(
void *, int))GetFunction(
"ApplySX");
209 CheckFunction((
void *)fApplySX, __LINE__);
210 fApplySXDG = (int (*)(
void *, int))GetFunction(
"ApplySXDG");
211 CheckFunction((
void *)fApplySXDG, __LINE__);
212 fApplyK = (int (*)(
void *, int))GetFunction(
"ApplyK");
213 CheckFunction((
void *)fApplyK, __LINE__);
214 fApplyP = (int (*)(
void *, int, double))GetFunction(
"ApplyP");
215 CheckFunction((
void *)fApplyP, __LINE__);
216 fApplyRx = (int (*)(
void *, int, double))GetFunction(
"ApplyRx");
217 CheckFunction((
void *)fApplyRx, __LINE__);
218 fApplyRy = (int (*)(
void *, int, double))GetFunction(
"ApplyRy");
219 CheckFunction((
void *)fApplyRy, __LINE__);
220 fApplyRz = (int (*)(
void *, int, double))GetFunction(
"ApplyRz");
221 CheckFunction((
void *)fApplyRz, __LINE__);
222 fApplyU = (int (*)(
void *, int, double, double, double,
223 double))GetFunction(
"ApplyU");
224 CheckFunction((
void *)fApplyU, __LINE__);
225 fApplyCX = (int (*)(
void *, int, int))GetFunction(
"ApplyCX");
226 CheckFunction((
void *)fApplyCX, __LINE__);
227 fApplyCY = (int (*)(
void *, int, int))GetFunction(
"ApplyCY");
228 CheckFunction((
void *)fApplyCY, __LINE__);
229 fApplyCZ = (int (*)(
void *, int, int))GetFunction(
"ApplyCZ");
230 CheckFunction((
void *)fApplyCZ, __LINE__);
231 fApplyCH = (int (*)(
void *, int, int))GetFunction(
"ApplyCH");
232 CheckFunction((
void *)fApplyCH, __LINE__);
233 fApplyCSX = (int (*)(
void *, int, int))GetFunction(
"ApplyCSX");
234 CheckFunction((
void *)fApplyCSX, __LINE__);
235 fApplyCSXDG = (int (*)(
void *, int, int))GetFunction(
"ApplyCSXDG");
236 CheckFunction((
void *)fApplyCSXDG, __LINE__);
237 fApplyCP = (int (*)(
void *, int, int, double))GetFunction(
"ApplyCP");
238 CheckFunction((
void *)fApplyCP, __LINE__);
240 (int (*)(
void *, int, int, double))GetFunction(
"ApplyCRx");
241 CheckFunction((
void *)fApplyCRx, __LINE__);
243 (int (*)(
void *, int, int, double))GetFunction(
"ApplyCRy");
244 CheckFunction((
void *)fApplyCRy, __LINE__);
246 (int (*)(
void *, int, int, double))GetFunction(
"ApplyCRz");
247 CheckFunction((
void *)fApplyCRz, __LINE__);
248 fApplyCCX = (int (*)(
void *, int, int, int))GetFunction(
"ApplyCCX");
249 CheckFunction((
void *)fApplyCCX, __LINE__);
250 fApplySwap = (int (*)(
void *, int, int))GetFunction(
"ApplySwap");
251 CheckFunction((
void *)fApplySwap, __LINE__);
253 (int (*)(
void *, int, int, int))GetFunction(
"ApplyCSwap");
254 CheckFunction((
void *)fApplyCSwap, __LINE__);
255 fApplyCU = (int (*)(
void *, int, int, double, double, double,
256 double))GetFunction(
"ApplyCU");
257 CheckFunction((
void *)fApplyCU, __LINE__);
261 fCreateMPS = (
void *(*)(
void *))GetFunction(
"CreateMPS");
262 CheckFunction((
void *)fCreateMPS, __LINE__);
263 fDestroyMPS = (void (*)(
void *))GetFunction(
"DestroyMPS");
264 CheckFunction((
void *)fDestroyMPS, __LINE__);
266 fMPSCreate = (int (*)(
void *,
unsigned int))GetFunction(
"MPSCreate");
267 CheckFunction((
void *)fMPSCreate, __LINE__);
268 fMPSReset = (int (*)(
void *))GetFunction(
"MPSReset");
269 CheckFunction((
void *)fMPSReset, __LINE__);
270 fMPSSetInitialQubitsMap =
271 (int (*)(
void *,
const long long int *,
unsigned int))GetFunction(
272 "MPSSetInitialQubitsMap");
273 CheckFunction((
void *)fMPSSetInitialQubitsMap, __LINE__);
274 fMPSSetUseOptimalMeetingPosition = (int (*)(
void *, int))GetFunction(
275 "MPSSetUseOptimalMeetingPosition");
276 CheckFunction((
void *)fMPSSetUseOptimalMeetingPosition, __LINE__);
278 fMPSIsValid = (int (*)(
void *))GetFunction(
"MPSIsValid");
279 CheckFunction((
void *)fMPSIsValid, __LINE__);
280 fMPSIsCreated = (int (*)(
void *))GetFunction(
"MPSIsCreated");
281 CheckFunction((
void *)fMPSIsCreated, __LINE__);
283 fMPSSetDataType = (int (*)(
void *, int))GetFunction(
"MPSSetDataType");
284 CheckFunction((
void *)fMPSSetDataType, __LINE__);
285 fMPSIsDoublePrecision =
286 (int (*)(
void *))GetFunction(
"MPSIsDoublePrecision");
287 CheckFunction((
void *)fMPSIsDoublePrecision, __LINE__);
288 fMPSSetCutoff = (int (*)(
void *, double))GetFunction(
"MPSSetCutoff");
289 CheckFunction((
void *)fMPSSetCutoff, __LINE__);
290 fMPSGetCutoff = (double (*)(
void *))GetFunction(
"MPSGetCutoff");
291 CheckFunction((
void *)fMPSGetCutoff, __LINE__);
292 fMPSSetGesvdJ = (int (*)(
void *, int))GetFunction(
"MPSSetGesvdJ");
293 CheckFunction((
void *)fMPSSetGesvdJ, __LINE__);
294 fMPSGetGesvdJ = (int (*)(
void *))GetFunction(
"MPSGetGesvdJ");
295 CheckFunction((
void *)fMPSGetGesvdJ, __LINE__);
297 (int (*)(
void *,
long int))GetFunction(
"MPSSetMaxExtent");
298 CheckFunction((
void *)fMPSSetMaxExtent, __LINE__);
300 (
long int (*)(
void *))GetFunction(
"MPSGetMaxExtent");
301 CheckFunction((
void *)fMPSGetMaxExtent, __LINE__);
302 fMPSGetNrQubits = (int (*)(
void *))GetFunction(
"MPSGetNrQubits");
303 CheckFunction((
void *)fMPSGetNrQubits, __LINE__);
304 fMPSSetCallbackContext =
305 (int (*)(
void *,
void *))GetFunction(
"MPSSetCallbackContext");
306 CheckFunction((
void *)fMPSSetCallbackContext, __LINE__);
308 fMPSSetMeetingPositionCallback =
309 (int (*)(
void *, int64_t (*)(
void *,
const int64_t *)))
310 GetFunction(
"MPSSetMeetingPositionCallback");
311 CheckFunction((
void *)fMPSSetMeetingPositionCallback, __LINE__);
313 fMPSAmplitude = (int (*)(
void *,
long int,
long int *,
double *,
314 double *))GetFunction(
"MPSAmplitude");
315 CheckFunction((
void *)fMPSAmplitude, __LINE__);
317 (double (*)(
void *,
unsigned int))GetFunction(
"MPSProbability0");
318 CheckFunction((
void *)fMPSProbability0, __LINE__);
320 (int (*)(
void *,
unsigned int))GetFunction(
"MPSMeasure");
321 CheckFunction((
void *)fMPSMeasure, __LINE__);
322 fMPSMeasureQubits = (int (*)(
void *,
long int,
unsigned int *,
323 int *))GetFunction(
"MPSMeasureQubits");
324 CheckFunction((
void *)fMPSMeasureQubits, __LINE__);
326 fMPSGetMapForSample = (
void *(*)())GetFunction(
"MPSGetMapForSample");
327 CheckFunction((
void *)fMPSGetMapForSample, __LINE__);
328 fMPSFreeMapForSample =
329 (int (*)(
void *))GetFunction(
"MPSFreeMapForSample");
330 CheckFunction((
void *)fMPSFreeMapForSample, __LINE__);
331 fMPSSample = (int (*)(
void *,
long int,
long int,
unsigned int *,
332 void *))GetFunction(
"MPSSample");
333 CheckFunction((
void *)fMPSSample, __LINE__);
335 fMPSSaveState = (int (*)(
void *))GetFunction(
"MPSSaveState");
336 CheckFunction((
void *)fMPSSaveState, __LINE__);
337 fMPSRestoreState = (int (*)(
void *))GetFunction(
"MPSRestoreState");
338 CheckFunction((
void *)fMPSRestoreState, __LINE__);
339 fMPSCleanSavedState =
340 (int (*)(
void *))GetFunction(
"MPSCleanSavedState");
341 CheckFunction((
void *)fMPSCleanSavedState, __LINE__);
342 fMPSClone = (
void *(*)(
void *))GetFunction(
"MPSClone");
343 CheckFunction((
void *)fMPSClone, __LINE__);
345 fMPSExpectationValue = (double (*)(
346 void *,
const char *, int))GetFunction(
"MPSExpectationValue");
347 CheckFunction((
void *)fMPSExpectationValue, __LINE__);
349 (int (*)(
void *,
double *,
double *))GetFunction(
"MPSProjectOnZero");
350 CheckFunction((
void *)fMPSProjectOnZero, __LINE__);
352 fMPSApplyX = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyX");
353 CheckFunction((
void *)fMPSApplyX, __LINE__);
354 fMPSApplyY = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyY");
355 CheckFunction((
void *)fMPSApplyY, __LINE__);
356 fMPSApplyZ = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyZ");
357 CheckFunction((
void *)fMPSApplyZ, __LINE__);
358 fMPSApplyH = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyH");
359 CheckFunction((
void *)fMPSApplyH, __LINE__);
360 fMPSApplyS = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyS");
361 CheckFunction((
void *)fMPSApplyS, __LINE__);
363 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySDG");
364 CheckFunction((
void *)fMPSApplySDG, __LINE__);
365 fMPSApplyT = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyT");
366 CheckFunction((
void *)fMPSApplyT, __LINE__);
368 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyTDG");
369 CheckFunction((
void *)fMPSApplyTDG, __LINE__);
371 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySX");
372 CheckFunction((
void *)fMPSApplySX, __LINE__);
374 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySXDG");
375 CheckFunction((
void *)fMPSApplySXDG, __LINE__);
376 fMPSApplyK = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyK");
377 CheckFunction((
void *)fMPSApplyK, __LINE__);
379 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyP");
380 CheckFunction((
void *)fMPSApplyP, __LINE__);
382 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRx");
383 CheckFunction((
void *)fMPSApplyRx, __LINE__);
385 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRy");
386 CheckFunction((
void *)fMPSApplyRy, __LINE__);
388 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRz");
389 CheckFunction((
void *)fMPSApplyRz, __LINE__);
390 fMPSApplyU = (int (*)(
void *,
unsigned int, double, double, double,
391 double))GetFunction(
"MPSApplyU");
392 CheckFunction((
void *)fMPSApplyU, __LINE__);
393 fMPSApplySwap = (int (*)(
void *,
unsigned int,
394 unsigned int))GetFunction(
"MPSApplySwap");
395 CheckFunction((
void *)fMPSApplySwap, __LINE__);
396 fMPSApplyCX = (int (*)(
void *,
unsigned int,
397 unsigned int))GetFunction(
"MPSApplyCX");
398 CheckFunction((
void *)fMPSApplyCX, __LINE__);
399 fMPSApplyCY = (int (*)(
void *,
unsigned int,
400 unsigned int))GetFunction(
"MPSApplyCY");
401 CheckFunction((
void *)fMPSApplyCY, __LINE__);
402 fMPSApplyCZ = (int (*)(
void *,
unsigned int,
403 unsigned int))GetFunction(
"MPSApplyCZ");
404 CheckFunction((
void *)fMPSApplyCZ, __LINE__);
405 fMPSApplyCH = (int (*)(
void *,
unsigned int,
406 unsigned int))GetFunction(
"MPSApplyCH");
407 CheckFunction((
void *)fMPSApplyCH, __LINE__);
408 fMPSApplyCSX = (int (*)(
void *,
unsigned int,
409 unsigned int))GetFunction(
"MPSApplyCSX");
410 CheckFunction((
void *)fMPSApplyCSX, __LINE__);
411 fMPSApplyCSXDG = (int (*)(
void *,
unsigned int,
412 unsigned int))GetFunction(
"MPSApplyCSXDG");
413 CheckFunction((
void *)fMPSApplyCSXDG, __LINE__);
414 fMPSApplyCP = (int (*)(
void *,
unsigned int,
unsigned int,
415 double))GetFunction(
"MPSApplyCP");
416 CheckFunction((
void *)fMPSApplyCP, __LINE__);
417 fMPSApplyCRx = (int (*)(
void *,
unsigned int,
unsigned int,
418 double))GetFunction(
"MPSApplyCRx");
419 CheckFunction((
void *)fMPSApplyCRx, __LINE__);
420 fMPSApplyCRy = (int (*)(
void *,
unsigned int,
unsigned int,
421 double))GetFunction(
"MPSApplyCRy");
422 CheckFunction((
void *)fMPSApplyCRy, __LINE__);
423 fMPSApplyCRz = (int (*)(
void *,
unsigned int,
unsigned int,
424 double))GetFunction(
"MPSApplyCRz");
425 CheckFunction((
void *)fMPSApplyCRz, __LINE__);
427 (int (*)(
void *,
unsigned int,
unsigned int, double, double,
428 double, double))GetFunction(
"MPSApplyCU");
429 CheckFunction((
void *)fMPSApplyCU, __LINE__);
433 fCreateTensorNet = (
void *(*)(
void *))GetFunction(
"CreateTensorNet");
434 CheckFunction((
void *)fCreateTensorNet, __LINE__);
435 fDestroyTensorNet = (void (*)(
void *))GetFunction(
"DestroyTensorNet");
436 CheckFunction((
void *)fDestroyTensorNet, __LINE__);
438 fTNCreate = (int (*)(
void *,
unsigned int))GetFunction(
"TNCreate");
439 CheckFunction((
void *)fTNCreate, __LINE__);
440 fTNReset = (int (*)(
void *))GetFunction(
"TNReset");
441 CheckFunction((
void *)fTNReset, __LINE__);
443 fTNIsValid = (int (*)(
void *))GetFunction(
"TNIsValid");
444 CheckFunction((
void *)fTNIsValid, __LINE__);
445 fTNIsCreated = (int (*)(
void *))GetFunction(
"TNIsCreated");
446 CheckFunction((
void *)fTNIsCreated, __LINE__);
448 fTNSetDataType = (int (*)(
void *, int))GetFunction(
"TNSetDataType");
449 CheckFunction((
void *)fTNSetDataType, __LINE__);
450 fTNIsDoublePrecision =
451 (int (*)(
void *))GetFunction(
"TNIsDoublePrecision");
452 CheckFunction((
void *)fTNIsDoublePrecision, __LINE__);
453 fTNSetCutoff = (int (*)(
void *, double))GetFunction(
"TNSetCutoff");
454 CheckFunction((
void *)fTNSetCutoff, __LINE__);
455 fTNGetCutoff = (double (*)(
void *))GetFunction(
"TNGetCutoff");
456 CheckFunction((
void *)fTNGetCutoff, __LINE__);
457 fTNSetGesvdJ = (int (*)(
void *, int))GetFunction(
"TNSetGesvdJ");
458 CheckFunction((
void *)fTNSetGesvdJ, __LINE__);
459 fTNGetGesvdJ = (int (*)(
void *))GetFunction(
"TNGetGesvdJ");
460 CheckFunction((
void *)fTNGetGesvdJ, __LINE__);
462 (int (*)(
void *,
long int))GetFunction(
"TNSetMaxExtent");
463 CheckFunction((
void *)fTNSetMaxExtent, __LINE__);
464 fTNGetMaxExtent = (
long int (*)(
void *))GetFunction(
"TNGetMaxExtent");
465 CheckFunction((
void *)fTNGetMaxExtent, __LINE__);
466 fTNGetNrQubits = (int (*)(
void *))GetFunction(
"TNGetNrQubits");
467 CheckFunction((
void *)fTNGetNrQubits, __LINE__);
468 fTNAmplitude = (int (*)(
void *,
long int,
long int *,
double *,
469 double *))GetFunction(
"TNAmplitude");
470 CheckFunction((
void *)fTNAmplitude, __LINE__);
472 (double (*)(
void *,
unsigned int))GetFunction(
"TNProbability0");
473 CheckFunction((
void *)fTNProbability0, __LINE__);
474 fTNMeasure = (int (*)(
void *,
unsigned int))GetFunction(
"TNMeasure");
475 CheckFunction((
void *)fTNMeasure, __LINE__);
476 fTNMeasureQubits = (int (*)(
void *,
long int,
unsigned int *,
477 int *))GetFunction(
"TNMeasureQubits");
478 CheckFunction((
void *)fTNMeasureQubits, __LINE__);
480 fTNGetMapForSample = (
void *(*)())GetFunction(
"TNGetMapForSample");
481 CheckFunction((
void *)fTNGetMapForSample, __LINE__);
482 fTNFreeMapForSample =
483 (int (*)(
void *))GetFunction(
"TNFreeMapForSample");
484 CheckFunction((
void *)fTNFreeMapForSample, __LINE__);
485 fTNSample = (int (*)(
void *,
long int,
long int,
unsigned int *,
486 void *))GetFunction(
"TNSample");
487 CheckFunction((
void *)fTNSample, __LINE__);
489 fTNSaveState = (int (*)(
void *))GetFunction(
"TNSaveState");
490 CheckFunction((
void *)fTNSaveState, __LINE__);
491 fTNRestoreState = (int (*)(
void *))GetFunction(
"TNRestoreState");
492 CheckFunction((
void *)fTNRestoreState, __LINE__);
494 (int (*)(
void *))GetFunction(
"TNCleanSavedState");
495 CheckFunction((
void *)fTNCleanSavedState, __LINE__);
496 fTNClone = (
void *(*)(
void *))GetFunction(
"TNClone");
497 CheckFunction((
void *)fTNClone, __LINE__);
499 fTNExpectationValue = (double (*)(
500 void *,
const char *, int))GetFunction(
"TNExpectationValue");
501 CheckFunction((
void *)fTNExpectationValue, __LINE__);
503 fTNApplyX = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyX");
504 CheckFunction((
void *)fTNApplyX, __LINE__);
505 fTNApplyY = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyY");
506 CheckFunction((
void *)fTNApplyY, __LINE__);
507 fTNApplyZ = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyZ");
508 CheckFunction((
void *)fTNApplyZ, __LINE__);
509 fTNApplyH = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyH");
510 CheckFunction((
void *)fTNApplyH, __LINE__);
511 fTNApplyS = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyS");
512 CheckFunction((
void *)fTNApplyS, __LINE__);
514 (int (*)(
void *,
unsigned int))GetFunction(
"TNApplySDG");
515 CheckFunction((
void *)fTNApplySDG, __LINE__);
516 fTNApplyT = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyT");
517 CheckFunction((
void *)fTNApplyT, __LINE__);
519 (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyTDG");
520 CheckFunction((
void *)fTNApplyTDG, __LINE__);
521 fTNApplySX = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplySX");
522 CheckFunction((
void *)fTNApplySX, __LINE__);
524 (int (*)(
void *,
unsigned int))GetFunction(
"TNApplySXDG");
525 CheckFunction((
void *)fTNApplySXDG, __LINE__);
526 fTNApplyK = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyK");
527 CheckFunction((
void *)fTNApplyK, __LINE__);
529 (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyP");
530 CheckFunction((
void *)fTNApplyP, __LINE__);
532 (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyRx");
533 CheckFunction((
void *)fTNApplyRx, __LINE__);
535 (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyRy");
536 CheckFunction((
void *)fTNApplyRy, __LINE__);
538 (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyRz");
539 CheckFunction((
void *)fTNApplyRz, __LINE__);
540 fTNApplyU = (int (*)(
void *,
unsigned int, double, double, double,
541 double))GetFunction(
"TNApplyU");
542 CheckFunction((
void *)fTNApplyU, __LINE__);
543 fTNApplySwap = (int (*)(
void *,
unsigned int,
544 unsigned int))GetFunction(
"TNApplySwap");
545 CheckFunction((
void *)fTNApplySwap, __LINE__);
546 fTNApplyCX = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
548 CheckFunction((
void *)fTNApplyCX, __LINE__);
549 fTNApplyCY = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
551 CheckFunction((
void *)fTNApplyCY, __LINE__);
552 fTNApplyCZ = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
554 CheckFunction((
void *)fTNApplyCZ, __LINE__);
555 fTNApplyCH = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
557 CheckFunction((
void *)fTNApplyCH, __LINE__);
558 fTNApplyCSX = (int (*)(
void *,
unsigned int,
559 unsigned int))GetFunction(
"TNApplyCSX");
560 CheckFunction((
void *)fTNApplyCSX, __LINE__);
561 fTNApplyCSXDG = (int (*)(
void *,
unsigned int,
562 unsigned int))GetFunction(
"TNApplyCSXDG");
563 CheckFunction((
void *)fTNApplyCSXDG, __LINE__);
564 fTNApplyCP = (int (*)(
void *,
unsigned int,
unsigned int,
565 double))GetFunction(
"TNApplyCP");
566 CheckFunction((
void *)fTNApplyCP, __LINE__);
567 fTNApplyCRx = (int (*)(
void *,
unsigned int,
unsigned int,
568 double))GetFunction(
"TNApplyCRx");
569 CheckFunction((
void *)fTNApplyCRx, __LINE__);
570 fTNApplyCRy = (int (*)(
void *,
unsigned int,
unsigned int,
571 double))GetFunction(
"TNApplyCRy");
572 CheckFunction((
void *)fTNApplyCRy, __LINE__);
573 fTNApplyCRz = (int (*)(
void *,
unsigned int,
unsigned int,
574 double))GetFunction(
"TNApplyCRz");
575 CheckFunction((
void *)fTNApplyCRz, __LINE__);
577 (int (*)(
void *,
unsigned int,
unsigned int, double, double,
578 double, double))GetFunction(
"TNApplyCU");
579 CheckFunction((
void *)fTNApplyCU, __LINE__);
581 fTNApplyCCX = (int (*)(
void *,
unsigned int,
unsigned int,
582 unsigned int))GetFunction(
"TNApplyCCX");
583 CheckFunction((
void *)fTNApplyCCX, __LINE__);
584 fTNApplyCSwap = (int (*)(
void *,
unsigned int,
unsigned int,
585 unsigned int))GetFunction(
"TNApplyCSwap");
586 CheckFunction((
void *)fTNApplyCSwap, __LINE__);
589 fCreateStabilizerSimulator = (
void *(*)(
long long int,
long long int,
590 long long int,
long long int))
591 GetFunction(
"CreateStabilizerSimulator");
592 CheckFunction((
void *)fCreateStabilizerSimulator, __LINE__);
593 fDestroyStabilizerSimulator =
594 (void (*)(
void *))GetFunction(
"DestroyStabilizerSimulator");
595 CheckFunction((
void *)fDestroyStabilizerSimulator, __LINE__);
596 fExecuteStabilizerCircuit = (int (*)(
597 void *,
const char *, int,
598 unsigned long long int))GetFunction(
"ExecuteStabilizerCircuit");
599 CheckFunction((
void *)fExecuteStabilizerCircuit, __LINE__);
600 fGetStabilizerXZTableSize =
601 (
long long (*)(
void *))GetFunction(
"GetStabilizerXZTableSize");
602 CheckFunction((
void *)fGetStabilizerXZTableSize, __LINE__);
603 fGetStabilizerMTableSize =
604 (
long long (*)(
void *))GetFunction(
"GetStabilizerMTableSize");
605 CheckFunction((
void *)fGetStabilizerMTableSize, __LINE__);
607 fGetStabilizerTableStrideMajor = (
long long (*)(
void *))GetFunction(
608 "GetStabilizerTableStrideMajor");
609 CheckFunction((
void *)fGetStabilizerTableStrideMajor, __LINE__);
611 fGetStabilizerNumQubits =
612 (
long long (*)(
void *))GetFunction(
"GetStabilizerNumQubits");
613 CheckFunction((
void *)fGetStabilizerNumQubits, __LINE__);
614 fGetStabilizerNumShots =
615 (
long long (*)(
void *))GetFunction(
"GetStabilizerNumShots");
616 CheckFunction((
void *)fGetStabilizerNumShots, __LINE__);
617 fGetStabilizerNumMeasurements = (
long long (*)(
void *))GetFunction(
618 "GetStabilizerNumMeasurements");
619 CheckFunction((
void *)fGetStabilizerNumMeasurements, __LINE__);
620 fGetStabilizerNumDetectors =
621 (
long long (*)(
void *))GetFunction(
"GetStabilizerNumDetectors");
622 CheckFunction((
void *)fGetStabilizerNumDetectors, __LINE__);
623 fCopyStabilizerXTable = (int (*)(
void *,
unsigned int *))GetFunction(
624 "CopyStabilizerXTable");
625 CheckFunction((
void *)fCopyStabilizerXTable, __LINE__);
626 fCopyStabilizerZTable = (int (*)(
void *,
unsigned int *))GetFunction(
627 "CopyStabilizerZTable");
628 CheckFunction((
void *)fCopyStabilizerZTable, __LINE__);
629 fCopyStabilizerMTable = (int (*)(
void *,
unsigned int *))GetFunction(
630 "CopyStabilizerMTable");
631 CheckFunction((
void *)fCopyStabilizerMTable, __LINE__);
633 fInitStabilizerXTable =
634 (int (*)(
void *,
const unsigned int *))GetFunction(
"InitXTable");
635 CheckFunction((
void *)fInitStabilizerXTable, __LINE__);
636 fInitStabilizerZTable =
637 (int (*)(
void *,
const unsigned int *))GetFunction(
"InitZTable");
638 CheckFunction((
void *)fInitStabilizerZTable, __LINE__);
641 fCreatePauliPropSimulator =
642 (
void *(*)(
int))GetFunction(
"CreatePauliPropSimulator");
643 CheckFunction((
void *)fCreatePauliPropSimulator, __LINE__);
644 fDestroyPauliPropSimulator =
645 (void (*)(
void *))GetFunction(
"DestroyPauliPropSimulator");
646 CheckFunction((
void *)fDestroyPauliPropSimulator, __LINE__);
648 fPauliPropGetNrQubits =
649 (int (*)(
void *))GetFunction(
"PauliPropGetNrQubits");
650 CheckFunction((
void *)fPauliPropGetNrQubits, __LINE__);
651 fPauliPropSetWillUseSampling =
652 (int (*)(
void *, int))GetFunction(
"PauliPropSetWillUseSampling");
653 CheckFunction((
void *)fPauliPropSetWillUseSampling, __LINE__);
654 fPauliPropGetWillUseSampling =
655 (int (*)(
void *))GetFunction(
"PauliPropGetWillUseSampling");
656 CheckFunction((
void *)fPauliPropGetWillUseSampling, __LINE__);
658 fPauliPropGetCoefficientTruncationCutoff = (double (*)(
659 void *))GetFunction(
"PauliPropGetCoefficientTruncationCutoff");
660 CheckFunction((
void *)fPauliPropGetCoefficientTruncationCutoff,
662 fPauliPropSetCoefficientTruncationCutoff =
663 (void (*)(
void *, double))GetFunction(
664 "PauliPropSetCoefficientTruncationCutoff");
665 CheckFunction((
void *)fPauliPropSetCoefficientTruncationCutoff,
667 fPauliPropGetWeightTruncationCutoff = (double (*)(
void *))GetFunction(
668 "PauliPropGetWeightTruncationCutoff");
669 CheckFunction((
void *)fPauliPropGetWeightTruncationCutoff, __LINE__);
670 fPauliPropSetWeightTruncationCutoff = (void (*)(
671 void *, double))GetFunction(
"PauliPropSetWeightTruncationCutoff");
672 CheckFunction((
void *)fPauliPropSetWeightTruncationCutoff, __LINE__);
673 fPauliPropGetNumGatesBetweenTruncations = (int (*)(
674 void *))GetFunction(
"PauliPropGetNumGatesBetweenTruncations");
675 CheckFunction((
void *)fPauliPropGetNumGatesBetweenTruncations,
677 fPauliPropSetNumGatesBetweenTruncations =
678 (void (*)(
void *, int))GetFunction(
679 "PauliPropSetNumGatesBetweenTruncations");
680 CheckFunction((
void *)fPauliPropSetNumGatesBetweenTruncations,
682 fPauliPropGetNumGatesBetweenDeduplications = (int (*)(
683 void *))GetFunction(
"PauliPropGetNumGatesBetweenDeduplications");
684 CheckFunction((
void *)fPauliPropGetNumGatesBetweenDeduplications,
686 fPauliPropSetNumGatesBetweenDeduplications =
687 (void (*)(
void *, int))GetFunction(
688 "PauliPropSetNumGatesBetweenDeduplications");
689 CheckFunction((
void *)fPauliPropSetNumGatesBetweenDeduplications,
692 fPauliPropClearOperators =
693 (int (*)(
void *))GetFunction(
"PauliPropClearOperators");
694 CheckFunction((
void *)fPauliPropClearOperators, __LINE__);
695 fPauliPropAllocateMemory =
696 (int (*)(
void *, double))GetFunction(
"PauliPropAllocateMemory");
697 CheckFunction((
void *)fPauliPropAllocateMemory, __LINE__);
699 fPauliPropGetExpectationValue =
700 (double (*)(
void *))GetFunction(
"PauliPropGetExpectationValue");
701 CheckFunction((
void *)fPauliPropGetExpectationValue, __LINE__);
702 fPauliPropExecute = (int (*)(
void *))GetFunction(
"PauliPropExecute");
703 CheckFunction((
void *)fPauliPropExecute, __LINE__);
704 fPauliPropSetInPauliExpansionUnique =
705 (int (*)(
void *,
const char *))GetFunction(
706 "PauliPropSetInPauliExpansionUnique");
707 CheckFunction((
void *)fPauliPropSetInPauliExpansionUnique, __LINE__);
708 fPauliPropSetInPauliExpansionMultiple =
709 (int (*)(
void *,
const char **,
const double *, int))GetFunction(
710 "PauliPropSetInPauliExpansionMultiple");
711 CheckFunction((
void *)fPauliPropSetInPauliExpansionMultiple,
715 (int (*)(
void *, int))GetFunction(
"PauliPropApplyX");
716 CheckFunction((
void *)fPauliPropApplyX, __LINE__);
718 (int (*)(
void *, int))GetFunction(
"PauliPropApplyY");
719 CheckFunction((
void *)fPauliPropApplyY, __LINE__);
721 (int (*)(
void *, int))GetFunction(
"PauliPropApplyZ");
722 CheckFunction((
void *)fPauliPropApplyZ, __LINE__);
724 (int (*)(
void *, int))GetFunction(
"PauliPropApplyH");
725 CheckFunction((
void *)fPauliPropApplyH, __LINE__);
727 (int (*)(
void *, int))GetFunction(
"PauliPropApplyS");
728 CheckFunction((
void *)fPauliPropApplyS, __LINE__);
730 fPauliPropApplySQRTX =
731 (int (*)(
void *, int))GetFunction(
"PauliPropApplySQRTX");
732 CheckFunction((
void *)fPauliPropApplySQRTX, __LINE__);
733 fPauliPropApplySQRTY =
734 (int (*)(
void *, int))GetFunction(
"PauliPropApplySQRTY");
735 CheckFunction((
void *)fPauliPropApplySQRTY, __LINE__);
736 fPauliPropApplySQRTZ =
737 (int (*)(
void *, int))GetFunction(
"PauliPropApplySQRTZ");
738 CheckFunction((
void *)fPauliPropApplySQRTZ, __LINE__);
740 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyCX");
741 CheckFunction((
void *)fPauliPropApplyCX, __LINE__);
743 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyCY");
744 CheckFunction((
void *)fPauliPropApplyCY, __LINE__);
746 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyCZ");
747 CheckFunction((
void *)fPauliPropApplyCZ, __LINE__);
748 fPauliPropApplySWAP =
749 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplySWAP");
750 CheckFunction((
void *)fPauliPropApplySWAP, __LINE__);
751 fPauliPropApplyISWAP =
752 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyISWAP");
753 CheckFunction((
void *)fPauliPropApplyISWAP, __LINE__);
755 (int (*)(
void *, int, double))GetFunction(
"PauliPropApplyRX");
756 CheckFunction((
void *)fPauliPropApplyRX, __LINE__);
758 (int (*)(
void *, int, double))GetFunction(
"PauliPropApplyRY");
759 CheckFunction((
void *)fPauliPropApplyRY, __LINE__);
761 (int (*)(
void *, int, double))GetFunction(
"PauliPropApplyRZ");
762 CheckFunction((
void *)fPauliPropApplyRZ, __LINE__);
764 fPauliPropAddNoiseX =
765 (int (*)(
void *, int, double))GetFunction(
"PauliPropAddNoiseX");
766 CheckFunction((
void *)fPauliPropAddNoiseX, __LINE__);
767 fPauliPropAddNoiseY =
768 (int (*)(
void *, int, double))GetFunction(
"PauliPropAddNoiseY");
769 CheckFunction((
void *)fPauliPropAddNoiseY, __LINE__);
770 fPauliPropAddNoiseZ =
771 (int (*)(
void *, int, double))GetFunction(
"PauliPropAddNoiseZ");
772 CheckFunction((
void *)fPauliPropAddNoiseZ, __LINE__);
773 fPauliPropAddNoiseXYZ =
774 (int (*)(
void *, int, double, double, double))GetFunction(
775 "PauliPropAddNoiseXYZ");
776 CheckFunction((
void *)fPauliPropAddNoiseXYZ, __LINE__);
777 fPauliPropAddAmplitudeDamping =
778 (int (*)(
void *, int, double, double))GetFunction(
779 "PauliPropAddAmplitudeDamping");
780 CheckFunction((
void *)fPauliPropAddAmplitudeDamping, __LINE__);
781 fPauliPropQubitProbability0 = (double (*)(
void *, int))GetFunction(
782 "PauliPropQubitProbability0");
783 CheckFunction((
void *)fPauliPropQubitProbability0, __LINE__);
784 fPauliPropProbability =
785 (double (*)(
void *,
unsigned long long int))GetFunction(
786 "PauliPropProbability");
787 CheckFunction((
void *)fPauliPropProbability, __LINE__);
789 fPauliPropMeasureQubit =
790 (int (*)(
void *, int))GetFunction(
"PauliPropMeasureQubit");
791 CheckFunction((
void *)fPauliPropMeasureQubit, __LINE__);
793 fPauliPropSampleQubits =
794 (
unsigned char *(*)(
void *,
const int *,
int))GetFunction(
795 "PauliPropSampleQubits");
796 CheckFunction((
void *)fPauliPropSampleQubits, __LINE__);
797 fPauliPropFreeSampledQubits = (void (*)(
unsigned char *))GetFunction(
798 "PauliPropFreeSampledQubits");
799 CheckFunction((
void *)fPauliPropFreeSampledQubits, __LINE__);
800 fPauliPropSaveState =
801 (void (*)(
void *))GetFunction(
"PauliPropSaveState");
802 CheckFunction((
void *)fPauliPropSaveState, __LINE__);
803 fPauliPropRestoreState =
804 (void (*)(
void *))GetFunction(
"PauliPropRestoreState");
805 CheckFunction((
void *)fPauliPropRestoreState, __LINE__);
809 std::cerr <<
"GpuLibrary: Unable to initialize gpu library"
812 std::cerr <<
"GpuLibrary: Unable to get initialization function for "
816 std::cerr <<
"GpuLibrary: Unable to load gpu library" << std::endl;
821 static void CheckFunction(
void *func,
int line) {
823 std::cerr <<
"GpuLibrary: Unable to load function, line #: " << line;
824 const char *dlsym_error = dlerror();
825 if (dlsym_error) std::cerr <<
", error: " << dlsym_error;
827 std::cerr << std::endl;
831 bool IsValid()
const {
return LibraryHandle !=
nullptr; }
835 void *CreateStateVector() {
837 return fCreateStateVector(LibraryHandle);
839 throw std::runtime_error(
"GpuLibrary: Unable to create state vector");
842 void DestroyStateVector(
void *obj) {
844 fDestroyStateVector(obj);
846 throw std::runtime_error(
"GpuLibrary: Unable to destroy state vector");
849 bool Create(
void *obj,
unsigned int nrQubits) {
851 return fCreate(obj, nrQubits) == 1;
853 throw std::runtime_error(
854 "GpuLibrary: Unable to create state vector state");
859 bool CreateWithState(
void *obj,
unsigned int nrQubits,
const double *state) {
861 return fCreateWithState(obj, nrQubits, state) == 1;
863 throw std::runtime_error(
864 "GpuLibrary: Unable to create state vector state with a state");
869 bool Reset(
void *obj) {
871 return fReset(obj) == 1;
873 throw std::runtime_error(
"GpuLibrary: Unable to reset state vector");
878 bool SetDataType(
void *obj,
int dataType) {
880 return fSetDataType(obj, dataType) == 1;
882 throw std::runtime_error(
"GpuLibrary: Unable to set data type");
887 bool IsDoublePrecision(
void *obj)
const {
889 return fIsDoublePrecision(obj) == 1;
891 throw std::runtime_error(
892 "GpuLibrary: Unable to check if double precision");
897 int GetNrQubits(
void *obj)
const {
899 return fGetNrQubits(obj);
901 throw std::runtime_error(
"GpuLibrary: Unable to get number of qubits");
905 bool MeasureQubitCollapse(
void *obj,
int qubitIndex) {
907 return fMeasureQubitCollapse(obj, qubitIndex) == 1;
909 throw std::runtime_error(
910 "GpuLibrary: Unable to measure qubit with collapse");
915 bool MeasureQubitNoCollapse(
void *obj,
int qubitIndex) {
917 return fMeasureQubitNoCollapse(obj, qubitIndex) == 1;
919 throw std::runtime_error(
920 "GpuLibrary: Unable to measure qubit no collapse");
925 bool MeasureQubitsCollapse(
void *obj,
int *qubits,
int *bitstring,
928 return fMeasureQubitsCollapse(obj, qubits, bitstring, bitstringLen) == 1;
930 throw std::runtime_error(
931 "GpuLibrary: Unable to measure qubits with collapse");
936 bool MeasureQubitsNoCollapse(
void *obj,
int *qubits,
int *bitstring,
939 return fMeasureQubitsNoCollapse(obj, qubits, bitstring, bitstringLen) ==
942 throw std::runtime_error(
943 "GpuLibrary: Unable to measure qubits with no collapse");
948 unsigned long long MeasureAllQubitsCollapse(
void *obj) {
950 return fMeasureAllQubitsCollapse(obj);
952 throw std::runtime_error(
953 "GpuLibrary: Unable to measure all qubits with collapse");
958 unsigned long long MeasureAllQubitsNoCollapse(
void *obj) {
960 return fMeasureAllQubitsNoCollapse(obj);
962 throw std::runtime_error(
963 "GpuLibrary: Unable to measure all qubits with no collapse");
970 return fSaveState(obj) == 1;
972 throw std::runtime_error(
"GpuLibrary: Unable to save state");
977 bool SaveStateToHost(
void *obj) {
979 return fSaveStateToHost(obj) == 1;
981 throw std::runtime_error(
"GpuLibrary: Unable to save state to host");
986 bool SaveStateDestructive(
void *obj) {
988 return fSaveStateDestructive(obj) == 1;
990 throw std::runtime_error(
991 "GpuLibrary: Unable to save state destructively");
996 bool RestoreStateFreeSaved(
void *obj) {
998 return fRestoreStateFreeSaved(obj) == 1;
1000 throw std::runtime_error(
1001 "GpuLibrary: Unable to restore state free saved");
1006 bool RestoreStateNoFreeSaved(
void *obj) {
1008 return fRestoreStateNoFreeSaved(obj) == 1;
1010 throw std::runtime_error(
1011 "GpuLibrary: Unable to restore state no free saved");
1016 void FreeSavedState(
void *obj) {
1018 fFreeSavedState(obj);
1020 throw std::runtime_error(
"GpuLibrary: Unable to free saved state");
1023 void *Clone(
void *obj)
const {
1027 throw std::runtime_error(
"GpuLibrary: Unable to clone state vector");
1032 bool Sample(
void *obj,
unsigned int nSamples,
long int *samples,
1033 unsigned int nBits,
int *bits) {
1035 return fSample(obj, nSamples, samples, nBits, bits) == 1;
1037 throw std::runtime_error(
"GpuLibrary: Unable to sample state vector");
1042 bool SampleAll(
void *obj,
unsigned int nSamples,
long int *samples) {
1044 return fSampleAll(obj, nSamples, samples) == 1;
1046 throw std::runtime_error(
"GpuLibrary: Unable to sample state vector");
1051 bool Amplitude(
void *obj,
long long int state,
double *real,
1052 double *imaginary)
const {
1054 return fAmplitude(obj, state, real, imaginary) == 1;
1056 throw std::runtime_error(
"GpuLibrary: Unable to get amplitude");
1061 double Probability(
void *obj,
int *qubits,
int *mask,
int len)
const {
1063 return fProbability(obj, qubits, mask, len);
1065 throw std::runtime_error(
"GpuLibrary: Unable to get probability");
1070 double BasisStateProbability(
void *obj,
long long int state)
const {
1072 return fBasisStateProbability(obj, state);
1074 throw std::runtime_error(
1075 "GpuLibrary: Unable to get basis state probability");
1082 return fAllProbabilities(obj, probabilities) == 1;
1084 throw std::runtime_error(
"GpuLibrary: Unable to get all probabilities");
1089 double ExpectationValue(
void *obj,
const char *pauliString,
int len)
const {
1091 return fExpectationValue(obj, pauliString, len);
1093 throw std::runtime_error(
"GpuLibrary: Unable to get expectation value");
1098 bool ApplyX(
void *obj,
int qubit) {
1100 return fApplyX(obj, qubit) == 1;
1102 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate");
1107 bool ApplyY(
void *obj,
int qubit) {
1109 return fApplyY(obj, qubit) == 1;
1111 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate");
1116 bool ApplyZ(
void *obj,
int qubit) {
1118 return fApplyZ(obj, qubit) == 1;
1120 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate");
1125 bool ApplyH(
void *obj,
int qubit) {
1127 return fApplyH(obj, qubit) == 1;
1129 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate");
1134 bool ApplyS(
void *obj,
int qubit) {
1136 return fApplyS(obj, qubit) == 1;
1138 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate");
1143 bool ApplySDG(
void *obj,
int qubit) {
1145 return fApplySDG(obj, qubit) == 1;
1147 throw std::runtime_error(
"GpuLibrary: Unable to apply SDG gate");
1152 bool ApplyT(
void *obj,
int qubit) {
1154 return fApplyT(obj, qubit) == 1;
1156 throw std::runtime_error(
"GpuLibrary: Unable to apply T gate");
1161 bool ApplyTDG(
void *obj,
int qubit) {
1163 return fApplyTDG(obj, qubit) == 1;
1165 throw std::runtime_error(
"GpuLibrary: Unable to apply TDG gate");
1170 bool ApplySX(
void *obj,
int qubit) {
1172 return fApplySX(obj, qubit) == 1;
1174 throw std::runtime_error(
"GpuLibrary: Unable to apply SX gate");
1181 return fApplySXDG(obj, qubit) == 1;
1183 throw std::runtime_error(
"GpuLibrary: Unable to apply SXDG gate");
1188 bool ApplyK(
void *obj,
int qubit) {
1190 return fApplyK(obj, qubit) == 1;
1192 throw std::runtime_error(
"GpuLibrary: Unable to apply K gate");
1197 bool ApplyP(
void *obj,
int qubit,
double theta) {
1199 return fApplyP(obj, qubit, theta) == 1;
1201 throw std::runtime_error(
"GpuLibrary: Unable to apply P gate");
1206 bool ApplyRx(
void *obj,
int qubit,
double theta) {
1208 return fApplyRx(obj, qubit, theta) == 1;
1210 throw std::runtime_error(
"GpuLibrary: Unable to apply Rx gate");
1215 bool ApplyRy(
void *obj,
int qubit,
double theta) {
1217 return fApplyRy(obj, qubit, theta) == 1;
1219 throw std::runtime_error(
"GpuLibrary: Unable to apply Ry gate");
1224 bool ApplyRz(
void *obj,
int qubit,
double theta) {
1226 return fApplyRz(obj, qubit, theta) == 1;
1228 throw std::runtime_error(
"GpuLibrary: Unable to apply Rz gate");
1233 bool ApplyU(
void *obj,
int qubit,
double theta,
double phi,
double lambda,
1236 return fApplyU(obj, qubit, theta, phi, lambda, gamma) == 1;
1238 throw std::runtime_error(
"GpuLibrary: Unable to apply U gate");
1243 bool ApplyCX(
void *obj,
int controlQubit,
int targetQubit) {
1245 return fApplyCX(obj, controlQubit, targetQubit) == 1;
1247 throw std::runtime_error(
"GpuLibrary: Unable to apply CX gate");
1252 bool ApplyCY(
void *obj,
int controlQubit,
int targetQubit) {
1254 return fApplyCY(obj, controlQubit, targetQubit) == 1;
1256 throw std::runtime_error(
"GpuLibrary: Unable to apply CY gate");
1261 bool ApplyCZ(
void *obj,
int controlQubit,
int targetQubit) {
1263 return fApplyCZ(obj, controlQubit, targetQubit) == 1;
1265 throw std::runtime_error(
"GpuLibrary: Unable to apply CZ gate");
1270 bool ApplyCH(
void *obj,
int controlQubit,
int targetQubit) {
1272 return fApplyCH(obj, controlQubit, targetQubit) == 1;
1274 throw std::runtime_error(
"GpuLibrary: Unable to apply CH gate");
1279 bool ApplyCSX(
void *obj,
int controlQubit,
int targetQubit) {
1281 return fApplyCSX(obj, controlQubit, targetQubit) == 1;
1283 throw std::runtime_error(
"GpuLibrary: Unable to apply CSX gate");
1288 bool ApplyCSXDG(
void *obj,
int controlQubit,
int targetQubit) {
1290 return fApplyCSXDG(obj, controlQubit, targetQubit) == 1;
1292 throw std::runtime_error(
"GpuLibrary: Unable to apply CSXDG gate");
1297 bool ApplyCP(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
1299 return fApplyCP(obj, controlQubit, targetQubit, theta) == 1;
1301 throw std::runtime_error(
"GpuLibrary: Unable to apply CP gate");
1306 bool ApplyCRx(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
1308 return fApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
1310 throw std::runtime_error(
"GpuLibrary: Unable to apply CRx gate");
1315 bool ApplyCRy(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
1317 return fApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
1319 throw std::runtime_error(
"GpuLibrary: Unable to apply CRy gate");
1324 bool ApplyCRz(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
1326 return fApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
1328 throw std::runtime_error(
"GpuLibrary: Unable to apply CRz gate");
1333 bool ApplyCCX(
void *obj,
int controlQubit1,
int controlQubit2,
1336 return fApplyCCX(obj, controlQubit1, controlQubit2, targetQubit) == 1;
1338 throw std::runtime_error(
"GpuLibrary: Unable to apply CCX gate");
1343 bool ApplySwap(
void *obj,
int qubit1,
int qubit2) {
1345 return fApplySwap(obj, qubit1, qubit2) == 1;
1347 throw std::runtime_error(
"GpuLibrary: Unable to apply Swap gate");
1352 bool ApplyCSwap(
void *obj,
int controlQubit,
int qubit1,
int qubit2) {
1354 return fApplyCSwap(obj, controlQubit, qubit1, qubit2) == 1;
1356 throw std::runtime_error(
"GpuLibrary: Unable to apply CSwap gate");
1361 bool ApplyCU(
void *obj,
int controlQubit,
int targetQubit,
double theta,
1362 double phi,
double lambda,
double gamma) {
1364 return fApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda,
1367 throw std::runtime_error(
"GpuLibrary: Unable to apply CU gate");
1376 return fCreateMPS(LibraryHandle);
1378 throw std::runtime_error(
"GpuLibrary: Unable to create mps");
1381 void DestroyMPS(
void *obj) {
1385 throw std::runtime_error(
"GpuLibrary: Unable to destroy mps");
1388 bool MPSCreate(
void *obj,
unsigned int nrQubits) {
1390 return fMPSCreate(obj, nrQubits) == 1;
1392 throw std::runtime_error(
1393 "GpuLibrary: Unable to create mps with the "
1394 "specified number of qubits");
1399 bool MPSReset(
void *obj) {
1401 return fMPSReset(obj) == 1;
1403 throw std::runtime_error(
"GpuLibrary: Unable to reset mps");
1408 bool MPSSetInitialQubitsMap(
void *obj,
1409 const std::vector<long long int> &initialMap) {
1411 return fMPSSetInitialQubitsMap(obj, initialMap.data(),
1412 initialMap.size()) == 1;
1414 throw std::runtime_error(
1415 "GpuLibrary: Unable to set initial qubits map for mps");
1420 bool MPSSetUseOptimalMeetingPosition(
void *obj,
int val) {
1422 return fMPSSetUseOptimalMeetingPosition(obj, val) == 1;
1424 throw std::runtime_error(
1425 "GpuLibrary: Unable to set use optimal meeting position for mps");
1429 bool MPSIsValid(
void *obj)
const {
1431 return fMPSIsValid(obj) == 1;
1433 throw std::runtime_error(
"GpuLibrary: Unable to check if mps is valid");
1438 bool MPSIsCreated(
void *obj)
const {
1440 return fMPSIsCreated(obj) == 1;
1442 throw std::runtime_error(
"GpuLibrary: Unable to check if mps is created");
1447 bool MPSSetDataType(
void *obj,
int useDoublePrecision) {
1449 return fMPSSetDataType(obj, useDoublePrecision) == 1;
1451 throw std::runtime_error(
"GpuLibrary: Unable to set precision for mps");
1456 bool MPSIsDoublePrecision(
void *obj)
const {
1458 return fMPSIsDoublePrecision(obj) == 1;
1460 throw std::runtime_error(
"GpuLibrary: Unable to get precision for mps");
1465 bool MPSSetCutoff(
void *obj,
double val) {
1467 return fMPSSetCutoff(obj, val) == 1;
1469 throw std::runtime_error(
"GpuLibrary: Unable to set cutoff for mps");
1474 double MPSGetCutoff(
void *obj)
const {
1476 return fMPSGetCutoff(obj);
1478 throw std::runtime_error(
"GpuLibrary: Unable to get cutoff for mps");
1481 bool MPSSetGesvdJ(
void *obj,
int val) {
1483 return fMPSSetGesvdJ(obj, val) == 1;
1485 throw std::runtime_error(
"GpuLibrary: Unable to set GesvdJ for mps");
1490 bool MPSGetGesvdJ(
void *obj)
const {
1492 return fMPSGetGesvdJ(obj) == 1;
1494 throw std::runtime_error(
"GpuLibrary: Unable to get GesvdJ for mps");
1499 bool MPSSetMaxExtent(
void *obj,
long int val) {
1501 return fMPSSetMaxExtent(obj, val) == 1;
1503 throw std::runtime_error(
"GpuLibrary: Unable to set max extent for mps");
1508 long int MPSGetMaxExtent(
void *obj) {
1510 return fMPSGetMaxExtent(obj);
1512 throw std::runtime_error(
"GpuLibrary: Unable to get max extent for mps");
1517 int MPSGetNrQubits(
void *obj) {
1519 return fMPSGetNrQubits(obj);
1521 throw std::runtime_error(
"GpuLibrary: Unable to get nr qubits for mps");
1526 bool MPSSetCallbackContext(
void *obj,
void *context) {
1528 return fMPSSetCallbackContext(obj, context) == 1;
1530 throw std::runtime_error(
1531 "GpuLibrary: Unable to set callback context for mps");
1535 bool MPSSetMeetingPositionCallback(
void *obj, int64_t(*callback)(
void*,
const int64_t*)) {
1537 return fMPSSetMeetingPositionCallback(obj, callback) == 1;
1539 throw std::runtime_error(
1540 "GpuLibrary: Unable to set meeting position callback for mps");
1544 bool MPSAmplitude(
void *obj,
long int numFixedValues,
long int *fixedValues,
1545 double *real,
double *imaginary) {
1547 return fMPSAmplitude(obj, numFixedValues, fixedValues, real, imaginary) ==
1550 throw std::runtime_error(
"GpuLibrary: Unable to get mps amplitude");
1555 double MPSProbability0(
void *obj,
unsigned int qubit) {
1557 return fMPSProbability0(obj, qubit);
1559 throw std::runtime_error(
1560 "GpuLibrary: Unable to get probability for 0 for mps");
1565 bool MPSMeasure(
void *obj,
unsigned int qubit) {
1567 return fMPSMeasure(obj, qubit) == 1;
1569 throw std::runtime_error(
"GpuLibrary: Unable to measure qubit on mps");
1574 bool MPSMeasureQubits(
void *obj,
long int numQubits,
unsigned int *qubits,
1577 return fMPSMeasureQubits(obj, numQubits, qubits, result) == 1;
1579 throw std::runtime_error(
"GpuLibrary: Unable to measure qubits on mps");
1584 std::unordered_map<std::vector<bool>, int64_t> *MPSGetMapForSample() {
1586 return (std::unordered_map<std::vector<bool>, int64_t> *)
1587 fMPSGetMapForSample();
1589 throw std::runtime_error(
1590 "GpuLibrary: Unable to get map for sample for mps");
1595 bool MPSFreeMapForSample(
1596 std::unordered_map<std::vector<bool>, int64_t> *map) {
1598 return fMPSFreeMapForSample((
void *)map) == 1;
1600 throw std::runtime_error(
1601 "GpuLibrary: Unable to free map for sample for mps");
1606 bool MPSSample(
void *obj,
long int numShots,
long int numQubits,
1607 unsigned int *qubits,
void *resultMap) {
1609 return fMPSSample(obj, numShots, numQubits, qubits, resultMap) == 1;
1611 throw std::runtime_error(
"GpuLibrary: Unable to sample mps");
1616 bool MPSSaveState(
void *obj) {
1618 return fMPSSaveState(obj) == 1;
1620 throw std::runtime_error(
"GpuLibrary: Unable to save mps state");
1625 bool MPSRestoreState(
void *obj) {
1627 return fMPSRestoreState(obj) == 1;
1629 throw std::runtime_error(
"GpuLibrary: Unable to restore mps state");
1634 bool MPSCleanSavedState(
void *obj) {
1636 return fMPSCleanSavedState(obj) == 1;
1638 throw std::runtime_error(
"GpuLibrary: Unable to clean mps saved state");
1643 void *MPSClone(
void *obj) {
1645 return fMPSClone(obj);
1647 throw std::runtime_error(
"GpuLibrary: Unable to clone mps");
1652 double MPSExpectationValue(
void *obj,
const char *pauliString,
1655 return fMPSExpectationValue(obj, pauliString, len);
1657 throw std::runtime_error(
1658 "GpuLibrary: Unable to get mps expectation value");
1663 std::complex<double> MPSProjectOnZero(
void* obj)
1665 if (LibraryHandle) {
1667 if (fMPSProjectOnZero(obj, &real, &imag) == 1)
1668 return std::complex<double>(real, imag);
1670 throw std::runtime_error(
1671 "GpuLibrary: Unable to project on zero for mps");
1673 throw std::runtime_error(
1674 "GpuLibrary: Unable to project on zero for mps, library handle is null");
1676 return std::complex<double>(0, 0);
1679 bool MPSApplyX(
void *obj,
unsigned int siteA) {
1681 return fMPSApplyX(obj, siteA) == 1;
1683 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate on mps");
1688 bool MPSApplyY(
void *obj,
unsigned int siteA) {
1690 return fMPSApplyY(obj, siteA) == 1;
1692 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate on mps");
1697 bool MPSApplyZ(
void *obj,
unsigned int siteA) {
1699 return fMPSApplyZ(obj, siteA) == 1;
1701 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate on mps");
1706 bool MPSApplyH(
void *obj,
unsigned int siteA) {
1708 return fMPSApplyH(obj, siteA) == 1;
1710 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate on mps");
1715 bool MPSApplyS(
void *obj,
unsigned int siteA) {
1717 return fMPSApplyS(obj, siteA) == 1;
1719 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate on mps");
1724 bool MPSApplySDG(
void *obj,
unsigned int siteA) {
1726 return fMPSApplySDG(obj, siteA) == 1;
1728 throw std::runtime_error(
"GpuLibrary: Unable to apply sdg gate on mps");
1733 bool MPSApplyT(
void *obj,
unsigned int siteA) {
1735 return fMPSApplyT(obj, siteA) == 1;
1737 throw std::runtime_error(
"GpuLibrary: Unable to apply t gate on mps");
1742 bool MPSApplyTDG(
void *obj,
unsigned int siteA) {
1744 return fMPSApplyTDG(obj, siteA) == 1;
1746 throw std::runtime_error(
"GpuLibrary: Unable to appl tdg gate on mps");
1751 bool MPSApplySX(
void *obj,
unsigned int siteA) {
1753 return fMPSApplySX(obj, siteA) == 1;
1755 throw std::runtime_error(
"GpuLibrary: Unable to apply sx gate on mps");
1760 bool MPSApplySXDG(
void *obj,
unsigned int siteA) {
1762 return fMPSApplySXDG(obj, siteA) == 1;
1764 throw std::runtime_error(
"GpuLibrary: Unable to apply sxdg gate on mps");
1769 bool MPSApplyK(
void *obj,
unsigned int siteA) {
1771 return fMPSApplyK(obj, siteA) == 1;
1773 throw std::runtime_error(
"GpuLibrary: Unable to apply k gate on mps");
1778 bool MPSApplyP(
void *obj,
unsigned int siteA,
double theta) {
1780 return fMPSApplyP(obj, siteA, theta) == 1;
1782 throw std::runtime_error(
"GpuLibrary: Unable to apply p gate on mps");
1786 bool MPSApplyRx(
void *obj,
unsigned int siteA,
double theta) {
1788 return fMPSApplyRx(obj, siteA, theta) == 1;
1790 throw std::runtime_error(
"GpuLibrary: Unable to apply rx gate on mps");
1795 bool MPSApplyRy(
void *obj,
unsigned int siteA,
double theta) {
1797 return fMPSApplyRy(obj, siteA, theta) == 1;
1799 throw std::runtime_error(
"GpuLibrary: Unable to apply ry gate on mps");
1804 bool MPSApplyRz(
void *obj,
unsigned int siteA,
double theta) {
1806 return fMPSApplyRz(obj, siteA, theta) == 1;
1808 throw std::runtime_error(
"GpuLibrary: Unable to apply rz gate on mps");
1813 bool MPSApplyU(
void *obj,
unsigned int siteA,
double theta,
double phi,
1814 double lambda,
double gamma) {
1816 return fMPSApplyU(obj, siteA, theta, phi, lambda, gamma) == 1;
1818 throw std::runtime_error(
"GpuLibrary: Unable to apply u gate on mps");
1823 bool MPSApplySwap(
void *obj,
unsigned int controlQubit,
1824 unsigned int targetQubit) {
1826 return fMPSApplySwap(obj, controlQubit, targetQubit) == 1;
1828 throw std::runtime_error(
"GpuLibrary: Unable to apply swap gate on mps");
1833 bool MPSApplyCX(
void *obj,
unsigned int controlQubit,
1834 unsigned int targetQubit) {
1836 return fMPSApplyCX(obj, controlQubit, targetQubit) == 1;
1838 throw std::runtime_error(
"GpuLibrary: Unable to apply cx gate on mps");
1843 bool MPSApplyCY(
void *obj,
unsigned int controlQubit,
1844 unsigned int targetQubit) {
1846 return fMPSApplyCY(obj, controlQubit, targetQubit) == 1;
1848 throw std::runtime_error(
"GpuLibrary: Unable to apply cy gate on mps");
1853 bool MPSApplyCZ(
void *obj,
unsigned int controlQubit,
1854 unsigned int targetQubit) {
1856 return fMPSApplyCZ(obj, controlQubit, targetQubit) == 1;
1858 throw std::runtime_error(
"GpuLibrary: Unable to apply cz gate on mps");
1863 bool MPSApplyCH(
void *obj,
unsigned int controlQubit,
1864 unsigned int targetQubit) {
1866 return fMPSApplyCH(obj, controlQubit, targetQubit) == 1;
1868 throw std::runtime_error(
"GpuLibrary: Unable to apply ch gate on mps");
1873 bool MPSApplyCSX(
void *obj,
unsigned int controlQubit,
1874 unsigned int targetQubit) {
1876 return fMPSApplyCSX(obj, controlQubit, targetQubit) == 1;
1878 throw std::runtime_error(
"GpuLibrary: Unable to apply csx gate on mps");
1881 bool MPSApplyCSXDG(
void *obj,
unsigned int controlQubit,
1882 unsigned int targetQubit) {
1884 return fMPSApplyCSXDG(obj, controlQubit, targetQubit) == 1;
1886 throw std::runtime_error(
"GpuLibrary: Unable to apply csxdg gate on mps");
1891 bool MPSApplyCP(
void *obj,
unsigned int controlQubit,
1892 unsigned int targetQubit,
double theta) {
1894 return fMPSApplyCP(obj, controlQubit, targetQubit, theta) == 1;
1896 throw std::runtime_error(
"GpuLibrary: Unable to apply cp gate on mps");
1901 bool MPSApplyCRx(
void *obj,
unsigned int controlQubit,
1902 unsigned int targetQubit,
double theta) {
1904 return fMPSApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
1906 throw std::runtime_error(
"GpuLibrary: Unable to apply crx gate on mps");
1911 bool MPSApplyCRy(
void *obj,
unsigned int controlQubit,
1912 unsigned int targetQubit,
double theta) {
1914 return fMPSApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
1916 throw std::runtime_error(
"GpuLibrary: Unable to apply cry gate on mps");
1921 bool MPSApplyCRz(
void *obj,
unsigned int controlQubit,
1922 unsigned int targetQubit,
double theta) {
1924 return fMPSApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
1926 throw std::runtime_error(
"GpuLibrary: Unable to apply crz gate on mps");
1931 bool MPSApplyCU(
void *obj,
unsigned int controlQubit,
1932 unsigned int targetQubit,
double theta,
double phi,
1933 double lambda,
double gamma) {
1935 return fMPSApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda,
1938 throw std::runtime_error(
"GpuLibrary: Unable to apply cu gate on mps");
1945 void *CreateTensorNet() {
1947 return fCreateTensorNet(LibraryHandle);
1949 throw std::runtime_error(
"GpuLibrary: Unable to create tensor network");
1952 void DestroyTensorNet(
void *obj) {
1954 fDestroyTensorNet(obj);
1956 throw std::runtime_error(
"GpuLibrary: Unable to destroy tensor network");
1959 bool TNCreate(
void *obj,
unsigned int nrQubits) {
1961 return fTNCreate(obj, nrQubits) == 1;
1963 throw std::runtime_error(
1964 "GpuLibrary: Unable to create tensor network with the "
1965 "specified number of qubits");
1970 bool TNReset(
void *obj) {
1972 return fTNReset(obj) == 1;
1974 throw std::runtime_error(
"GpuLibrary: Unable to reset tensor network");
1979 bool TNIsValid(
void *obj)
const {
1981 return fTNIsValid(obj) == 1;
1983 throw std::runtime_error(
1984 "GpuLibrary: Unable to check if tensor network is valid");
1989 bool TNIsCreated(
void *obj)
const {
1991 return fTNIsCreated(obj) == 1;
1993 throw std::runtime_error(
1994 "GpuLibrary: Unable to check if tensor network is created");
1999 bool TNSetDataType(
void *obj,
int useDoublePrecision) {
2001 return fTNSetDataType(obj, useDoublePrecision) == 1;
2003 throw std::runtime_error(
2004 "GpuLibrary: Unable to set precision for tensor network");
2009 bool TNIsDoublePrecision(
void *obj)
const {
2011 return fTNIsDoublePrecision(obj) == 1;
2013 throw std::runtime_error(
2014 "GpuLibrary: Unable to get precision for tensor network");
2019 bool TNSetCutoff(
void *obj,
double val) {
2021 return fTNSetCutoff(obj, val) == 1;
2023 throw std::runtime_error(
2024 "GpuLibrary: Unable to set cutoff for tensor network");
2029 double TNGetCutoff(
void *obj)
const {
2031 return fTNGetCutoff(obj);
2033 throw std::runtime_error(
2034 "GpuLibrary: Unable to get cutoff for tensor network");
2037 bool TNSetGesvdJ(
void *obj,
int val) {
2039 return fTNSetGesvdJ(obj, val) == 1;
2041 throw std::runtime_error(
2042 "GpuLibrary: Unable to set GesvdJ for tensor network");
2047 bool TNGetGesvdJ(
void *obj)
const {
2049 return fTNGetGesvdJ(obj) == 1;
2051 throw std::runtime_error(
2052 "GpuLibrary: Unable to get GesvdJ for tensor network");
2057 bool TNSetMaxExtent(
void *obj,
long int val) {
2059 return fTNSetMaxExtent(obj, val) == 1;
2061 throw std::runtime_error(
2062 "GpuLibrary: Unable to set max extent for tensor network");
2067 long int TNGetMaxExtent(
void *obj) {
2069 return fTNGetMaxExtent(obj);
2071 throw std::runtime_error(
2072 "GpuLibrary: Unable to get max extent for tensor network");
2077 int TNGetNrQubits(
void *obj) {
2079 return fTNGetNrQubits(obj);
2081 throw std::runtime_error(
2082 "GpuLibrary: Unable to get nr qubits for tensor network");
2087 bool TNAmplitude(
void *obj,
long int numFixedValues,
long int *fixedValues,
2088 double *real,
double *imaginary) {
2090 return fTNAmplitude(obj, numFixedValues, fixedValues, real, imaginary) ==
2093 throw std::runtime_error(
2094 "GpuLibrary: Unable to get tensor network amplitude");
2099 double TNProbability0(
void *obj,
unsigned int qubit) {
2101 return fTNProbability0(obj, qubit);
2103 throw std::runtime_error(
2104 "GpuLibrary: Unable to get probability for 0 for tensor network");
2109 bool TNMeasure(
void *obj,
unsigned int qubit) {
2111 return fTNMeasure(obj, qubit) == 1;
2113 throw std::runtime_error(
2114 "GpuLibrary: Unable to measure qubit on tensor network");
2119 bool TNMeasureQubits(
void *obj,
long int numQubits,
unsigned int *qubits,
2122 return fTNMeasureQubits(obj, numQubits, qubits, result) == 1;
2124 throw std::runtime_error(
2125 "GpuLibrary: Unable to measure qubits on tensor network");
2130 std::unordered_map<std::vector<bool>, int64_t> *TNGetMapForSample() {
2133 std::unordered_map<std::vector<bool>, int64_t> *)fTNGetMapForSample();
2135 throw std::runtime_error(
2136 "GpuLibrary: Unable to get map for sample for tensor network");
2141 bool TNFreeMapForSample(std::unordered_map<std::vector<bool>, int64_t> *map) {
2143 return fTNFreeMapForSample((
void *)map) == 1;
2145 throw std::runtime_error(
2146 "GpuLibrary: Unable to free map for sample for tensor network");
2151 bool TNSample(
void *obj,
long int numShots,
long int numQubits,
2152 unsigned int *qubits,
void *resultMap) {
2154 return fTNSample(obj, numShots, numQubits, qubits, resultMap) == 1;
2156 throw std::runtime_error(
"GpuLibrary: Unable to sample tensor network");
2161 bool TNSaveState(
void *obj) {
2163 return fTNSaveState(obj) == 1;
2165 throw std::runtime_error(
2166 "GpuLibrary: Unable to save tensor network state");
2171 bool TNRestoreState(
void *obj) {
2173 return fTNRestoreState(obj) == 1;
2175 throw std::runtime_error(
2176 "GpuLibrary: Unable to restore tensor network state");
2181 bool TNCleanSavedState(
void *obj) {
2183 return fTNCleanSavedState(obj) == 1;
2185 throw std::runtime_error(
2186 "GpuLibrary: Unable to clean tensor network saved state");
2191 void *TNClone(
void *obj) {
2193 return fTNClone(obj);
2195 throw std::runtime_error(
"GpuLibrary: Unable to clone tensor network");
2200 double TNExpectationValue(
void *obj,
const char *pauliString,
int len)
const {
2202 return fTNExpectationValue(obj, pauliString, len);
2204 throw std::runtime_error(
2205 "GpuLibrary: Unable to get tensor network expectation value");
2210 bool TNApplyX(
void *obj,
unsigned int siteA) {
2212 return fTNApplyX(obj, siteA) == 1;
2214 throw std::runtime_error(
2215 "GpuLibrary: Unable to apply X gate on tensor network");
2220 bool TNApplyY(
void *obj,
unsigned int siteA) {
2222 return fTNApplyY(obj, siteA) == 1;
2224 throw std::runtime_error(
2225 "GpuLibrary: Unable to apply Y gate on tensor network");
2230 bool TNApplyZ(
void *obj,
unsigned int siteA) {
2232 return fTNApplyZ(obj, siteA) == 1;
2234 throw std::runtime_error(
2235 "GpuLibrary: Unable to apply Z gate on tensor network");
2240 bool TNApplyH(
void *obj,
unsigned int siteA) {
2242 return fTNApplyH(obj, siteA) == 1;
2244 throw std::runtime_error(
2245 "GpuLibrary: Unable to apply H gate on tensor network");
2250 bool TNApplyS(
void *obj,
unsigned int siteA) {
2252 return fTNApplyS(obj, siteA) == 1;
2254 throw std::runtime_error(
2255 "GpuLibrary: Unable to apply S gate on tensor network");
2260 bool TNApplySDG(
void *obj,
unsigned int siteA) {
2262 return fTNApplySDG(obj, siteA) == 1;
2264 throw std::runtime_error(
2265 "GpuLibrary: Unable to apply sdg gate on tensor network");
2270 bool TNApplyT(
void *obj,
unsigned int siteA) {
2272 return fTNApplyT(obj, siteA) == 1;
2274 throw std::runtime_error(
2275 "GpuLibrary: Unable to apply t gate on tensor network");
2280 bool TNApplyTDG(
void *obj,
unsigned int siteA) {
2282 return fTNApplyTDG(obj, siteA) == 1;
2284 throw std::runtime_error(
2285 "GpuLibrary: Unable to apply tdg gate on tensor network");
2290 bool TNApplySX(
void *obj,
unsigned int siteA) {
2292 return fTNApplySX(obj, siteA) == 1;
2294 throw std::runtime_error(
2295 "GpuLibrary: Unable to apply sx gate on tensor network");
2300 bool TNApplySXDG(
void *obj,
unsigned int siteA) {
2302 return fTNApplySXDG(obj, siteA) == 1;
2304 throw std::runtime_error(
2305 "GpuLibrary: Unable to apply sxdg gate on tensor network");
2310 bool TNApplyK(
void *obj,
unsigned int siteA) {
2312 return fTNApplyK(obj, siteA) == 1;
2314 throw std::runtime_error(
2315 "GpuLibrary: Unable to apply k gate on tensor network");
2320 bool TNApplyP(
void *obj,
unsigned int siteA,
double theta) {
2322 return fTNApplyP(obj, siteA, theta) == 1;
2324 throw std::runtime_error(
2325 "GpuLibrary: Unable to apply p gate on tensor network");
2329 bool TNApplyRx(
void *obj,
unsigned int siteA,
double theta) {
2331 return fTNApplyRx(obj, siteA, theta) == 1;
2333 throw std::runtime_error(
2334 "GpuLibrary: Unable to apply rx gate on tensor network");
2339 bool TNApplyRy(
void *obj,
unsigned int siteA,
double theta) {
2341 return fTNApplyRy(obj, siteA, theta) == 1;
2343 throw std::runtime_error(
2344 "GpuLibrary: Unable to apply ry gate on tensor network");
2349 bool TNApplyRz(
void *obj,
unsigned int siteA,
double theta) {
2351 return fTNApplyRz(obj, siteA, theta) == 1;
2353 throw std::runtime_error(
2354 "GpuLibrary: Unable to apply rz gate on tensor network");
2359 bool TNApplyU(
void *obj,
unsigned int siteA,
double theta,
double phi,
2360 double lambda,
double gamma) {
2362 return fTNApplyU(obj, siteA, theta, phi, lambda, gamma) == 1;
2364 throw std::runtime_error(
2365 "GpuLibrary: Unable to apply u gate on tensor network");
2370 bool TNApplySwap(
void *obj,
unsigned int controlQubit,
2371 unsigned int targetQubit) {
2373 return fTNApplySwap(obj, controlQubit, targetQubit) == 1;
2375 throw std::runtime_error(
2376 "GpuLibrary: Unable to apply swap gate on tensor network");
2381 bool TNApplyCX(
void *obj,
unsigned int controlQubit,
2382 unsigned int targetQubit) {
2384 return fTNApplyCX(obj, controlQubit, targetQubit) == 1;
2386 throw std::runtime_error(
2387 "GpuLibrary: Unable to apply cx gate on tensor network");
2392 bool TNApplyCY(
void *obj,
unsigned int controlQubit,
2393 unsigned int targetQubit) {
2395 return fTNApplyCY(obj, controlQubit, targetQubit) == 1;
2397 throw std::runtime_error(
2398 "GpuLibrary: Unable to apply cy gate on tensor network");
2403 bool TNApplyCZ(
void *obj,
unsigned int controlQubit,
2404 unsigned int targetQubit) {
2406 return fTNApplyCZ(obj, controlQubit, targetQubit) == 1;
2408 throw std::runtime_error(
2409 "GpuLibrary: Unable to apply cz gate on tensor network");
2414 bool TNApplyCH(
void *obj,
unsigned int controlQubit,
2415 unsigned int targetQubit) {
2417 return fTNApplyCH(obj, controlQubit, targetQubit) == 1;
2419 throw std::runtime_error(
2420 "GpuLibrary: Unable to apply ch gate on tensor network");
2425 bool TNApplyCSX(
void *obj,
unsigned int controlQubit,
2426 unsigned int targetQubit) {
2428 return fTNApplyCSX(obj, controlQubit, targetQubit) == 1;
2430 throw std::runtime_error(
2431 "GpuLibrary: Unable to apply csx gate on tensor network");
2434 bool TNApplyCSXDG(
void *obj,
unsigned int controlQubit,
2435 unsigned int targetQubit) {
2437 return fTNApplyCSXDG(obj, controlQubit, targetQubit) == 1;
2439 throw std::runtime_error(
2440 "GpuLibrary: Unable to apply csxdg gate on tensor network");
2445 bool TNApplyCP(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
2448 return fTNApplyCP(obj, controlQubit, targetQubit, theta) == 1;
2450 throw std::runtime_error(
2451 "GpuLibrary: Unable to apply cp gate on tensor network");
2456 bool TNApplyCRx(
void *obj,
unsigned int controlQubit,
2457 unsigned int targetQubit,
double theta) {
2459 return fTNApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
2461 throw std::runtime_error(
2462 "GpuLibrary: Unable to apply crx gate on tensor network");
2467 bool TNApplyCRy(
void *obj,
unsigned int controlQubit,
2468 unsigned int targetQubit,
double theta) {
2470 return fTNApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
2472 throw std::runtime_error(
2473 "GpuLibrary: Unable to apply cry gate on tensor network");
2478 bool TNApplyCRz(
void *obj,
unsigned int controlQubit,
2479 unsigned int targetQubit,
double theta) {
2481 return fTNApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
2483 throw std::runtime_error(
2484 "GpuLibrary: Unable to apply crz gate on tensor network");
2489 bool TNApplyCU(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
2490 double theta,
double phi,
double lambda,
double gamma) {
2492 return fTNApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda,
2495 throw std::runtime_error(
2496 "GpuLibrary: Unable to apply cu gate on tensor network");
2501 bool TNApplyCCX(
void *obj,
unsigned int controlQubit1,
2502 unsigned int controlQubit2,
unsigned int targetQubit) {
2504 return fTNApplyCCX(obj, controlQubit1, controlQubit2, targetQubit) == 1;
2506 throw std::runtime_error(
2507 "GpuLibrary: Unable to apply ccx gate on tensor network");
2511 bool TNApplyCSwap(
void *obj,
unsigned int controlQubit,
2512 unsigned int targetQubit1,
unsigned int targetQubit2) {
2514 return fTNApplyCSwap(obj, controlQubit, targetQubit1, targetQubit2) == 1;
2516 throw std::runtime_error(
2517 "GpuLibrary: Unable to apply cswap gate on tensor network");
2522 void *CreateStabilizerSimulator(
long long int numQubits,
2523 long long int numShots,
2524 long long int numMeasurements,
2525 long long int numDetectors) {
2527 return fCreateStabilizerSimulator(numQubits, numShots, numMeasurements,
2530 throw std::runtime_error(
2531 "GpuLibrary: Unable to create stabilizer simulator");
2536 void DestroyStabilizerSimulator(
void *obj) {
2539 fDestroyStabilizerSimulator(obj);
2541 throw std::runtime_error(
2542 "GpuLibrary: Unable to destroy stabilizer simulator");
2545 bool ExecuteStabilizerCircuit(
void *obj,
const char *circuitStr,
2546 int randomizeMeasurements,
2547 unsigned long long int seed) {
2548 if (!obj)
return false;
2550 return fExecuteStabilizerCircuit(obj, circuitStr, randomizeMeasurements,
2553 throw std::runtime_error(
2554 "GpuLibrary: Unable to execute stabilizer circuit");
2559 long long GetStabilizerXZTableSize(
void *obj) {
2562 return fGetStabilizerXZTableSize(obj);
2564 throw std::runtime_error(
2565 "GpuLibrary: Unable to get stabilizer XZ table size");
2570 long long GetStabilizerMTableSize(
void *obj) {
2573 return fGetStabilizerMTableSize(obj);
2575 throw std::runtime_error(
2576 "GpuLibrary: Unable to get stabilizer M table size");
2581 long long GetStabilizerTableStrideMajor(
void *obj) {
2584 return fGetStabilizerTableStrideMajor(obj);
2586 throw std::runtime_error(
2587 "GpuLibrary: Unable to get stabilizer table stride major");
2591 long long GetStabilizerNumQubits(
void *obj) {
2594 return fGetStabilizerNumQubits(obj);
2596 throw std::runtime_error(
2597 "GpuLibrary: Unable to get stabilizer number of qubits");
2602 long long GetStabilizerNumShots(
void *obj) {
2605 return fGetStabilizerNumShots(obj);
2607 throw std::runtime_error(
2608 "GpuLibrary: Unable to get stabilizer number of shots");
2613 long long GetStabilizerNumMeasurements(
void *obj) {
2616 return fGetStabilizerNumMeasurements(obj);
2618 throw std::runtime_error(
2619 "GpuLibrary: Unable to get stabilizer number of measurements");
2624 long long GetStabilizerNumDetectors(
void *obj) {
2627 return fGetStabilizerNumDetectors(obj);
2629 throw std::runtime_error(
2630 "GpuLibrary: Unable to get stabilizer number of detectors");
2635 int CopyStabilizerXTable(
void *obj,
unsigned int *xtable) {
2638 return fCopyStabilizerXTable(obj, xtable);
2640 throw std::runtime_error(
"GpuLibrary: Unable to copy stabilizer X table");
2644 int CopyStabilizerZTable(
void *obj,
unsigned int *ztable) {
2647 return fCopyStabilizerZTable(obj, ztable);
2649 throw std::runtime_error(
"GpuLibrary: Unable to copy stabilizer Z table");
2653 int CopyStabilizerMTable(
void *obj,
unsigned int *mtable) {
2656 return fCopyStabilizerMTable(obj, mtable);
2658 throw std::runtime_error(
"GpuLibrary: Unable to copy stabilizer M table");
2662 int InitStabilizerXTable(
void *obj,
const unsigned int *xtable) {
2665 return fInitStabilizerXTable(obj, xtable);
2667 throw std::runtime_error(
2668 "GpuLibrary: Unable to initialize stabilizer X table");
2672 int InitStabilizerZTable(
void *obj,
const unsigned int *ztable) {
2675 return fInitStabilizerZTable(obj, ztable);
2677 throw std::runtime_error(
2678 "GpuLibrary: Unable to initialize stabilizer Z table");
2683 void *CreatePauliPropSimulator(
int nrQubits) {
2685 return fCreatePauliPropSimulator(nrQubits);
2687 throw std::runtime_error(
2688 "GpuLibrary: Unable to create pauli propagation simulator");
2692 void DestroyPauliPropSimulator(
void *obj) {
2695 fDestroyPauliPropSimulator(obj);
2697 throw std::runtime_error(
2698 "GpuLibrary: Unable to destroy pauli propagation simulator");
2701 int PauliPropGetNrQubits(
void *obj) {
2704 return fPauliPropGetNrQubits(obj);
2706 throw std::runtime_error(
2707 "GpuLibrary: Unable to get number of qubits in pauli propagation "
2712 int PauliPropSetWillUseSampling(
void *obj,
int willUseSampling) {
2715 return fPauliPropSetWillUseSampling(obj, willUseSampling) == 1;
2717 throw std::runtime_error(
2718 "GpuLibrary: Unable to set 'will use sampling' in pauli propagation "
2723 int PauliPropGetWillUseSampling(
void *obj) {
2726 return fPauliPropGetWillUseSampling(obj);
2728 throw std::runtime_error(
2729 "GpuLibrary: Unable to get 'will use sampling' in pauli propagation "
2734 double PauliPropGetCoefficientTruncationCutoff(
void *obj) {
2735 if (!obj)
return 0.0;
2737 return fPauliPropGetCoefficientTruncationCutoff(obj);
2739 throw std::runtime_error(
2740 "GpuLibrary: Unable to get coefficient truncation cutoff in pauli "
2741 "propagation simulator");
2745 void PauliPropSetCoefficientTruncationCutoff(
void *obj,
double cutoff) {
2748 fPauliPropSetCoefficientTruncationCutoff(obj, cutoff);
2750 throw std::runtime_error(
2751 "GpuLibrary: Unable to set coefficient truncation cutoff in pauli "
2752 "propagation simulator");
2755 double PauliPropGetWeightTruncationCutoff(
void *obj) {
2756 if (!obj)
return 0.0;
2758 return fPauliPropGetWeightTruncationCutoff(obj);
2760 throw std::runtime_error(
2761 "GpuLibrary: Unable to get weight truncation cutoff in pauli "
2762 "propagation simulator");
2766 void PauliPropSetWeightTruncationCutoff(
void *obj,
double cutoff) {
2769 fPauliPropSetWeightTruncationCutoff(obj, cutoff);
2771 throw std::runtime_error(
2772 "GpuLibrary: Unable to set weight truncation cutoff in pauli "
2773 "propagation simulator");
2776 int PauliPropGetNumGatesBetweenTruncations(
void *obj) {
2779 return fPauliPropGetNumGatesBetweenTruncations(obj);
2781 throw std::runtime_error(
2782 "GpuLibrary: Unable to get number of gates between truncations in "
2783 "pauli propagation simulator");
2787 void PauliPropSetNumGatesBetweenTruncations(
void *obj,
int numGates) {
2790 fPauliPropSetNumGatesBetweenTruncations(obj, numGates);
2792 throw std::runtime_error(
2793 "GpuLibrary: Unable to set number of gates between truncations in "
2795 "propagation simulator");
2798 int PauliPropGetNumGatesBetweenDeduplications(
void *obj) {
2801 return fPauliPropGetNumGatesBetweenDeduplications(obj);
2803 throw std::runtime_error(
2804 "GpuLibrary: Unable to get number of gates between deduplications in "
2805 "pauli propagation simulator");
2809 void PauliPropSetNumGatesBetweenDeduplications(
void *obj,
int numGates) {
2812 fPauliPropSetNumGatesBetweenDeduplications(obj, numGates);
2814 throw std::runtime_error(
2815 "GpuLibrary: Unable to set number of gates between deduplications in "
2817 "propagation simulator");
2820 bool PauliPropClearOperators(
void *obj) {
2821 if (!obj)
return false;
2823 return fPauliPropClearOperators(obj) == 1;
2825 throw std::runtime_error(
2826 "GpuLibrary: Unable to clear operators in pauli propagation "
2831 bool PauliPropAllocateMemory(
void *obj,
double percentage) {
2832 if (!obj)
return false;
2834 return fPauliPropAllocateMemory(obj, percentage) == 1;
2836 throw std::runtime_error(
2837 "GpuLibrary: Unable to allocate memory in pauli propagation "
2842 double PauliPropGetExpectationValue(
void *obj) {
2843 if (!obj)
return 0.0;
2845 return fPauliPropGetExpectationValue(obj);
2847 throw std::runtime_error(
2848 "GpuLibrary: Unable to get expectation value in pauli propagation "
2853 bool PauliPropExecute(
void *obj) {
2854 if (!obj)
return false;
2856 return fPauliPropExecute(obj) == 1;
2858 throw std::runtime_error(
2859 "GpuLibrary: Unable to execute pauli propagation simulator");
2863 bool PauliPropSetInPauliExpansionUnique(
void *obj,
const char *pauliString) {
2864 if (!obj)
return false;
2866 return fPauliPropSetInPauliExpansionUnique(obj, pauliString) == 1;
2868 throw std::runtime_error(
2869 "GpuLibrary: Unable to set unique pauli in pauli propagation "
2874 bool PauliPropSetInPauliExpansionMultiple(
void *obj,
2875 const char **pauliStrings,
2876 const double *coefficients,
2878 if (!obj)
return false;
2880 return fPauliPropSetInPauliExpansionMultiple(obj, pauliStrings,
2881 coefficients, nrPaulis) == 1;
2883 throw std::runtime_error(
2884 "GpuLibrary: Unable to set multiple pauli in pauli propagation "
2889 bool PauliPropApplyX(
void *obj,
int qubit) {
2890 if (!obj)
return false;
2892 return fPauliPropApplyX(obj, qubit) == 1;
2894 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate on mps");
2898 bool PauliPropApplyY(
void *obj,
int qubit) {
2899 if (!obj)
return false;
2901 return fPauliPropApplyY(obj, qubit) == 1;
2903 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate on mps");
2907 bool PauliPropApplyZ(
void *obj,
int qubit) {
2908 if (!obj)
return false;
2910 return fPauliPropApplyZ(obj, qubit) == 1;
2912 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate on mps");
2916 bool PauliPropApplyH(
void *obj,
int qubit) {
2917 if (!obj)
return false;
2919 return fPauliPropApplyH(obj, qubit) == 1;
2921 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate on mps");
2925 bool PauliPropApplyS(
void *obj,
int qubit) {
2926 if (!obj)
return false;
2928 return fPauliPropApplyS(obj, qubit) == 1;
2930 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate on mps");
2934 bool PauliPropApplySQRTX(
void *obj,
int qubit) {
2935 if (!obj)
return false;
2937 return fPauliPropApplySQRTX(obj, qubit) == 1;
2939 throw std::runtime_error(
"GpuLibrary: Unable to apply SQRTX gate on mps");
2943 bool PauliPropApplySQRTY(
void *obj,
int qubit) {
2944 if (!obj)
return false;
2946 return fPauliPropApplySQRTY(obj, qubit) == 1;
2948 throw std::runtime_error(
"GpuLibrary: Unable to apply SQRTY gate on mps");
2952 bool PauliPropApplySQRTZ(
void *obj,
int qubit) {
2953 if (!obj)
return false;
2955 return fPauliPropApplySQRTZ(obj, qubit) == 1;
2957 throw std::runtime_error(
"GpuLibrary: Unable to apply SQRTZ gate on mps");
2961 bool PauliPropApplyCX(
void *obj,
int targetQubit,
int controlQubit) {
2962 if (!obj)
return false;
2964 return fPauliPropApplyCX(obj, targetQubit, controlQubit) == 1;
2966 throw std::runtime_error(
"GpuLibrary: Unable to apply CX gate on mps");
2970 bool PauliPropApplyCY(
void *obj,
int targetQubit,
int controlQubit) {
2971 if (!obj)
return false;
2973 return fPauliPropApplyCY(obj, targetQubit, controlQubit) == 1;
2975 throw std::runtime_error(
"GpuLibrary: Unable to apply CY gate on mps");
2979 bool PauliPropApplyCZ(
void *obj,
int targetQubit,
int controlQubit) {
2980 if (!obj)
return false;
2982 return fPauliPropApplyCZ(obj, targetQubit, controlQubit) == 1;
2984 throw std::runtime_error(
"GpuLibrary: Unable to apply CZ gate on mps");
2988 bool PauliPropApplySWAP(
void *obj,
int qubit1,
int qubit2) {
2989 if (!obj)
return false;
2991 return fPauliPropApplySWAP(obj, qubit1, qubit2) == 1;
2993 throw std::runtime_error(
"GpuLibrary: Unable to apply SWAP gate on mps");
2997 bool PauliPropApplyISWAP(
void *obj,
int qubit1,
int qubit2) {
2998 if (!obj)
return false;
3000 return fPauliPropApplyISWAP(obj, qubit1, qubit2) == 1;
3002 throw std::runtime_error(
"GpuLibrary: Unable to apply ISWAP gate on mps");
3006 bool PauliPropApplyRX(
void *obj,
int qubit,
double angle) {
3007 if (!obj)
return false;
3009 return fPauliPropApplyRX(obj, qubit, angle) == 1;
3011 throw std::runtime_error(
"GpuLibrary: Unable to apply RX gate on mps");
3015 bool PauliPropApplyRY(
void *obj,
int qubit,
double angle) {
3016 if (!obj)
return false;
3018 return fPauliPropApplyRY(obj, qubit, angle) == 1;
3020 throw std::runtime_error(
"GpuLibrary: Unable to apply RY gate on mps");
3024 bool PauliPropApplyRZ(
void *obj,
int qubit,
double angle) {
3025 if (!obj)
return false;
3027 return fPauliPropApplyRZ(obj, qubit, angle) == 1;
3029 throw std::runtime_error(
"GpuLibrary: Unable to apply RZ gate on mps");
3033 bool PauliPropAddNoiseX(
void *obj,
int qubit,
double probability) {
3034 if (!obj)
return false;
3036 return fPauliPropAddNoiseX(obj, qubit, probability) == 1;
3038 throw std::runtime_error(
"GpuLibrary: Unable to add X noise on mps");
3042 bool PauliPropAddNoiseY(
void *obj,
int qubit,
double probability) {
3043 if (!obj)
return false;
3045 return fPauliPropAddNoiseY(obj, qubit, probability) == 1;
3047 throw std::runtime_error(
"GpuLibrary: Unable to add Y noise on mps");
3051 bool PauliPropAddNoiseZ(
void *obj,
int qubit,
double probability) {
3052 if (!obj)
return false;
3054 return fPauliPropAddNoiseZ(obj, qubit, probability) == 1;
3056 throw std::runtime_error(
"GpuLibrary: Unable to add Z noise on mps");
3060 bool PauliPropAddNoiseXYZ(
void *obj,
int qubit,
double probabilityX,
3061 double probabilityY,
double probabilityZ) {
3062 if (!obj)
return false;
3064 return fPauliPropAddNoiseXYZ(obj, qubit, probabilityX, probabilityY,
3067 throw std::runtime_error(
"GpuLibrary: Unable to add XYZ noise on mps");
3071 bool PauliPropAddAmplitudeDamping(
void *obj,
int qubit,
double dampingProb,
3072 double exciteProb) {
3073 if (!obj)
return false;
3075 return fPauliPropAddAmplitudeDamping(obj, qubit, dampingProb,
3078 throw std::runtime_error(
3079 "GpuLibrary: Unable to add amplitude damping on mps");
3083 double PauliPropQubitProbability0(
void *obj,
int qubit) {
3084 if (!obj)
return 0.0;
3086 return fPauliPropQubitProbability0(obj, qubit);
3088 throw std::runtime_error(
3089 "GpuLibrary: Unable to get qubit probability 0 in pauli propagation "
3094 double PauliPropProbability(
void *obj,
unsigned long long int outcome) {
3095 if (!obj)
return 0.0;
3097 return fPauliPropProbability(obj, outcome);
3099 throw std::runtime_error(
3100 "GpuLibrary: Unable to get probability of outcome in pauli "
3101 "propagation simulator");
3105 bool PauliPropMeasureQubit(
void *obj,
int qubit) {
3106 if (!obj)
return false;
3108 return fPauliPropMeasureQubit(obj, qubit) == 1;
3110 throw std::runtime_error(
3111 "GpuLibrary: Unable to measure qubit in pauli propagation simulator");
3115 unsigned char *PauliPropSampleQubits(
void *obj,
const int *qubits,
3117 if (!obj)
return nullptr;
3119 return fPauliPropSampleQubits(obj, qubits, nrQubits);
3121 throw std::runtime_error(
3122 "GpuLibrary: Unable to sample qubits in pauli propagation simulator");
3126 void PauliPropFreeSampledQubits(
unsigned char *samples) {
3127 if (!samples)
return;
3129 fPauliPropFreeSampledQubits(samples);
3131 throw std::runtime_error(
3132 "GpuLibrary: Unable to free sampled qubits in pauli propagation "
3136 void PauliPropSaveState(
void *obj) {
3139 fPauliPropSaveState(obj);
3141 throw std::runtime_error(
3142 "GpuLibrary: Unable to save state in pauli propagation simulator");
3145 void PauliPropRestoreState(
void *obj) {
3148 fPauliPropRestoreState(obj);
3150 throw std::runtime_error(
3151 "GpuLibrary: Unable to restore state in pauli propagation simulator");
3155 void *LibraryHandle =
nullptr;
3157 int (*fValidateLicense)(
const char *) =
nullptr;
3158 void *(*InitLib)() =
nullptr;
3159 void (*FreeLib)() =
nullptr;
3161 void *(*fCreateStateVector)(
void *) =
nullptr;
3162 void (*fDestroyStateVector)(
void *) =
nullptr;
3164 int (*fSetDataType)(
void *, int) =
nullptr;
3165 int (*fIsDoublePrecision)(
void *) =
nullptr;
3166 int (*fGetNrQubits)(
void *) =
nullptr;
3167 int (*fCreate)(
void *,
unsigned int) =
nullptr;
3168 int (*fReset)(
void *) =
nullptr;
3169 int (*fCreateWithState)(
void *,
unsigned int,
const double *) =
nullptr;
3170 int (*fMeasureQubitCollapse)(
void *, int) =
nullptr;
3171 int (*fMeasureQubitNoCollapse)(
void *, int) =
nullptr;
3172 int (*fMeasureQubitsCollapse)(
void *,
int *,
int *, int) =
nullptr;
3173 int (*fMeasureQubitsNoCollapse)(
void *,
int *,
int *, int) =
nullptr;
3174 unsigned long long (*fMeasureAllQubitsCollapse)(
void *) =
nullptr;
3175 unsigned long long (*fMeasureAllQubitsNoCollapse)(
void *) =
nullptr;
3177 int (*fSaveState)(
void *) =
nullptr;
3178 int (*fSaveStateToHost)(
void *) =
nullptr;
3179 int (*fSaveStateDestructive)(
void *) =
nullptr;
3180 int (*fRestoreStateFreeSaved)(
void *) =
nullptr;
3181 int (*fRestoreStateNoFreeSaved)(
void *) =
nullptr;
3182 void (*fFreeSavedState)(
void *obj) =
nullptr;
3183 void *(*fClone)(
void *) =
nullptr;
3184 int (*fSample)(
void *,
unsigned int,
long int *,
unsigned int,
3186 int (*fSampleAll)(
void *,
unsigned int,
long int *) =
nullptr;
3187 int (*fAmplitude)(
void *,
long long int,
double *,
double *) =
nullptr;
3188 double (*fProbability)(
void *,
int *,
int *, int) =
nullptr;
3189 double (*fBasisStateProbability)(
void *,
long long int) =
nullptr;
3190 int (*fAllProbabilities)(
void *,
double *) =
nullptr;
3191 double (*fExpectationValue)(
void *,
const char *, int) =
nullptr;
3193 int (*fApplyX)(
void *, int) =
nullptr;
3194 int (*fApplyY)(
void *, int) =
nullptr;
3195 int (*fApplyZ)(
void *, int) =
nullptr;
3196 int (*fApplyH)(
void *, int) =
nullptr;
3197 int (*fApplyS)(
void *, int) =
nullptr;
3198 int (*fApplySDG)(
void *, int) =
nullptr;
3199 int (*fApplyT)(
void *, int) =
nullptr;
3200 int (*fApplyTDG)(
void *, int) =
nullptr;
3201 int (*fApplySX)(
void *, int) =
nullptr;
3202 int (*fApplySXDG)(
void *, int) =
nullptr;
3203 int (*fApplyK)(
void *, int) =
nullptr;
3204 int (*fApplyP)(
void *, int, double) =
nullptr;
3205 int (*fApplyRx)(
void *, int, double) =
nullptr;
3206 int (*fApplyRy)(
void *, int, double) =
nullptr;
3207 int (*fApplyRz)(
void *, int, double) =
nullptr;
3208 int (*fApplyU)(
void *, int, double, double, double, double) =
nullptr;
3209 int (*fApplyCX)(
void *, int, int) =
nullptr;
3210 int (*fApplyCY)(
void *, int, int) =
nullptr;
3211 int (*fApplyCZ)(
void *, int, int) =
nullptr;
3212 int (*fApplyCH)(
void *, int, int) =
nullptr;
3213 int (*fApplyCSX)(
void *, int, int) =
nullptr;
3214 int (*fApplyCSXDG)(
void *, int, int) =
nullptr;
3215 int (*fApplyCP)(
void *, int, int, double) =
nullptr;
3216 int (*fApplyCRx)(
void *, int, int, double) =
nullptr;
3217 int (*fApplyCRy)(
void *, int, int, double) =
nullptr;
3218 int (*fApplyCRz)(
void *, int, int, double) =
nullptr;
3219 int (*fApplyCCX)(
void *, int, int, int) =
nullptr;
3220 int (*fApplySwap)(
void *, int, int) =
nullptr;
3221 int (*fApplyCSwap)(
void *, int, int, int) =
nullptr;
3222 int (*fApplyCU)(
void *, int, int, double, double, double, double) =
nullptr;
3224 void *(*fCreateMPS)(
void *) =
nullptr;
3225 void (*fDestroyMPS)(
void *) =
nullptr;
3227 int (*fMPSCreate)(
void *,
unsigned int) =
nullptr;
3228 int (*fMPSReset)(
void *) =
nullptr;
3229 int (*fMPSSetInitialQubitsMap)(
void *,
const long long int *,
3230 unsigned int) =
nullptr;
3231 int (*fMPSSetUseOptimalMeetingPosition)(
void *, int) =
nullptr;
3233 int (*fMPSIsValid)(
void *) =
nullptr;
3234 int (*fMPSIsCreated)(
void *) =
nullptr;
3236 int (*fMPSSetDataType)(
void *, int) =
nullptr;
3237 int (*fMPSIsDoublePrecision)(
void *) =
nullptr;
3238 int (*fMPSSetCutoff)(
void *, double) =
nullptr;
3239 double (*fMPSGetCutoff)(
void *) =
nullptr;
3240 int (*fMPSSetGesvdJ)(
void *, int) =
nullptr;
3241 int (*fMPSGetGesvdJ)(
void *) =
nullptr;
3242 int (*fMPSSetMaxExtent)(
void *,
long int) =
nullptr;
3243 long int (*fMPSGetMaxExtent)(
void *) =
nullptr;
3244 int (*fMPSGetNrQubits)(
void *) =
nullptr;
3245 int (*fMPSSetCallbackContext)(
void *,
void *) =
nullptr;
3246 int (*fMPSSetMeetingPositionCallback)(
void *, int64_t (*)(
void *,
const int64_t *)) =
nullptr;
3248 int (*fMPSAmplitude)(
void *,
long int,
long int *,
double *,
3249 double *) =
nullptr;
3250 double (*fMPSProbability0)(
void *,
unsigned int) =
nullptr;
3251 int (*fMPSMeasure)(
void *,
unsigned int) =
nullptr;
3252 int (*fMPSMeasureQubits)(
void *,
long int,
unsigned int *,
int *) =
nullptr;
3253 void *(*fMPSGetMapForSample)() =
nullptr;
3254 int (*fMPSFreeMapForSample)(
void *) =
nullptr;
3255 int (*fMPSSample)(
void *,
long int,
long int,
unsigned int *,
3258 int (*fMPSSaveState)(
void *) =
nullptr;
3259 int (*fMPSRestoreState)(
void *) =
nullptr;
3260 int (*fMPSCleanSavedState)(
void *) =
nullptr;
3261 void *(*fMPSClone)(
void *) =
nullptr;
3263 double (*fMPSExpectationValue)(
void *,
const char *, int) =
nullptr;
3264 int (*fMPSProjectOnZero)(
void *,
double *,
double *) =
nullptr;
3266 int (*fMPSApplyX)(
void *,
unsigned int) =
nullptr;
3267 int (*fMPSApplyY)(
void *,
unsigned int) =
nullptr;
3268 int (*fMPSApplyZ)(
void *,
unsigned int) =
nullptr;
3269 int (*fMPSApplyH)(
void *,
unsigned int) =
nullptr;
3270 int (*fMPSApplyS)(
void *,
unsigned int) =
nullptr;
3271 int (*fMPSApplySDG)(
void *,
unsigned int) =
nullptr;
3272 int (*fMPSApplyT)(
void *,
unsigned int) =
nullptr;
3273 int (*fMPSApplyTDG)(
void *,
unsigned int) =
nullptr;
3274 int (*fMPSApplySX)(
void *,
unsigned int) =
nullptr;
3275 int (*fMPSApplySXDG)(
void *,
unsigned int) =
nullptr;
3276 int (*fMPSApplyK)(
void *,
unsigned int) =
nullptr;
3277 int (*fMPSApplyP)(
void *,
unsigned int, double) =
nullptr;
3278 int (*fMPSApplyRx)(
void *,
unsigned int, double) =
nullptr;
3279 int (*fMPSApplyRy)(
void *,
unsigned int, double) =
nullptr;
3280 int (*fMPSApplyRz)(
void *,
unsigned int, double) =
nullptr;
3281 int (*fMPSApplyU)(
void *,
unsigned int, double, double, double,
3283 int (*fMPSApplySwap)(
void *,
unsigned int,
unsigned int) =
nullptr;
3284 int (*fMPSApplyCX)(
void *,
unsigned int,
unsigned int) =
nullptr;
3285 int (*fMPSApplyCY)(
void *,
unsigned int,
unsigned int) =
nullptr;
3286 int (*fMPSApplyCZ)(
void *,
unsigned int,
unsigned int) =
nullptr;
3287 int (*fMPSApplyCH)(
void *,
unsigned int,
unsigned int) =
nullptr;
3288 int (*fMPSApplyCSX)(
void *,
unsigned int,
unsigned int) =
nullptr;
3289 int (*fMPSApplyCSXDG)(
void *,
unsigned int,
unsigned int) =
nullptr;
3290 int (*fMPSApplyCP)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3291 int (*fMPSApplyCRx)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3292 int (*fMPSApplyCRy)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3293 int (*fMPSApplyCRz)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3294 int (*fMPSApplyCU)(
void *,
unsigned int,
unsigned int, double, double, double,
3298 void *(*fCreateTensorNet)(
void *) =
nullptr;
3299 void (*fDestroyTensorNet)(
void *) =
nullptr;
3301 int (*fTNCreate)(
void *,
unsigned int) =
nullptr;
3302 int (*fTNReset)(
void *) =
nullptr;
3303 int (*fTNIsValid)(
void *) =
nullptr;
3304 int (*fTNIsCreated)(
void *) =
nullptr;
3306 int (*fTNSetDataType)(
void *, int) =
nullptr;
3307 int (*fTNIsDoublePrecision)(
void *) =
nullptr;
3308 int (*fTNSetCutoff)(
void *, double) =
nullptr;
3309 double (*fTNGetCutoff)(
void *) =
nullptr;
3310 int (*fTNSetGesvdJ)(
void *, int) =
nullptr;
3311 int (*fTNGetGesvdJ)(
void *) =
nullptr;
3312 int (*fTNSetMaxExtent)(
void *,
long int) =
nullptr;
3313 long int (*fTNGetMaxExtent)(
void *) =
nullptr;
3314 int (*fTNGetNrQubits)(
void *) =
nullptr;
3315 int (*fTNAmplitude)(
void *,
long int,
long int *,
double *,
3316 double *) =
nullptr;
3317 double (*fTNProbability0)(
void *,
unsigned int) =
nullptr;
3318 int (*fTNMeasure)(
void *,
unsigned int) =
nullptr;
3319 int (*fTNMeasureQubits)(
void *,
long int,
unsigned int *,
int *) =
nullptr;
3320 void *(*fTNGetMapForSample)() =
nullptr;
3321 int (*fTNFreeMapForSample)(
void *) =
nullptr;
3322 int (*fTNSample)(
void *,
long int,
long int,
unsigned int *,
3325 int (*fTNSaveState)(
void *) =
nullptr;
3326 int (*fTNRestoreState)(
void *) =
nullptr;
3327 int (*fTNCleanSavedState)(
void *) =
nullptr;
3328 void *(*fTNClone)(
void *) =
nullptr;
3330 double (*fTNExpectationValue)(
void *,
const char *, int) =
nullptr;
3332 int (*fTNApplyX)(
void *,
unsigned int) =
nullptr;
3333 int (*fTNApplyY)(
void *,
unsigned int) =
nullptr;
3334 int (*fTNApplyZ)(
void *,
unsigned int) =
nullptr;
3335 int (*fTNApplyH)(
void *,
unsigned int) =
nullptr;
3336 int (*fTNApplyS)(
void *,
unsigned int) =
nullptr;
3337 int (*fTNApplySDG)(
void *,
unsigned int) =
nullptr;
3338 int (*fTNApplyT)(
void *,
unsigned int) =
nullptr;
3339 int (*fTNApplyTDG)(
void *,
unsigned int) =
nullptr;
3340 int (*fTNApplySX)(
void *,
unsigned int) =
nullptr;
3341 int (*fTNApplySXDG)(
void *,
unsigned int) =
nullptr;
3342 int (*fTNApplyK)(
void *,
unsigned int) =
nullptr;
3343 int (*fTNApplyP)(
void *,
unsigned int, double) =
nullptr;
3344 int (*fTNApplyRx)(
void *,
unsigned int, double) =
nullptr;
3345 int (*fTNApplyRy)(
void *,
unsigned int, double) =
nullptr;
3346 int (*fTNApplyRz)(
void *,
unsigned int, double) =
nullptr;
3347 int (*fTNApplyU)(
void *,
unsigned int, double, double, double,
3349 int (*fTNApplySwap)(
void *,
unsigned int,
unsigned int) =
nullptr;
3350 int (*fTNApplyCX)(
void *,
unsigned int,
unsigned int) =
nullptr;
3351 int (*fTNApplyCY)(
void *,
unsigned int,
unsigned int) =
nullptr;
3352 int (*fTNApplyCZ)(
void *,
unsigned int,
unsigned int) =
nullptr;
3353 int (*fTNApplyCH)(
void *,
unsigned int,
unsigned int) =
nullptr;
3354 int (*fTNApplyCSX)(
void *,
unsigned int,
unsigned int) =
nullptr;
3355 int (*fTNApplyCSXDG)(
void *,
unsigned int,
unsigned int) =
nullptr;
3356 int (*fTNApplyCP)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3357 int (*fTNApplyCRx)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3358 int (*fTNApplyCRy)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3359 int (*fTNApplyCRz)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3360 int (*fTNApplyCU)(
void *,
unsigned int,
unsigned int, double, double, double,
3362 int (*fTNApplyCCX)(
void *,
unsigned int,
unsigned int,
3363 unsigned int) =
nullptr;
3364 int (*fTNApplyCSwap)(
void *,
unsigned int,
unsigned int,
3365 unsigned int) =
nullptr;
3367 void *(*fCreateStabilizerSimulator)(
long long int,
long long int,
3368 long long int,
long long int) =
nullptr;
3369 void (*fDestroyStabilizerSimulator)(
void *) =
nullptr;
3370 int (*fExecuteStabilizerCircuit)(
void *,
const char *, int,
3371 unsigned long long int) =
nullptr;
3372 long long (*fGetStabilizerXZTableSize)(
void *) =
nullptr;
3373 long long (*fGetStabilizerMTableSize)(
void *) =
nullptr;
3374 long long (*fGetStabilizerTableStrideMajor)(
void *) =
nullptr;
3375 long long (*fGetStabilizerNumQubits)(
void *) =
nullptr;
3376 long long (*fGetStabilizerNumShots)(
void *) =
nullptr;
3377 long long (*fGetStabilizerNumMeasurements)(
void *) =
nullptr;
3378 long long (*fGetStabilizerNumDetectors)(
void *) =
nullptr;
3379 int (*fCopyStabilizerXTable)(
void *,
unsigned int *) =
nullptr;
3380 int (*fCopyStabilizerZTable)(
void *,
unsigned int *) =
nullptr;
3381 int (*fCopyStabilizerMTable)(
void *,
unsigned int *) =
nullptr;
3382 int (*fInitStabilizerXTable)(
void *,
const unsigned int *) =
nullptr;
3383 int (*fInitStabilizerZTable)(
void *,
const unsigned int *) =
nullptr;
3385 void *(*fCreatePauliPropSimulator)(int) =
nullptr;
3386 void (*fDestroyPauliPropSimulator)(
void *) =
nullptr;
3388 int (*fPauliPropGetNrQubits)(
void *) =
nullptr;
3389 int (*fPauliPropSetWillUseSampling)(
void *, int) =
nullptr;
3390 int (*fPauliPropGetWillUseSampling)(
void *) =
nullptr;
3391 double (*fPauliPropGetCoefficientTruncationCutoff)(
void *) =
nullptr;
3392 void (*fPauliPropSetCoefficientTruncationCutoff)(
void *, double) =
nullptr;
3393 double (*fPauliPropGetWeightTruncationCutoff)(
void *) =
nullptr;
3394 void (*fPauliPropSetWeightTruncationCutoff)(
void *, double) =
nullptr;
3395 int (*fPauliPropGetNumGatesBetweenTruncations)(
void *) =
nullptr;
3396 void (*fPauliPropSetNumGatesBetweenTruncations)(
void *, int) =
nullptr;
3397 int (*fPauliPropGetNumGatesBetweenDeduplications)(
void *) =
nullptr;
3398 void (*fPauliPropSetNumGatesBetweenDeduplications)(
void *, int) =
nullptr;
3399 int (*fPauliPropClearOperators)(
void *) =
nullptr;
3400 int (*fPauliPropAllocateMemory)(
void *, double) =
nullptr;
3401 double (*fPauliPropGetExpectationValue)(
void *) =
nullptr;
3402 int (*fPauliPropExecute)(
void *) =
nullptr;
3403 int (*fPauliPropSetInPauliExpansionUnique)(
void *,
const char *) =
nullptr;
3404 int (*fPauliPropSetInPauliExpansionMultiple)(
void *,
const char **,
3405 const double *, int) =
nullptr;
3407 int (*fPauliPropApplyX)(
void *, int) =
nullptr;
3408 int (*fPauliPropApplyY)(
void *, int) =
nullptr;
3409 int (*fPauliPropApplyZ)(
void *, int) =
nullptr;
3410 int (*fPauliPropApplyH)(
void *, int) =
nullptr;
3411 int (*fPauliPropApplyS)(
void *, int) =
nullptr;
3412 int (*fPauliPropApplySQRTX)(
void *, int) =
nullptr;
3413 int (*fPauliPropApplySQRTY)(
void *, int) =
nullptr;
3414 int (*fPauliPropApplySQRTZ)(
void *, int) =
nullptr;
3415 int (*fPauliPropApplyCX)(
void *, int, int) =
nullptr;
3416 int (*fPauliPropApplyCY)(
void *, int, int) =
nullptr;
3417 int (*fPauliPropApplyCZ)(
void *, int, int) =
nullptr;
3418 int (*fPauliPropApplySWAP)(
void *, int, int) =
nullptr;
3419 int (*fPauliPropApplyISWAP)(
void *, int, int) =
nullptr;
3420 int (*fPauliPropApplyRX)(
void *, int, double) =
nullptr;
3421 int (*fPauliPropApplyRY)(
void *, int, double) =
nullptr;
3422 int (*fPauliPropApplyRZ)(
void *, int, double) =
nullptr;
3423 int (*fPauliPropAddNoiseX)(
void *, int, double) =
nullptr;
3424 int (*fPauliPropAddNoiseY)(
void *, int, double) =
nullptr;
3425 int (*fPauliPropAddNoiseZ)(
void *, int, double) =
nullptr;
3426 int (*fPauliPropAddNoiseXYZ)(
void *, int, double, double, double) =
nullptr;
3427 int (*fPauliPropAddAmplitudeDamping)(
void *, int, double, double) =
nullptr;
3428 double (*fPauliPropQubitProbability0)(
void *, int) =
nullptr;
3429 double (*fPauliPropProbability)(
void *,
unsigned long long int) =
nullptr;
3431 int (*fPauliPropMeasureQubit)(
void *, int) =
nullptr;
3432 unsigned char *(*fPauliPropSampleQubits)(
void *,
const int *, int) =
nullptr;
3433 void (*fPauliPropFreeSampledQubits)(
unsigned char *) =
nullptr;
3434 void (*fPauliPropSaveState)(
void *) =
nullptr;
3435 void (*fPauliPropRestoreState)(
void *) =
nullptr;
int ApplyK(void *sim, int qubit)
double Probability(void *sim, unsigned long long int outcome)
int ApplyRx(void *sim, int qubit, double theta)
int ApplyX(void *sim, int qubit)
int ApplyU(void *sim, int qubit, double theta, double phi, double lambda, double gamma)
int ApplyCRy(void *sim, int controlQubit, int targetQubit, double theta)
int ApplyTDG(void *sim, int qubit)
int ApplyCSXDG(void *sim, int controlQubit, int targetQubit)
int ApplyS(void *sim, int qubit)
int ApplyCX(void *sim, int controlQubit, int targetQubit)
int ApplyCRz(void *sim, int controlQubit, int targetQubit, double theta)
double * AllProbabilities(void *sim)
int ApplyCP(void *sim, int controlQubit, int targetQubit, double theta)
int ApplySXDG(void *sim, int qubit)
int ApplySDG(void *sim, int qubit)
int ApplyCSwap(void *sim, int controlQubit, int qubit1, int qubit2)
int ApplyCCX(void *sim, int controlQubit1, int controlQubit2, int targetQubit)
int ApplyY(void *sim, int qubit)
double * Amplitude(void *sim, unsigned long long int outcome)
int ApplyZ(void *sim, int qubit)
int ApplyH(void *sim, int qubit)
int ApplyCY(void *sim, int controlQubit, int targetQubit)
int ApplyCU(void *sim, int controlQubit, int targetQubit, double theta, double phi, double lambda, double gamma)
int ApplySwap(void *sim, int qubit1, int qubit2)
int ApplyRy(void *sim, int qubit, double theta)
int ApplyP(void *sim, int qubit, double theta)
int ApplyCH(void *sim, int controlQubit, int targetQubit)
int ApplySX(void *sim, int qubit)
int ApplyCZ(void *sim, int controlQubit, int targetQubit)
int ApplyRz(void *sim, int qubit, double theta)
int ApplyT(void *sim, int qubit)
int ApplyCRx(void *sim, int controlQubit, int targetQubit, double theta)
int ApplyCSX(void *sim, int controlQubit, int targetQubit)
virtual bool Init(const char *libName) noexcept
bool IsMuted() const noexcept