46#include "../Utils/Library.h"
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 fMPSAmplitude = (int (*)(
void *,
long int,
long int *,
double *,
305 double *))GetFunction(
"MPSAmplitude");
306 CheckFunction((
void *)fMPSAmplitude, __LINE__);
308 (double (*)(
void *,
unsigned int))GetFunction(
"MPSProbability0");
309 CheckFunction((
void *)fMPSProbability0, __LINE__);
311 (int (*)(
void *,
unsigned int))GetFunction(
"MPSMeasure");
312 CheckFunction((
void *)fMPSMeasure, __LINE__);
313 fMPSMeasureQubits = (int (*)(
void *,
long int,
unsigned int *,
314 int *))GetFunction(
"MPSMeasureQubits");
315 CheckFunction((
void *)fMPSMeasureQubits, __LINE__);
317 fMPSGetMapForSample = (
void *(*)())GetFunction(
"MPSGetMapForSample");
318 CheckFunction((
void *)fMPSGetMapForSample, __LINE__);
319 fMPSFreeMapForSample =
320 (int (*)(
void *))GetFunction(
"MPSFreeMapForSample");
321 CheckFunction((
void *)fMPSFreeMapForSample, __LINE__);
322 fMPSSample = (int (*)(
void *,
long int,
long int,
unsigned int *,
323 void *))GetFunction(
"MPSSample");
324 CheckFunction((
void *)fMPSSample, __LINE__);
326 fMPSSaveState = (int (*)(
void *))GetFunction(
"MPSSaveState");
327 CheckFunction((
void *)fMPSSaveState, __LINE__);
328 fMPSRestoreState = (int (*)(
void *))GetFunction(
"MPSRestoreState");
329 CheckFunction((
void *)fMPSRestoreState, __LINE__);
330 fMPSCleanSavedState =
331 (int (*)(
void *))GetFunction(
"MPSCleanSavedState");
332 CheckFunction((
void *)fMPSCleanSavedState, __LINE__);
333 fMPSClone = (
void *(*)(
void *))GetFunction(
"MPSClone");
334 CheckFunction((
void *)fMPSClone, __LINE__);
336 fMPSExpectationValue = (double (*)(
337 void *,
const char *, int))GetFunction(
"MPSExpectationValue");
338 CheckFunction((
void *)fMPSExpectationValue, __LINE__);
340 (int (*)(
void *,
double *,
double *))GetFunction(
"MPSProjectOnZero");
341 CheckFunction((
void *)fMPSProjectOnZero, __LINE__);
343 fMPSApplyX = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyX");
344 CheckFunction((
void *)fMPSApplyX, __LINE__);
345 fMPSApplyY = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyY");
346 CheckFunction((
void *)fMPSApplyY, __LINE__);
347 fMPSApplyZ = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyZ");
348 CheckFunction((
void *)fMPSApplyZ, __LINE__);
349 fMPSApplyH = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyH");
350 CheckFunction((
void *)fMPSApplyH, __LINE__);
351 fMPSApplyS = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyS");
352 CheckFunction((
void *)fMPSApplyS, __LINE__);
354 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySDG");
355 CheckFunction((
void *)fMPSApplySDG, __LINE__);
356 fMPSApplyT = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyT");
357 CheckFunction((
void *)fMPSApplyT, __LINE__);
359 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyTDG");
360 CheckFunction((
void *)fMPSApplyTDG, __LINE__);
362 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySX");
363 CheckFunction((
void *)fMPSApplySX, __LINE__);
365 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySXDG");
366 CheckFunction((
void *)fMPSApplySXDG, __LINE__);
367 fMPSApplyK = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyK");
368 CheckFunction((
void *)fMPSApplyK, __LINE__);
370 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyP");
371 CheckFunction((
void *)fMPSApplyP, __LINE__);
373 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRx");
374 CheckFunction((
void *)fMPSApplyRx, __LINE__);
376 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRy");
377 CheckFunction((
void *)fMPSApplyRy, __LINE__);
379 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRz");
380 CheckFunction((
void *)fMPSApplyRz, __LINE__);
381 fMPSApplyU = (int (*)(
void *,
unsigned int, double, double, double,
382 double))GetFunction(
"MPSApplyU");
383 CheckFunction((
void *)fMPSApplyU, __LINE__);
384 fMPSApplySwap = (int (*)(
void *,
unsigned int,
385 unsigned int))GetFunction(
"MPSApplySwap");
386 CheckFunction((
void *)fMPSApplySwap, __LINE__);
387 fMPSApplyCX = (int (*)(
void *,
unsigned int,
388 unsigned int))GetFunction(
"MPSApplyCX");
389 CheckFunction((
void *)fMPSApplyCX, __LINE__);
390 fMPSApplyCY = (int (*)(
void *,
unsigned int,
391 unsigned int))GetFunction(
"MPSApplyCY");
392 CheckFunction((
void *)fMPSApplyCY, __LINE__);
393 fMPSApplyCZ = (int (*)(
void *,
unsigned int,
394 unsigned int))GetFunction(
"MPSApplyCZ");
395 CheckFunction((
void *)fMPSApplyCZ, __LINE__);
396 fMPSApplyCH = (int (*)(
void *,
unsigned int,
397 unsigned int))GetFunction(
"MPSApplyCH");
398 CheckFunction((
void *)fMPSApplyCH, __LINE__);
399 fMPSApplyCSX = (int (*)(
void *,
unsigned int,
400 unsigned int))GetFunction(
"MPSApplyCSX");
401 CheckFunction((
void *)fMPSApplyCSX, __LINE__);
402 fMPSApplyCSXDG = (int (*)(
void *,
unsigned int,
403 unsigned int))GetFunction(
"MPSApplyCSXDG");
404 CheckFunction((
void *)fMPSApplyCSXDG, __LINE__);
405 fMPSApplyCP = (int (*)(
void *,
unsigned int,
unsigned int,
406 double))GetFunction(
"MPSApplyCP");
407 CheckFunction((
void *)fMPSApplyCP, __LINE__);
408 fMPSApplyCRx = (int (*)(
void *,
unsigned int,
unsigned int,
409 double))GetFunction(
"MPSApplyCRx");
410 CheckFunction((
void *)fMPSApplyCRx, __LINE__);
411 fMPSApplyCRy = (int (*)(
void *,
unsigned int,
unsigned int,
412 double))GetFunction(
"MPSApplyCRy");
413 CheckFunction((
void *)fMPSApplyCRy, __LINE__);
414 fMPSApplyCRz = (int (*)(
void *,
unsigned int,
unsigned int,
415 double))GetFunction(
"MPSApplyCRz");
416 CheckFunction((
void *)fMPSApplyCRz, __LINE__);
418 (int (*)(
void *,
unsigned int,
unsigned int, double, double,
419 double, double))GetFunction(
"MPSApplyCU");
420 CheckFunction((
void *)fMPSApplyCU, __LINE__);
424 fCreateTensorNet = (
void *(*)(
void *))GetFunction(
"CreateTensorNet");
425 CheckFunction((
void *)fCreateTensorNet, __LINE__);
426 fDestroyTensorNet = (void (*)(
void *))GetFunction(
"DestroyTensorNet");
427 CheckFunction((
void *)fDestroyTensorNet, __LINE__);
429 fTNCreate = (int (*)(
void *,
unsigned int))GetFunction(
"TNCreate");
430 CheckFunction((
void *)fTNCreate, __LINE__);
431 fTNReset = (int (*)(
void *))GetFunction(
"TNReset");
432 CheckFunction((
void *)fTNReset, __LINE__);
434 fTNIsValid = (int (*)(
void *))GetFunction(
"TNIsValid");
435 CheckFunction((
void *)fTNIsValid, __LINE__);
436 fTNIsCreated = (int (*)(
void *))GetFunction(
"TNIsCreated");
437 CheckFunction((
void *)fTNIsCreated, __LINE__);
439 fTNSetDataType = (int (*)(
void *, int))GetFunction(
"TNSetDataType");
440 CheckFunction((
void *)fTNSetDataType, __LINE__);
441 fTNIsDoublePrecision =
442 (int (*)(
void *))GetFunction(
"TNIsDoublePrecision");
443 CheckFunction((
void *)fTNIsDoublePrecision, __LINE__);
444 fTNSetCutoff = (int (*)(
void *, double))GetFunction(
"TNSetCutoff");
445 CheckFunction((
void *)fTNSetCutoff, __LINE__);
446 fTNGetCutoff = (double (*)(
void *))GetFunction(
"TNGetCutoff");
447 CheckFunction((
void *)fTNGetCutoff, __LINE__);
448 fTNSetGesvdJ = (int (*)(
void *, int))GetFunction(
"TNSetGesvdJ");
449 CheckFunction((
void *)fTNSetGesvdJ, __LINE__);
450 fTNGetGesvdJ = (int (*)(
void *))GetFunction(
"TNGetGesvdJ");
451 CheckFunction((
void *)fTNGetGesvdJ, __LINE__);
453 (int (*)(
void *,
long int))GetFunction(
"TNSetMaxExtent");
454 CheckFunction((
void *)fTNSetMaxExtent, __LINE__);
455 fTNGetMaxExtent = (
long int (*)(
void *))GetFunction(
"TNGetMaxExtent");
456 CheckFunction((
void *)fTNGetMaxExtent, __LINE__);
457 fTNGetNrQubits = (int (*)(
void *))GetFunction(
"TNGetNrQubits");
458 CheckFunction((
void *)fTNGetNrQubits, __LINE__);
459 fTNAmplitude = (int (*)(
void *,
long int,
long int *,
double *,
460 double *))GetFunction(
"TNAmplitude");
461 CheckFunction((
void *)fTNAmplitude, __LINE__);
463 (double (*)(
void *,
unsigned int))GetFunction(
"TNProbability0");
464 CheckFunction((
void *)fTNProbability0, __LINE__);
465 fTNMeasure = (int (*)(
void *,
unsigned int))GetFunction(
"TNMeasure");
466 CheckFunction((
void *)fTNMeasure, __LINE__);
467 fTNMeasureQubits = (int (*)(
void *,
long int,
unsigned int *,
468 int *))GetFunction(
"TNMeasureQubits");
469 CheckFunction((
void *)fTNMeasureQubits, __LINE__);
471 fTNGetMapForSample = (
void *(*)())GetFunction(
"TNGetMapForSample");
472 CheckFunction((
void *)fTNGetMapForSample, __LINE__);
473 fTNFreeMapForSample =
474 (int (*)(
void *))GetFunction(
"TNFreeMapForSample");
475 CheckFunction((
void *)fTNFreeMapForSample, __LINE__);
476 fTNSample = (int (*)(
void *,
long int,
long int,
unsigned int *,
477 void *))GetFunction(
"TNSample");
478 CheckFunction((
void *)fTNSample, __LINE__);
480 fTNSaveState = (int (*)(
void *))GetFunction(
"TNSaveState");
481 CheckFunction((
void *)fTNSaveState, __LINE__);
482 fTNRestoreState = (int (*)(
void *))GetFunction(
"TNRestoreState");
483 CheckFunction((
void *)fTNRestoreState, __LINE__);
485 (int (*)(
void *))GetFunction(
"TNCleanSavedState");
486 CheckFunction((
void *)fTNCleanSavedState, __LINE__);
487 fTNClone = (
void *(*)(
void *))GetFunction(
"TNClone");
488 CheckFunction((
void *)fTNClone, __LINE__);
490 fTNExpectationValue = (double (*)(
491 void *,
const char *, int))GetFunction(
"TNExpectationValue");
492 CheckFunction((
void *)fTNExpectationValue, __LINE__);
494 fTNApplyX = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyX");
495 CheckFunction((
void *)fTNApplyX, __LINE__);
496 fTNApplyY = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyY");
497 CheckFunction((
void *)fTNApplyY, __LINE__);
498 fTNApplyZ = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyZ");
499 CheckFunction((
void *)fTNApplyZ, __LINE__);
500 fTNApplyH = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyH");
501 CheckFunction((
void *)fTNApplyH, __LINE__);
502 fTNApplyS = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyS");
503 CheckFunction((
void *)fTNApplyS, __LINE__);
505 (int (*)(
void *,
unsigned int))GetFunction(
"TNApplySDG");
506 CheckFunction((
void *)fTNApplySDG, __LINE__);
507 fTNApplyT = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyT");
508 CheckFunction((
void *)fTNApplyT, __LINE__);
510 (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyTDG");
511 CheckFunction((
void *)fTNApplyTDG, __LINE__);
512 fTNApplySX = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplySX");
513 CheckFunction((
void *)fTNApplySX, __LINE__);
515 (int (*)(
void *,
unsigned int))GetFunction(
"TNApplySXDG");
516 CheckFunction((
void *)fTNApplySXDG, __LINE__);
517 fTNApplyK = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyK");
518 CheckFunction((
void *)fTNApplyK, __LINE__);
520 (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyP");
521 CheckFunction((
void *)fTNApplyP, __LINE__);
523 (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyRx");
524 CheckFunction((
void *)fTNApplyRx, __LINE__);
526 (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyRy");
527 CheckFunction((
void *)fTNApplyRy, __LINE__);
529 (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyRz");
530 CheckFunction((
void *)fTNApplyRz, __LINE__);
531 fTNApplyU = (int (*)(
void *,
unsigned int, double, double, double,
532 double))GetFunction(
"TNApplyU");
533 CheckFunction((
void *)fTNApplyU, __LINE__);
534 fTNApplySwap = (int (*)(
void *,
unsigned int,
535 unsigned int))GetFunction(
"TNApplySwap");
536 CheckFunction((
void *)fTNApplySwap, __LINE__);
537 fTNApplyCX = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
539 CheckFunction((
void *)fTNApplyCX, __LINE__);
540 fTNApplyCY = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
542 CheckFunction((
void *)fTNApplyCY, __LINE__);
543 fTNApplyCZ = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
545 CheckFunction((
void *)fTNApplyCZ, __LINE__);
546 fTNApplyCH = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
548 CheckFunction((
void *)fTNApplyCH, __LINE__);
549 fTNApplyCSX = (int (*)(
void *,
unsigned int,
550 unsigned int))GetFunction(
"TNApplyCSX");
551 CheckFunction((
void *)fTNApplyCSX, __LINE__);
552 fTNApplyCSXDG = (int (*)(
void *,
unsigned int,
553 unsigned int))GetFunction(
"TNApplyCSXDG");
554 CheckFunction((
void *)fTNApplyCSXDG, __LINE__);
555 fTNApplyCP = (int (*)(
void *,
unsigned int,
unsigned int,
556 double))GetFunction(
"TNApplyCP");
557 CheckFunction((
void *)fTNApplyCP, __LINE__);
558 fTNApplyCRx = (int (*)(
void *,
unsigned int,
unsigned int,
559 double))GetFunction(
"TNApplyCRx");
560 CheckFunction((
void *)fTNApplyCRx, __LINE__);
561 fTNApplyCRy = (int (*)(
void *,
unsigned int,
unsigned int,
562 double))GetFunction(
"TNApplyCRy");
563 CheckFunction((
void *)fTNApplyCRy, __LINE__);
564 fTNApplyCRz = (int (*)(
void *,
unsigned int,
unsigned int,
565 double))GetFunction(
"TNApplyCRz");
566 CheckFunction((
void *)fTNApplyCRz, __LINE__);
568 (int (*)(
void *,
unsigned int,
unsigned int, double, double,
569 double, double))GetFunction(
"TNApplyCU");
570 CheckFunction((
void *)fTNApplyCU, __LINE__);
572 fTNApplyCCX = (int (*)(
void *,
unsigned int,
unsigned int,
573 unsigned int))GetFunction(
"TNApplyCCX");
574 CheckFunction((
void *)fTNApplyCCX, __LINE__);
575 fTNApplyCSwap = (int (*)(
void *,
unsigned int,
unsigned int,
576 unsigned int))GetFunction(
"TNApplyCSwap");
577 CheckFunction((
void *)fTNApplyCSwap, __LINE__);
580 fCreateStabilizerSimulator = (
void *(*)(
long long int,
long long int,
581 long long int,
long long int))
582 GetFunction(
"CreateStabilizerSimulator");
583 CheckFunction((
void *)fCreateStabilizerSimulator, __LINE__);
584 fDestroyStabilizerSimulator =
585 (void (*)(
void *))GetFunction(
"DestroyStabilizerSimulator");
586 CheckFunction((
void *)fDestroyStabilizerSimulator, __LINE__);
587 fExecuteStabilizerCircuit = (int (*)(
588 void *,
const char *, int,
589 unsigned long long int))GetFunction(
"ExecuteStabilizerCircuit");
590 CheckFunction((
void *)fExecuteStabilizerCircuit, __LINE__);
591 fGetStabilizerXZTableSize =
592 (
long long (*)(
void *))GetFunction(
"GetStabilizerXZTableSize");
593 CheckFunction((
void *)fGetStabilizerXZTableSize, __LINE__);
594 fGetStabilizerMTableSize =
595 (
long long (*)(
void *))GetFunction(
"GetStabilizerMTableSize");
596 CheckFunction((
void *)fGetStabilizerMTableSize, __LINE__);
598 fGetStabilizerTableStrideMajor = (
long long (*)(
void *))GetFunction(
599 "GetStabilizerTableStrideMajor");
600 CheckFunction((
void *)fGetStabilizerTableStrideMajor, __LINE__);
602 fGetStabilizerNumQubits =
603 (
long long (*)(
void *))GetFunction(
"GetStabilizerNumQubits");
604 CheckFunction((
void *)fGetStabilizerNumQubits, __LINE__);
605 fGetStabilizerNumShots =
606 (
long long (*)(
void *))GetFunction(
"GetStabilizerNumShots");
607 CheckFunction((
void *)fGetStabilizerNumShots, __LINE__);
608 fGetStabilizerNumMeasurements = (
long long (*)(
void *))GetFunction(
609 "GetStabilizerNumMeasurements");
610 CheckFunction((
void *)fGetStabilizerNumMeasurements, __LINE__);
611 fGetStabilizerNumDetectors =
612 (
long long (*)(
void *))GetFunction(
"GetStabilizerNumDetectors");
613 CheckFunction((
void *)fGetStabilizerNumDetectors, __LINE__);
614 fCopyStabilizerXTable = (int (*)(
void *,
unsigned int *))GetFunction(
615 "CopyStabilizerXTable");
616 CheckFunction((
void *)fCopyStabilizerXTable, __LINE__);
617 fCopyStabilizerZTable = (int (*)(
void *,
unsigned int *))GetFunction(
618 "CopyStabilizerZTable");
619 CheckFunction((
void *)fCopyStabilizerZTable, __LINE__);
620 fCopyStabilizerMTable = (int (*)(
void *,
unsigned int *))GetFunction(
621 "CopyStabilizerMTable");
622 CheckFunction((
void *)fCopyStabilizerMTable, __LINE__);
624 fInitStabilizerXTable =
625 (int (*)(
void *,
const unsigned int *))GetFunction(
"InitXTable");
626 CheckFunction((
void *)fInitStabilizerXTable, __LINE__);
627 fInitStabilizerZTable =
628 (int (*)(
void *,
const unsigned int *))GetFunction(
"InitZTable");
629 CheckFunction((
void *)fInitStabilizerZTable, __LINE__);
632 fCreatePauliPropSimulator =
633 (
void *(*)(
int))GetFunction(
"CreatePauliPropSimulator");
634 CheckFunction((
void *)fCreatePauliPropSimulator, __LINE__);
635 fDestroyPauliPropSimulator =
636 (void (*)(
void *))GetFunction(
"DestroyPauliPropSimulator");
637 CheckFunction((
void *)fDestroyPauliPropSimulator, __LINE__);
639 fPauliPropGetNrQubits =
640 (int (*)(
void *))GetFunction(
"PauliPropGetNrQubits");
641 CheckFunction((
void *)fPauliPropGetNrQubits, __LINE__);
642 fPauliPropSetWillUseSampling =
643 (int (*)(
void *, int))GetFunction(
"PauliPropSetWillUseSampling");
644 CheckFunction((
void *)fPauliPropSetWillUseSampling, __LINE__);
645 fPauliPropGetWillUseSampling =
646 (int (*)(
void *))GetFunction(
"PauliPropGetWillUseSampling");
647 CheckFunction((
void *)fPauliPropGetWillUseSampling, __LINE__);
649 fPauliPropGetCoefficientTruncationCutoff = (double (*)(
650 void *))GetFunction(
"PauliPropGetCoefficientTruncationCutoff");
651 CheckFunction((
void *)fPauliPropGetCoefficientTruncationCutoff,
653 fPauliPropSetCoefficientTruncationCutoff =
654 (void (*)(
void *, double))GetFunction(
655 "PauliPropSetCoefficientTruncationCutoff");
656 CheckFunction((
void *)fPauliPropSetCoefficientTruncationCutoff,
658 fPauliPropGetWeightTruncationCutoff = (double (*)(
void *))GetFunction(
659 "PauliPropGetWeightTruncationCutoff");
660 CheckFunction((
void *)fPauliPropGetWeightTruncationCutoff, __LINE__);
661 fPauliPropSetWeightTruncationCutoff = (void (*)(
662 void *, double))GetFunction(
"PauliPropSetWeightTruncationCutoff");
663 CheckFunction((
void *)fPauliPropSetWeightTruncationCutoff, __LINE__);
664 fPauliPropGetNumGatesBetweenTruncations = (int (*)(
665 void *))GetFunction(
"PauliPropGetNumGatesBetweenTruncations");
666 CheckFunction((
void *)fPauliPropGetNumGatesBetweenTruncations,
668 fPauliPropSetNumGatesBetweenTruncations =
669 (void (*)(
void *, int))GetFunction(
670 "PauliPropSetNumGatesBetweenTruncations");
671 CheckFunction((
void *)fPauliPropSetNumGatesBetweenTruncations,
673 fPauliPropGetNumGatesBetweenDeduplications = (int (*)(
674 void *))GetFunction(
"PauliPropGetNumGatesBetweenDeduplications");
675 CheckFunction((
void *)fPauliPropGetNumGatesBetweenDeduplications,
677 fPauliPropSetNumGatesBetweenDeduplications =
678 (void (*)(
void *, int))GetFunction(
679 "PauliPropSetNumGatesBetweenDeduplications");
680 CheckFunction((
void *)fPauliPropSetNumGatesBetweenDeduplications,
683 fPauliPropClearOperators =
684 (int (*)(
void *))GetFunction(
"PauliPropClearOperators");
685 CheckFunction((
void *)fPauliPropClearOperators, __LINE__);
686 fPauliPropAllocateMemory =
687 (int (*)(
void *, double))GetFunction(
"PauliPropAllocateMemory");
688 CheckFunction((
void *)fPauliPropAllocateMemory, __LINE__);
690 fPauliPropGetExpectationValue =
691 (double (*)(
void *))GetFunction(
"PauliPropGetExpectationValue");
692 CheckFunction((
void *)fPauliPropGetExpectationValue, __LINE__);
693 fPauliPropExecute = (int (*)(
void *))GetFunction(
"PauliPropExecute");
694 CheckFunction((
void *)fPauliPropExecute, __LINE__);
695 fPauliPropSetInPauliExpansionUnique =
696 (int (*)(
void *,
const char *))GetFunction(
697 "PauliPropSetInPauliExpansionUnique");
698 CheckFunction((
void *)fPauliPropSetInPauliExpansionUnique, __LINE__);
699 fPauliPropSetInPauliExpansionMultiple =
700 (int (*)(
void *,
const char **,
const double *, int))GetFunction(
701 "PauliPropSetInPauliExpansionMultiple");
702 CheckFunction((
void *)fPauliPropSetInPauliExpansionMultiple,
706 (int (*)(
void *, int))GetFunction(
"PauliPropApplyX");
707 CheckFunction((
void *)fPauliPropApplyX, __LINE__);
709 (int (*)(
void *, int))GetFunction(
"PauliPropApplyY");
710 CheckFunction((
void *)fPauliPropApplyY, __LINE__);
712 (int (*)(
void *, int))GetFunction(
"PauliPropApplyZ");
713 CheckFunction((
void *)fPauliPropApplyZ, __LINE__);
715 (int (*)(
void *, int))GetFunction(
"PauliPropApplyH");
716 CheckFunction((
void *)fPauliPropApplyH, __LINE__);
718 (int (*)(
void *, int))GetFunction(
"PauliPropApplyS");
719 CheckFunction((
void *)fPauliPropApplyS, __LINE__);
721 fPauliPropApplySQRTX =
722 (int (*)(
void *, int))GetFunction(
"PauliPropApplySQRTX");
723 CheckFunction((
void *)fPauliPropApplySQRTX, __LINE__);
724 fPauliPropApplySQRTY =
725 (int (*)(
void *, int))GetFunction(
"PauliPropApplySQRTY");
726 CheckFunction((
void *)fPauliPropApplySQRTY, __LINE__);
727 fPauliPropApplySQRTZ =
728 (int (*)(
void *, int))GetFunction(
"PauliPropApplySQRTZ");
729 CheckFunction((
void *)fPauliPropApplySQRTZ, __LINE__);
731 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyCX");
732 CheckFunction((
void *)fPauliPropApplyCX, __LINE__);
734 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyCY");
735 CheckFunction((
void *)fPauliPropApplyCY, __LINE__);
737 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyCZ");
738 CheckFunction((
void *)fPauliPropApplyCZ, __LINE__);
739 fPauliPropApplySWAP =
740 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplySWAP");
741 CheckFunction((
void *)fPauliPropApplySWAP, __LINE__);
742 fPauliPropApplyISWAP =
743 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyISWAP");
744 CheckFunction((
void *)fPauliPropApplyISWAP, __LINE__);
746 (int (*)(
void *, int, double))GetFunction(
"PauliPropApplyRX");
747 CheckFunction((
void *)fPauliPropApplyRX, __LINE__);
749 (int (*)(
void *, int, double))GetFunction(
"PauliPropApplyRY");
750 CheckFunction((
void *)fPauliPropApplyRY, __LINE__);
752 (int (*)(
void *, int, double))GetFunction(
"PauliPropApplyRZ");
753 CheckFunction((
void *)fPauliPropApplyRZ, __LINE__);
755 fPauliPropAddNoiseX =
756 (int (*)(
void *, int, double))GetFunction(
"PauliPropAddNoiseX");
757 CheckFunction((
void *)fPauliPropAddNoiseX, __LINE__);
758 fPauliPropAddNoiseY =
759 (int (*)(
void *, int, double))GetFunction(
"PauliPropAddNoiseY");
760 CheckFunction((
void *)fPauliPropAddNoiseY, __LINE__);
761 fPauliPropAddNoiseZ =
762 (int (*)(
void *, int, double))GetFunction(
"PauliPropAddNoiseZ");
763 CheckFunction((
void *)fPauliPropAddNoiseZ, __LINE__);
764 fPauliPropAddNoiseXYZ =
765 (int (*)(
void *, int, double, double, double))GetFunction(
766 "PauliPropAddNoiseXYZ");
767 CheckFunction((
void *)fPauliPropAddNoiseXYZ, __LINE__);
768 fPauliPropAddAmplitudeDamping =
769 (int (*)(
void *, int, double, double))GetFunction(
770 "PauliPropAddAmplitudeDamping");
771 CheckFunction((
void *)fPauliPropAddAmplitudeDamping, __LINE__);
772 fPauliPropQubitProbability0 = (double (*)(
void *, int))GetFunction(
773 "PauliPropQubitProbability0");
774 CheckFunction((
void *)fPauliPropQubitProbability0, __LINE__);
775 fPauliPropProbability =
776 (double (*)(
void *,
unsigned long long int))GetFunction(
777 "PauliPropProbability");
778 CheckFunction((
void *)fPauliPropProbability, __LINE__);
780 fPauliPropMeasureQubit =
781 (int (*)(
void *, int))GetFunction(
"PauliPropMeasureQubit");
782 CheckFunction((
void *)fPauliPropMeasureQubit, __LINE__);
784 fPauliPropSampleQubits =
785 (
unsigned char *(*)(
void *,
const int *,
int))GetFunction(
786 "PauliPropSampleQubits");
787 CheckFunction((
void *)fPauliPropSampleQubits, __LINE__);
788 fPauliPropFreeSampledQubits = (void (*)(
unsigned char *))GetFunction(
789 "PauliPropFreeSampledQubits");
790 CheckFunction((
void *)fPauliPropFreeSampledQubits, __LINE__);
791 fPauliPropSaveState =
792 (void (*)(
void *))GetFunction(
"PauliPropSaveState");
793 CheckFunction((
void *)fPauliPropSaveState, __LINE__);
794 fPauliPropRestoreState =
795 (void (*)(
void *))GetFunction(
"PauliPropRestoreState");
796 CheckFunction((
void *)fPauliPropRestoreState, __LINE__);
800 std::cerr <<
"GpuLibrary: Unable to initialize gpu library"
803 std::cerr <<
"GpuLibrary: Unable to get initialization function for "
807 std::cerr <<
"GpuLibrary: Unable to load gpu library" << std::endl;
812 static void CheckFunction(
void *func,
int line) {
814 std::cerr <<
"GpuLibrary: Unable to load function, line #: " << line;
815 const char *dlsym_error = dlerror();
816 if (dlsym_error) std::cerr <<
", error: " << dlsym_error;
818 std::cerr << std::endl;
822 bool IsValid()
const {
return LibraryHandle !=
nullptr; }
826 void *CreateStateVector() {
828 return fCreateStateVector(LibraryHandle);
830 throw std::runtime_error(
"GpuLibrary: Unable to create state vector");
833 void DestroyStateVector(
void *obj) {
835 fDestroyStateVector(obj);
837 throw std::runtime_error(
"GpuLibrary: Unable to destroy state vector");
840 bool Create(
void *obj,
unsigned int nrQubits) {
842 return fCreate(obj, nrQubits) == 1;
844 throw std::runtime_error(
845 "GpuLibrary: Unable to create state vector state");
850 bool CreateWithState(
void *obj,
unsigned int nrQubits,
const double *state) {
852 return fCreateWithState(obj, nrQubits, state) == 1;
854 throw std::runtime_error(
855 "GpuLibrary: Unable to create state vector state with a state");
860 bool Reset(
void *obj) {
862 return fReset(obj) == 1;
864 throw std::runtime_error(
"GpuLibrary: Unable to reset state vector");
869 bool SetDataType(
void *obj,
int dataType) {
871 return fSetDataType(obj, dataType) == 1;
873 throw std::runtime_error(
"GpuLibrary: Unable to set data type");
878 bool IsDoublePrecision(
void *obj)
const {
880 return fIsDoublePrecision(obj) == 1;
882 throw std::runtime_error(
883 "GpuLibrary: Unable to check if double precision");
888 int GetNrQubits(
void *obj)
const {
890 return fGetNrQubits(obj);
892 throw std::runtime_error(
"GpuLibrary: Unable to get number of qubits");
896 bool MeasureQubitCollapse(
void *obj,
int qubitIndex) {
898 return fMeasureQubitCollapse(obj, qubitIndex) == 1;
900 throw std::runtime_error(
901 "GpuLibrary: Unable to measure qubit with collapse");
906 bool MeasureQubitNoCollapse(
void *obj,
int qubitIndex) {
908 return fMeasureQubitNoCollapse(obj, qubitIndex) == 1;
910 throw std::runtime_error(
911 "GpuLibrary: Unable to measure qubit no collapse");
916 bool MeasureQubitsCollapse(
void *obj,
int *qubits,
int *bitstring,
919 return fMeasureQubitsCollapse(obj, qubits, bitstring, bitstringLen) == 1;
921 throw std::runtime_error(
922 "GpuLibrary: Unable to measure qubits with collapse");
927 bool MeasureQubitsNoCollapse(
void *obj,
int *qubits,
int *bitstring,
930 return fMeasureQubitsNoCollapse(obj, qubits, bitstring, bitstringLen) ==
933 throw std::runtime_error(
934 "GpuLibrary: Unable to measure qubits with no collapse");
939 unsigned long long MeasureAllQubitsCollapse(
void *obj) {
941 return fMeasureAllQubitsCollapse(obj);
943 throw std::runtime_error(
944 "GpuLibrary: Unable to measure all qubits with collapse");
949 unsigned long long MeasureAllQubitsNoCollapse(
void *obj) {
951 return fMeasureAllQubitsNoCollapse(obj);
953 throw std::runtime_error(
954 "GpuLibrary: Unable to measure all qubits with no collapse");
961 return fSaveState(obj) == 1;
963 throw std::runtime_error(
"GpuLibrary: Unable to save state");
968 bool SaveStateToHost(
void *obj) {
970 return fSaveStateToHost(obj) == 1;
972 throw std::runtime_error(
"GpuLibrary: Unable to save state to host");
977 bool SaveStateDestructive(
void *obj) {
979 return fSaveStateDestructive(obj) == 1;
981 throw std::runtime_error(
982 "GpuLibrary: Unable to save state destructively");
987 bool RestoreStateFreeSaved(
void *obj) {
989 return fRestoreStateFreeSaved(obj) == 1;
991 throw std::runtime_error(
992 "GpuLibrary: Unable to restore state free saved");
997 bool RestoreStateNoFreeSaved(
void *obj) {
999 return fRestoreStateNoFreeSaved(obj) == 1;
1001 throw std::runtime_error(
1002 "GpuLibrary: Unable to restore state no free saved");
1007 void FreeSavedState(
void *obj) {
1009 fFreeSavedState(obj);
1011 throw std::runtime_error(
"GpuLibrary: Unable to free saved state");
1014 void *Clone(
void *obj)
const {
1018 throw std::runtime_error(
"GpuLibrary: Unable to clone state vector");
1023 bool Sample(
void *obj,
unsigned int nSamples,
long int *samples,
1024 unsigned int nBits,
int *bits) {
1026 return fSample(obj, nSamples, samples, nBits, bits) == 1;
1028 throw std::runtime_error(
"GpuLibrary: Unable to sample state vector");
1033 bool SampleAll(
void *obj,
unsigned int nSamples,
long int *samples) {
1035 return fSampleAll(obj, nSamples, samples) == 1;
1037 throw std::runtime_error(
"GpuLibrary: Unable to sample state vector");
1042 bool Amplitude(
void *obj,
long long int state,
double *real,
1043 double *imaginary)
const {
1045 return fAmplitude(obj, state, real, imaginary) == 1;
1047 throw std::runtime_error(
"GpuLibrary: Unable to get amplitude");
1052 double Probability(
void *obj,
int *qubits,
int *mask,
int len)
const {
1054 return fProbability(obj, qubits, mask, len);
1056 throw std::runtime_error(
"GpuLibrary: Unable to get probability");
1061 double BasisStateProbability(
void *obj,
long long int state)
const {
1063 return fBasisStateProbability(obj, state);
1065 throw std::runtime_error(
1066 "GpuLibrary: Unable to get basis state probability");
1073 return fAllProbabilities(obj, probabilities) == 1;
1075 throw std::runtime_error(
"GpuLibrary: Unable to get all probabilities");
1080 double ExpectationValue(
void *obj,
const char *pauliString,
int len)
const {
1082 return fExpectationValue(obj, pauliString, len);
1084 throw std::runtime_error(
"GpuLibrary: Unable to get expectation value");
1089 bool ApplyX(
void *obj,
int qubit) {
1091 return fApplyX(obj, qubit) == 1;
1093 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate");
1098 bool ApplyY(
void *obj,
int qubit) {
1100 return fApplyY(obj, qubit) == 1;
1102 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate");
1107 bool ApplyZ(
void *obj,
int qubit) {
1109 return fApplyZ(obj, qubit) == 1;
1111 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate");
1116 bool ApplyH(
void *obj,
int qubit) {
1118 return fApplyH(obj, qubit) == 1;
1120 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate");
1125 bool ApplyS(
void *obj,
int qubit) {
1127 return fApplyS(obj, qubit) == 1;
1129 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate");
1134 bool ApplySDG(
void *obj,
int qubit) {
1136 return fApplySDG(obj, qubit) == 1;
1138 throw std::runtime_error(
"GpuLibrary: Unable to apply SDG gate");
1143 bool ApplyT(
void *obj,
int qubit) {
1145 return fApplyT(obj, qubit) == 1;
1147 throw std::runtime_error(
"GpuLibrary: Unable to apply T gate");
1152 bool ApplyTDG(
void *obj,
int qubit) {
1154 return fApplyTDG(obj, qubit) == 1;
1156 throw std::runtime_error(
"GpuLibrary: Unable to apply TDG gate");
1161 bool ApplySX(
void *obj,
int qubit) {
1163 return fApplySX(obj, qubit) == 1;
1165 throw std::runtime_error(
"GpuLibrary: Unable to apply SX gate");
1172 return fApplySXDG(obj, qubit) == 1;
1174 throw std::runtime_error(
"GpuLibrary: Unable to apply SXDG gate");
1179 bool ApplyK(
void *obj,
int qubit) {
1181 return fApplyK(obj, qubit) == 1;
1183 throw std::runtime_error(
"GpuLibrary: Unable to apply K gate");
1188 bool ApplyP(
void *obj,
int qubit,
double theta) {
1190 return fApplyP(obj, qubit, theta) == 1;
1192 throw std::runtime_error(
"GpuLibrary: Unable to apply P gate");
1197 bool ApplyRx(
void *obj,
int qubit,
double theta) {
1199 return fApplyRx(obj, qubit, theta) == 1;
1201 throw std::runtime_error(
"GpuLibrary: Unable to apply Rx gate");
1206 bool ApplyRy(
void *obj,
int qubit,
double theta) {
1208 return fApplyRy(obj, qubit, theta) == 1;
1210 throw std::runtime_error(
"GpuLibrary: Unable to apply Ry gate");
1215 bool ApplyRz(
void *obj,
int qubit,
double theta) {
1217 return fApplyRz(obj, qubit, theta) == 1;
1219 throw std::runtime_error(
"GpuLibrary: Unable to apply Rz gate");
1224 bool ApplyU(
void *obj,
int qubit,
double theta,
double phi,
double lambda,
1227 return fApplyU(obj, qubit, theta, phi, lambda, gamma) == 1;
1229 throw std::runtime_error(
"GpuLibrary: Unable to apply U gate");
1234 bool ApplyCX(
void *obj,
int controlQubit,
int targetQubit) {
1236 return fApplyCX(obj, controlQubit, targetQubit) == 1;
1238 throw std::runtime_error(
"GpuLibrary: Unable to apply CX gate");
1243 bool ApplyCY(
void *obj,
int controlQubit,
int targetQubit) {
1245 return fApplyCY(obj, controlQubit, targetQubit) == 1;
1247 throw std::runtime_error(
"GpuLibrary: Unable to apply CY gate");
1252 bool ApplyCZ(
void *obj,
int controlQubit,
int targetQubit) {
1254 return fApplyCZ(obj, controlQubit, targetQubit) == 1;
1256 throw std::runtime_error(
"GpuLibrary: Unable to apply CZ gate");
1261 bool ApplyCH(
void *obj,
int controlQubit,
int targetQubit) {
1263 return fApplyCH(obj, controlQubit, targetQubit) == 1;
1265 throw std::runtime_error(
"GpuLibrary: Unable to apply CH gate");
1270 bool ApplyCSX(
void *obj,
int controlQubit,
int targetQubit) {
1272 return fApplyCSX(obj, controlQubit, targetQubit) == 1;
1274 throw std::runtime_error(
"GpuLibrary: Unable to apply CSX gate");
1279 bool ApplyCSXDG(
void *obj,
int controlQubit,
int targetQubit) {
1281 return fApplyCSXDG(obj, controlQubit, targetQubit) == 1;
1283 throw std::runtime_error(
"GpuLibrary: Unable to apply CSXDG gate");
1288 bool ApplyCP(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
1290 return fApplyCP(obj, controlQubit, targetQubit, theta) == 1;
1292 throw std::runtime_error(
"GpuLibrary: Unable to apply CP gate");
1297 bool ApplyCRx(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
1299 return fApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
1301 throw std::runtime_error(
"GpuLibrary: Unable to apply CRx gate");
1306 bool ApplyCRy(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
1308 return fApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
1310 throw std::runtime_error(
"GpuLibrary: Unable to apply CRy gate");
1315 bool ApplyCRz(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
1317 return fApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
1319 throw std::runtime_error(
"GpuLibrary: Unable to apply CRz gate");
1324 bool ApplyCCX(
void *obj,
int controlQubit1,
int controlQubit2,
1327 return fApplyCCX(obj, controlQubit1, controlQubit2, targetQubit) == 1;
1329 throw std::runtime_error(
"GpuLibrary: Unable to apply CCX gate");
1334 bool ApplySwap(
void *obj,
int qubit1,
int qubit2) {
1336 return fApplySwap(obj, qubit1, qubit2) == 1;
1338 throw std::runtime_error(
"GpuLibrary: Unable to apply Swap gate");
1343 bool ApplyCSwap(
void *obj,
int controlQubit,
int qubit1,
int qubit2) {
1345 return fApplyCSwap(obj, controlQubit, qubit1, qubit2) == 1;
1347 throw std::runtime_error(
"GpuLibrary: Unable to apply CSwap gate");
1352 bool ApplyCU(
void *obj,
int controlQubit,
int targetQubit,
double theta,
1353 double phi,
double lambda,
double gamma) {
1355 return fApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda,
1358 throw std::runtime_error(
"GpuLibrary: Unable to apply CU gate");
1367 return fCreateMPS(LibraryHandle);
1369 throw std::runtime_error(
"GpuLibrary: Unable to create mps");
1372 void DestroyMPS(
void *obj) {
1376 throw std::runtime_error(
"GpuLibrary: Unable to destroy mps");
1379 bool MPSCreate(
void *obj,
unsigned int nrQubits) {
1381 return fMPSCreate(obj, nrQubits) == 1;
1383 throw std::runtime_error(
1384 "GpuLibrary: Unable to create mps with the "
1385 "specified number of qubits");
1390 bool MPSReset(
void *obj) {
1392 return fMPSReset(obj) == 1;
1394 throw std::runtime_error(
"GpuLibrary: Unable to reset mps");
1399 bool MPSSetInitialQubitsMap(
void *obj,
1400 const std::vector<long long int> &initialMap) {
1402 return fMPSSetInitialQubitsMap(obj, initialMap.data(),
1403 initialMap.size()) == 1;
1405 throw std::runtime_error(
1406 "GpuLibrary: Unable to set initial qubits map for mps");
1411 bool MPSSetUseOptimalMeetingPosition(
void *obj,
int val) {
1413 return fMPSSetUseOptimalMeetingPosition(obj, val) == 1;
1415 throw std::runtime_error(
1416 "GpuLibrary: Unable to set use optimal meeting position for mps");
1420 bool MPSIsValid(
void *obj)
const {
1422 return fMPSIsValid(obj) == 1;
1424 throw std::runtime_error(
"GpuLibrary: Unable to check if mps is valid");
1429 bool MPSIsCreated(
void *obj)
const {
1431 return fMPSIsCreated(obj) == 1;
1433 throw std::runtime_error(
"GpuLibrary: Unable to check if mps is created");
1438 bool MPSSetDataType(
void *obj,
int useDoublePrecision) {
1440 return fMPSSetDataType(obj, useDoublePrecision) == 1;
1442 throw std::runtime_error(
"GpuLibrary: Unable to set precision for mps");
1447 bool MPSIsDoublePrecision(
void *obj)
const {
1449 return fMPSIsDoublePrecision(obj) == 1;
1451 throw std::runtime_error(
"GpuLibrary: Unable to get precision for mps");
1456 bool MPSSetCutoff(
void *obj,
double val) {
1458 return fMPSSetCutoff(obj, val) == 1;
1460 throw std::runtime_error(
"GpuLibrary: Unable to set cutoff for mps");
1465 double MPSGetCutoff(
void *obj)
const {
1467 return fMPSGetCutoff(obj);
1469 throw std::runtime_error(
"GpuLibrary: Unable to get cutoff for mps");
1472 bool MPSSetGesvdJ(
void *obj,
int val) {
1474 return fMPSSetGesvdJ(obj, val) == 1;
1476 throw std::runtime_error(
"GpuLibrary: Unable to set GesvdJ for mps");
1481 bool MPSGetGesvdJ(
void *obj)
const {
1483 return fMPSGetGesvdJ(obj) == 1;
1485 throw std::runtime_error(
"GpuLibrary: Unable to get GesvdJ for mps");
1490 bool MPSSetMaxExtent(
void *obj,
long int val) {
1492 return fMPSSetMaxExtent(obj, val) == 1;
1494 throw std::runtime_error(
"GpuLibrary: Unable to set max extent for mps");
1499 long int MPSGetMaxExtent(
void *obj) {
1501 return fMPSGetMaxExtent(obj);
1503 throw std::runtime_error(
"GpuLibrary: Unable to get max extent for mps");
1508 int MPSGetNrQubits(
void *obj) {
1510 return fMPSGetNrQubits(obj);
1512 throw std::runtime_error(
"GpuLibrary: Unable to get nr qubits for mps");
1517 bool MPSAmplitude(
void *obj,
long int numFixedValues,
long int *fixedValues,
1518 double *real,
double *imaginary) {
1520 return fMPSAmplitude(obj, numFixedValues, fixedValues, real, imaginary) ==
1523 throw std::runtime_error(
"GpuLibrary: Unable to get mps amplitude");
1528 double MPSProbability0(
void *obj,
unsigned int qubit) {
1530 return fMPSProbability0(obj, qubit);
1532 throw std::runtime_error(
1533 "GpuLibrary: Unable to get probability for 0 for mps");
1538 bool MPSMeasure(
void *obj,
unsigned int qubit) {
1540 return fMPSMeasure(obj, qubit) == 1;
1542 throw std::runtime_error(
"GpuLibrary: Unable to measure qubit on mps");
1547 bool MPSMeasureQubits(
void *obj,
long int numQubits,
unsigned int *qubits,
1550 return fMPSMeasureQubits(obj, numQubits, qubits, result) == 1;
1552 throw std::runtime_error(
"GpuLibrary: Unable to measure qubits on mps");
1557 std::unordered_map<std::vector<bool>, int64_t> *MPSGetMapForSample() {
1559 return (std::unordered_map<std::vector<bool>, int64_t> *)
1560 fMPSGetMapForSample();
1562 throw std::runtime_error(
1563 "GpuLibrary: Unable to get map for sample for mps");
1568 bool MPSFreeMapForSample(
1569 std::unordered_map<std::vector<bool>, int64_t> *map) {
1571 return fMPSFreeMapForSample((
void *)map) == 1;
1573 throw std::runtime_error(
1574 "GpuLibrary: Unable to free map for sample for mps");
1579 bool MPSSample(
void *obj,
long int numShots,
long int numQubits,
1580 unsigned int *qubits,
void *resultMap) {
1582 return fMPSSample(obj, numShots, numQubits, qubits, resultMap) == 1;
1584 throw std::runtime_error(
"GpuLibrary: Unable to sample mps");
1589 bool MPSSaveState(
void *obj) {
1591 return fMPSSaveState(obj) == 1;
1593 throw std::runtime_error(
"GpuLibrary: Unable to save mps state");
1598 bool MPSRestoreState(
void *obj) {
1600 return fMPSRestoreState(obj) == 1;
1602 throw std::runtime_error(
"GpuLibrary: Unable to restore mps state");
1607 bool MPSCleanSavedState(
void *obj) {
1609 return fMPSCleanSavedState(obj) == 1;
1611 throw std::runtime_error(
"GpuLibrary: Unable to clean mps saved state");
1616 void *MPSClone(
void *obj) {
1618 return fMPSClone(obj);
1620 throw std::runtime_error(
"GpuLibrary: Unable to clone mps");
1625 double MPSExpectationValue(
void *obj,
const char *pauliString,
1628 return fMPSExpectationValue(obj, pauliString, len);
1630 throw std::runtime_error(
1631 "GpuLibrary: Unable to get mps expectation value");
1636 std::complex<double> MPSProjectOnZero(
void* obj)
1638 if (LibraryHandle) {
1640 if (fMPSProjectOnZero(obj, &real, &imag) == 1)
1641 return std::complex<double>(real, imag);
1643 throw std::runtime_error(
1644 "GpuLibrary: Unable to project on zero for mps");
1646 throw std::runtime_error(
1647 "GpuLibrary: Unable to project on zero for mps, library handle is null");
1649 return std::complex<double>(0, 0);
1652 bool MPSApplyX(
void *obj,
unsigned int siteA) {
1654 return fMPSApplyX(obj, siteA) == 1;
1656 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate on mps");
1661 bool MPSApplyY(
void *obj,
unsigned int siteA) {
1663 return fMPSApplyY(obj, siteA) == 1;
1665 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate on mps");
1670 bool MPSApplyZ(
void *obj,
unsigned int siteA) {
1672 return fMPSApplyZ(obj, siteA) == 1;
1674 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate on mps");
1679 bool MPSApplyH(
void *obj,
unsigned int siteA) {
1681 return fMPSApplyH(obj, siteA) == 1;
1683 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate on mps");
1688 bool MPSApplyS(
void *obj,
unsigned int siteA) {
1690 return fMPSApplyS(obj, siteA) == 1;
1692 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate on mps");
1697 bool MPSApplySDG(
void *obj,
unsigned int siteA) {
1699 return fMPSApplySDG(obj, siteA) == 1;
1701 throw std::runtime_error(
"GpuLibrary: Unable to apply sdg gate on mps");
1706 bool MPSApplyT(
void *obj,
unsigned int siteA) {
1708 return fMPSApplyT(obj, siteA) == 1;
1710 throw std::runtime_error(
"GpuLibrary: Unable to apply t gate on mps");
1715 bool MPSApplyTDG(
void *obj,
unsigned int siteA) {
1717 return fMPSApplyTDG(obj, siteA) == 1;
1719 throw std::runtime_error(
"GpuLibrary: Unable to appl tdg gate on mps");
1724 bool MPSApplySX(
void *obj,
unsigned int siteA) {
1726 return fMPSApplySX(obj, siteA) == 1;
1728 throw std::runtime_error(
"GpuLibrary: Unable to apply sx gate on mps");
1733 bool MPSApplySXDG(
void *obj,
unsigned int siteA) {
1735 return fMPSApplySXDG(obj, siteA) == 1;
1737 throw std::runtime_error(
"GpuLibrary: Unable to apply sxdg gate on mps");
1742 bool MPSApplyK(
void *obj,
unsigned int siteA) {
1744 return fMPSApplyK(obj, siteA) == 1;
1746 throw std::runtime_error(
"GpuLibrary: Unable to apply k gate on mps");
1751 bool MPSApplyP(
void *obj,
unsigned int siteA,
double theta) {
1753 return fMPSApplyP(obj, siteA, theta) == 1;
1755 throw std::runtime_error(
"GpuLibrary: Unable to apply p gate on mps");
1759 bool MPSApplyRx(
void *obj,
unsigned int siteA,
double theta) {
1761 return fMPSApplyRx(obj, siteA, theta) == 1;
1763 throw std::runtime_error(
"GpuLibrary: Unable to apply rx gate on mps");
1768 bool MPSApplyRy(
void *obj,
unsigned int siteA,
double theta) {
1770 return fMPSApplyRy(obj, siteA, theta) == 1;
1772 throw std::runtime_error(
"GpuLibrary: Unable to apply ry gate on mps");
1777 bool MPSApplyRz(
void *obj,
unsigned int siteA,
double theta) {
1779 return fMPSApplyRz(obj, siteA, theta) == 1;
1781 throw std::runtime_error(
"GpuLibrary: Unable to apply rz gate on mps");
1786 bool MPSApplyU(
void *obj,
unsigned int siteA,
double theta,
double phi,
1787 double lambda,
double gamma) {
1789 return fMPSApplyU(obj, siteA, theta, phi, lambda, gamma) == 1;
1791 throw std::runtime_error(
"GpuLibrary: Unable to apply u gate on mps");
1796 bool MPSApplySwap(
void *obj,
unsigned int controlQubit,
1797 unsigned int targetQubit) {
1799 return fMPSApplySwap(obj, controlQubit, targetQubit) == 1;
1801 throw std::runtime_error(
"GpuLibrary: Unable to apply swap gate on mps");
1806 bool MPSApplyCX(
void *obj,
unsigned int controlQubit,
1807 unsigned int targetQubit) {
1809 return fMPSApplyCX(obj, controlQubit, targetQubit) == 1;
1811 throw std::runtime_error(
"GpuLibrary: Unable to apply cx gate on mps");
1816 bool MPSApplyCY(
void *obj,
unsigned int controlQubit,
1817 unsigned int targetQubit) {
1819 return fMPSApplyCY(obj, controlQubit, targetQubit) == 1;
1821 throw std::runtime_error(
"GpuLibrary: Unable to apply cy gate on mps");
1826 bool MPSApplyCZ(
void *obj,
unsigned int controlQubit,
1827 unsigned int targetQubit) {
1829 return fMPSApplyCZ(obj, controlQubit, targetQubit) == 1;
1831 throw std::runtime_error(
"GpuLibrary: Unable to apply cz gate on mps");
1836 bool MPSApplyCH(
void *obj,
unsigned int controlQubit,
1837 unsigned int targetQubit) {
1839 return fMPSApplyCH(obj, controlQubit, targetQubit) == 1;
1841 throw std::runtime_error(
"GpuLibrary: Unable to apply ch gate on mps");
1846 bool MPSApplyCSX(
void *obj,
unsigned int controlQubit,
1847 unsigned int targetQubit) {
1849 return fMPSApplyCSX(obj, controlQubit, targetQubit) == 1;
1851 throw std::runtime_error(
"GpuLibrary: Unable to apply csx gate on mps");
1854 bool MPSApplyCSXDG(
void *obj,
unsigned int controlQubit,
1855 unsigned int targetQubit) {
1857 return fMPSApplyCSXDG(obj, controlQubit, targetQubit) == 1;
1859 throw std::runtime_error(
"GpuLibrary: Unable to apply csxdg gate on mps");
1864 bool MPSApplyCP(
void *obj,
unsigned int controlQubit,
1865 unsigned int targetQubit,
double theta) {
1867 return fMPSApplyCP(obj, controlQubit, targetQubit, theta) == 1;
1869 throw std::runtime_error(
"GpuLibrary: Unable to apply cp gate on mps");
1874 bool MPSApplyCRx(
void *obj,
unsigned int controlQubit,
1875 unsigned int targetQubit,
double theta) {
1877 return fMPSApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
1879 throw std::runtime_error(
"GpuLibrary: Unable to apply crx gate on mps");
1884 bool MPSApplyCRy(
void *obj,
unsigned int controlQubit,
1885 unsigned int targetQubit,
double theta) {
1887 return fMPSApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
1889 throw std::runtime_error(
"GpuLibrary: Unable to apply cry gate on mps");
1894 bool MPSApplyCRz(
void *obj,
unsigned int controlQubit,
1895 unsigned int targetQubit,
double theta) {
1897 return fMPSApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
1899 throw std::runtime_error(
"GpuLibrary: Unable to apply crz gate on mps");
1904 bool MPSApplyCU(
void *obj,
unsigned int controlQubit,
1905 unsigned int targetQubit,
double theta,
double phi,
1906 double lambda,
double gamma) {
1908 return fMPSApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda,
1911 throw std::runtime_error(
"GpuLibrary: Unable to apply cu gate on mps");
1918 void *CreateTensorNet() {
1920 return fCreateTensorNet(LibraryHandle);
1922 throw std::runtime_error(
"GpuLibrary: Unable to create tensor network");
1925 void DestroyTensorNet(
void *obj) {
1927 fDestroyTensorNet(obj);
1929 throw std::runtime_error(
"GpuLibrary: Unable to destroy tensor network");
1932 bool TNCreate(
void *obj,
unsigned int nrQubits) {
1934 return fTNCreate(obj, nrQubits) == 1;
1936 throw std::runtime_error(
1937 "GpuLibrary: Unable to create tensor network with the "
1938 "specified number of qubits");
1943 bool TNReset(
void *obj) {
1945 return fTNReset(obj) == 1;
1947 throw std::runtime_error(
"GpuLibrary: Unable to reset tensor network");
1952 bool TNIsValid(
void *obj)
const {
1954 return fTNIsValid(obj) == 1;
1956 throw std::runtime_error(
1957 "GpuLibrary: Unable to check if tensor network is valid");
1962 bool TNIsCreated(
void *obj)
const {
1964 return fTNIsCreated(obj) == 1;
1966 throw std::runtime_error(
1967 "GpuLibrary: Unable to check if tensor network is created");
1972 bool TNSetDataType(
void *obj,
int useDoublePrecision) {
1974 return fTNSetDataType(obj, useDoublePrecision) == 1;
1976 throw std::runtime_error(
1977 "GpuLibrary: Unable to set precision for tensor network");
1982 bool TNIsDoublePrecision(
void *obj)
const {
1984 return fTNIsDoublePrecision(obj) == 1;
1986 throw std::runtime_error(
1987 "GpuLibrary: Unable to get precision for tensor network");
1992 bool TNSetCutoff(
void *obj,
double val) {
1994 return fTNSetCutoff(obj, val) == 1;
1996 throw std::runtime_error(
1997 "GpuLibrary: Unable to set cutoff for tensor network");
2002 double TNGetCutoff(
void *obj)
const {
2004 return fTNGetCutoff(obj);
2006 throw std::runtime_error(
2007 "GpuLibrary: Unable to get cutoff for tensor network");
2010 bool TNSetGesvdJ(
void *obj,
int val) {
2012 return fTNSetGesvdJ(obj, val) == 1;
2014 throw std::runtime_error(
2015 "GpuLibrary: Unable to set GesvdJ for tensor network");
2020 bool TNGetGesvdJ(
void *obj)
const {
2022 return fTNGetGesvdJ(obj) == 1;
2024 throw std::runtime_error(
2025 "GpuLibrary: Unable to get GesvdJ for tensor network");
2030 bool TNSetMaxExtent(
void *obj,
long int val) {
2032 return fTNSetMaxExtent(obj, val) == 1;
2034 throw std::runtime_error(
2035 "GpuLibrary: Unable to set max extent for tensor network");
2040 long int TNGetMaxExtent(
void *obj) {
2042 return fTNGetMaxExtent(obj);
2044 throw std::runtime_error(
2045 "GpuLibrary: Unable to get max extent for tensor network");
2050 int TNGetNrQubits(
void *obj) {
2052 return fTNGetNrQubits(obj);
2054 throw std::runtime_error(
2055 "GpuLibrary: Unable to get nr qubits for tensor network");
2060 bool TNAmplitude(
void *obj,
long int numFixedValues,
long int *fixedValues,
2061 double *real,
double *imaginary) {
2063 return fTNAmplitude(obj, numFixedValues, fixedValues, real, imaginary) ==
2066 throw std::runtime_error(
2067 "GpuLibrary: Unable to get tensor network amplitude");
2072 double TNProbability0(
void *obj,
unsigned int qubit) {
2074 return fTNProbability0(obj, qubit);
2076 throw std::runtime_error(
2077 "GpuLibrary: Unable to get probability for 0 for tensor network");
2082 bool TNMeasure(
void *obj,
unsigned int qubit) {
2084 return fTNMeasure(obj, qubit) == 1;
2086 throw std::runtime_error(
2087 "GpuLibrary: Unable to measure qubit on tensor network");
2092 bool TNMeasureQubits(
void *obj,
long int numQubits,
unsigned int *qubits,
2095 return fTNMeasureQubits(obj, numQubits, qubits, result) == 1;
2097 throw std::runtime_error(
2098 "GpuLibrary: Unable to measure qubits on tensor network");
2103 std::unordered_map<std::vector<bool>, int64_t> *TNGetMapForSample() {
2106 std::unordered_map<std::vector<bool>, int64_t> *)fTNGetMapForSample();
2108 throw std::runtime_error(
2109 "GpuLibrary: Unable to get map for sample for tensor network");
2114 bool TNFreeMapForSample(std::unordered_map<std::vector<bool>, int64_t> *map) {
2116 return fTNFreeMapForSample((
void *)map) == 1;
2118 throw std::runtime_error(
2119 "GpuLibrary: Unable to free map for sample for tensor network");
2124 bool TNSample(
void *obj,
long int numShots,
long int numQubits,
2125 unsigned int *qubits,
void *resultMap) {
2127 return fTNSample(obj, numShots, numQubits, qubits, resultMap) == 1;
2129 throw std::runtime_error(
"GpuLibrary: Unable to sample tensor network");
2134 bool TNSaveState(
void *obj) {
2136 return fTNSaveState(obj) == 1;
2138 throw std::runtime_error(
2139 "GpuLibrary: Unable to save tensor network state");
2144 bool TNRestoreState(
void *obj) {
2146 return fTNRestoreState(obj) == 1;
2148 throw std::runtime_error(
2149 "GpuLibrary: Unable to restore tensor network state");
2154 bool TNCleanSavedState(
void *obj) {
2156 return fTNCleanSavedState(obj) == 1;
2158 throw std::runtime_error(
2159 "GpuLibrary: Unable to clean tensor network saved state");
2164 void *TNClone(
void *obj) {
2166 return fTNClone(obj);
2168 throw std::runtime_error(
"GpuLibrary: Unable to clone tensor network");
2173 double TNExpectationValue(
void *obj,
const char *pauliString,
int len)
const {
2175 return fTNExpectationValue(obj, pauliString, len);
2177 throw std::runtime_error(
2178 "GpuLibrary: Unable to get tensor network expectation value");
2183 bool TNApplyX(
void *obj,
unsigned int siteA) {
2185 return fTNApplyX(obj, siteA) == 1;
2187 throw std::runtime_error(
2188 "GpuLibrary: Unable to apply X gate on tensor network");
2193 bool TNApplyY(
void *obj,
unsigned int siteA) {
2195 return fTNApplyY(obj, siteA) == 1;
2197 throw std::runtime_error(
2198 "GpuLibrary: Unable to apply Y gate on tensor network");
2203 bool TNApplyZ(
void *obj,
unsigned int siteA) {
2205 return fTNApplyZ(obj, siteA) == 1;
2207 throw std::runtime_error(
2208 "GpuLibrary: Unable to apply Z gate on tensor network");
2213 bool TNApplyH(
void *obj,
unsigned int siteA) {
2215 return fTNApplyH(obj, siteA) == 1;
2217 throw std::runtime_error(
2218 "GpuLibrary: Unable to apply H gate on tensor network");
2223 bool TNApplyS(
void *obj,
unsigned int siteA) {
2225 return fTNApplyS(obj, siteA) == 1;
2227 throw std::runtime_error(
2228 "GpuLibrary: Unable to apply S gate on tensor network");
2233 bool TNApplySDG(
void *obj,
unsigned int siteA) {
2235 return fTNApplySDG(obj, siteA) == 1;
2237 throw std::runtime_error(
2238 "GpuLibrary: Unable to apply sdg gate on tensor network");
2243 bool TNApplyT(
void *obj,
unsigned int siteA) {
2245 return fTNApplyT(obj, siteA) == 1;
2247 throw std::runtime_error(
2248 "GpuLibrary: Unable to apply t gate on tensor network");
2253 bool TNApplyTDG(
void *obj,
unsigned int siteA) {
2255 return fTNApplyTDG(obj, siteA) == 1;
2257 throw std::runtime_error(
2258 "GpuLibrary: Unable to apply tdg gate on tensor network");
2263 bool TNApplySX(
void *obj,
unsigned int siteA) {
2265 return fTNApplySX(obj, siteA) == 1;
2267 throw std::runtime_error(
2268 "GpuLibrary: Unable to apply sx gate on tensor network");
2273 bool TNApplySXDG(
void *obj,
unsigned int siteA) {
2275 return fTNApplySXDG(obj, siteA) == 1;
2277 throw std::runtime_error(
2278 "GpuLibrary: Unable to apply sxdg gate on tensor network");
2283 bool TNApplyK(
void *obj,
unsigned int siteA) {
2285 return fTNApplyK(obj, siteA) == 1;
2287 throw std::runtime_error(
2288 "GpuLibrary: Unable to apply k gate on tensor network");
2293 bool TNApplyP(
void *obj,
unsigned int siteA,
double theta) {
2295 return fTNApplyP(obj, siteA, theta) == 1;
2297 throw std::runtime_error(
2298 "GpuLibrary: Unable to apply p gate on tensor network");
2302 bool TNApplyRx(
void *obj,
unsigned int siteA,
double theta) {
2304 return fTNApplyRx(obj, siteA, theta) == 1;
2306 throw std::runtime_error(
2307 "GpuLibrary: Unable to apply rx gate on tensor network");
2312 bool TNApplyRy(
void *obj,
unsigned int siteA,
double theta) {
2314 return fTNApplyRy(obj, siteA, theta) == 1;
2316 throw std::runtime_error(
2317 "GpuLibrary: Unable to apply ry gate on tensor network");
2322 bool TNApplyRz(
void *obj,
unsigned int siteA,
double theta) {
2324 return fTNApplyRz(obj, siteA, theta) == 1;
2326 throw std::runtime_error(
2327 "GpuLibrary: Unable to apply rz gate on tensor network");
2332 bool TNApplyU(
void *obj,
unsigned int siteA,
double theta,
double phi,
2333 double lambda,
double gamma) {
2335 return fTNApplyU(obj, siteA, theta, phi, lambda, gamma) == 1;
2337 throw std::runtime_error(
2338 "GpuLibrary: Unable to apply u gate on tensor network");
2343 bool TNApplySwap(
void *obj,
unsigned int controlQubit,
2344 unsigned int targetQubit) {
2346 return fTNApplySwap(obj, controlQubit, targetQubit) == 1;
2348 throw std::runtime_error(
2349 "GpuLibrary: Unable to apply swap gate on tensor network");
2354 bool TNApplyCX(
void *obj,
unsigned int controlQubit,
2355 unsigned int targetQubit) {
2357 return fTNApplyCX(obj, controlQubit, targetQubit) == 1;
2359 throw std::runtime_error(
2360 "GpuLibrary: Unable to apply cx gate on tensor network");
2365 bool TNApplyCY(
void *obj,
unsigned int controlQubit,
2366 unsigned int targetQubit) {
2368 return fTNApplyCY(obj, controlQubit, targetQubit) == 1;
2370 throw std::runtime_error(
2371 "GpuLibrary: Unable to apply cy gate on tensor network");
2376 bool TNApplyCZ(
void *obj,
unsigned int controlQubit,
2377 unsigned int targetQubit) {
2379 return fTNApplyCZ(obj, controlQubit, targetQubit) == 1;
2381 throw std::runtime_error(
2382 "GpuLibrary: Unable to apply cz gate on tensor network");
2387 bool TNApplyCH(
void *obj,
unsigned int controlQubit,
2388 unsigned int targetQubit) {
2390 return fTNApplyCH(obj, controlQubit, targetQubit) == 1;
2392 throw std::runtime_error(
2393 "GpuLibrary: Unable to apply ch gate on tensor network");
2398 bool TNApplyCSX(
void *obj,
unsigned int controlQubit,
2399 unsigned int targetQubit) {
2401 return fTNApplyCSX(obj, controlQubit, targetQubit) == 1;
2403 throw std::runtime_error(
2404 "GpuLibrary: Unable to apply csx gate on tensor network");
2407 bool TNApplyCSXDG(
void *obj,
unsigned int controlQubit,
2408 unsigned int targetQubit) {
2410 return fTNApplyCSXDG(obj, controlQubit, targetQubit) == 1;
2412 throw std::runtime_error(
2413 "GpuLibrary: Unable to apply csxdg gate on tensor network");
2418 bool TNApplyCP(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
2421 return fTNApplyCP(obj, controlQubit, targetQubit, theta) == 1;
2423 throw std::runtime_error(
2424 "GpuLibrary: Unable to apply cp gate on tensor network");
2429 bool TNApplyCRx(
void *obj,
unsigned int controlQubit,
2430 unsigned int targetQubit,
double theta) {
2432 return fTNApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
2434 throw std::runtime_error(
2435 "GpuLibrary: Unable to apply crx gate on tensor network");
2440 bool TNApplyCRy(
void *obj,
unsigned int controlQubit,
2441 unsigned int targetQubit,
double theta) {
2443 return fTNApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
2445 throw std::runtime_error(
2446 "GpuLibrary: Unable to apply cry gate on tensor network");
2451 bool TNApplyCRz(
void *obj,
unsigned int controlQubit,
2452 unsigned int targetQubit,
double theta) {
2454 return fTNApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
2456 throw std::runtime_error(
2457 "GpuLibrary: Unable to apply crz gate on tensor network");
2462 bool TNApplyCU(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
2463 double theta,
double phi,
double lambda,
double gamma) {
2465 return fTNApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda,
2468 throw std::runtime_error(
2469 "GpuLibrary: Unable to apply cu gate on tensor network");
2474 bool TNApplyCCX(
void *obj,
unsigned int controlQubit1,
2475 unsigned int controlQubit2,
unsigned int targetQubit) {
2477 return fTNApplyCCX(obj, controlQubit1, controlQubit2, targetQubit) == 1;
2479 throw std::runtime_error(
2480 "GpuLibrary: Unable to apply ccx gate on tensor network");
2484 bool TNApplyCSwap(
void *obj,
unsigned int controlQubit,
2485 unsigned int targetQubit1,
unsigned int targetQubit2) {
2487 return fTNApplyCSwap(obj, controlQubit, targetQubit1, targetQubit2) == 1;
2489 throw std::runtime_error(
2490 "GpuLibrary: Unable to apply cswap gate on tensor network");
2495 void *CreateStabilizerSimulator(
long long int numQubits,
2496 long long int numShots,
2497 long long int numMeasurements,
2498 long long int numDetectors) {
2500 return fCreateStabilizerSimulator(numQubits, numShots, numMeasurements,
2503 throw std::runtime_error(
2504 "GpuLibrary: Unable to create stabilizer simulator");
2509 void DestroyStabilizerSimulator(
void *obj) {
2512 fDestroyStabilizerSimulator(obj);
2514 throw std::runtime_error(
2515 "GpuLibrary: Unable to destroy stabilizer simulator");
2518 bool ExecuteStabilizerCircuit(
void *obj,
const char *circuitStr,
2519 int randomizeMeasurements,
2520 unsigned long long int seed) {
2521 if (!obj)
return false;
2523 return fExecuteStabilizerCircuit(obj, circuitStr, randomizeMeasurements,
2526 throw std::runtime_error(
2527 "GpuLibrary: Unable to execute stabilizer circuit");
2532 long long GetStabilizerXZTableSize(
void *obj) {
2535 return fGetStabilizerXZTableSize(obj);
2537 throw std::runtime_error(
2538 "GpuLibrary: Unable to get stabilizer XZ table size");
2543 long long GetStabilizerMTableSize(
void *obj) {
2546 return fGetStabilizerMTableSize(obj);
2548 throw std::runtime_error(
2549 "GpuLibrary: Unable to get stabilizer M table size");
2554 long long GetStabilizerTableStrideMajor(
void *obj) {
2557 return fGetStabilizerTableStrideMajor(obj);
2559 throw std::runtime_error(
2560 "GpuLibrary: Unable to get stabilizer table stride major");
2564 long long GetStabilizerNumQubits(
void *obj) {
2567 return fGetStabilizerNumQubits(obj);
2569 throw std::runtime_error(
2570 "GpuLibrary: Unable to get stabilizer number of qubits");
2575 long long GetStabilizerNumShots(
void *obj) {
2578 return fGetStabilizerNumShots(obj);
2580 throw std::runtime_error(
2581 "GpuLibrary: Unable to get stabilizer number of shots");
2586 long long GetStabilizerNumMeasurements(
void *obj) {
2589 return fGetStabilizerNumMeasurements(obj);
2591 throw std::runtime_error(
2592 "GpuLibrary: Unable to get stabilizer number of measurements");
2597 long long GetStabilizerNumDetectors(
void *obj) {
2600 return fGetStabilizerNumDetectors(obj);
2602 throw std::runtime_error(
2603 "GpuLibrary: Unable to get stabilizer number of detectors");
2608 int CopyStabilizerXTable(
void *obj,
unsigned int *xtable) {
2611 return fCopyStabilizerXTable(obj, xtable);
2613 throw std::runtime_error(
"GpuLibrary: Unable to copy stabilizer X table");
2617 int CopyStabilizerZTable(
void *obj,
unsigned int *ztable) {
2620 return fCopyStabilizerZTable(obj, ztable);
2622 throw std::runtime_error(
"GpuLibrary: Unable to copy stabilizer Z table");
2626 int CopyStabilizerMTable(
void *obj,
unsigned int *mtable) {
2629 return fCopyStabilizerMTable(obj, mtable);
2631 throw std::runtime_error(
"GpuLibrary: Unable to copy stabilizer M table");
2635 int InitStabilizerXTable(
void *obj,
const unsigned int *xtable) {
2638 return fInitStabilizerXTable(obj, xtable);
2640 throw std::runtime_error(
2641 "GpuLibrary: Unable to initialize stabilizer X table");
2645 int InitStabilizerZTable(
void *obj,
const unsigned int *ztable) {
2648 return fInitStabilizerZTable(obj, ztable);
2650 throw std::runtime_error(
2651 "GpuLibrary: Unable to initialize stabilizer Z table");
2656 void *CreatePauliPropSimulator(
int nrQubits) {
2658 return fCreatePauliPropSimulator(nrQubits);
2660 throw std::runtime_error(
2661 "GpuLibrary: Unable to create pauli propagation simulator");
2665 void DestroyPauliPropSimulator(
void *obj) {
2668 fDestroyPauliPropSimulator(obj);
2670 throw std::runtime_error(
2671 "GpuLibrary: Unable to destroy pauli propagation simulator");
2674 int PauliPropGetNrQubits(
void *obj) {
2677 return fPauliPropGetNrQubits(obj);
2679 throw std::runtime_error(
2680 "GpuLibrary: Unable to get number of qubits in pauli propagation "
2685 int PauliPropSetWillUseSampling(
void *obj,
int willUseSampling) {
2688 return fPauliPropSetWillUseSampling(obj, willUseSampling) == 1;
2690 throw std::runtime_error(
2691 "GpuLibrary: Unable to set 'will use sampling' in pauli propagation "
2696 int PauliPropGetWillUseSampling(
void *obj) {
2699 return fPauliPropGetWillUseSampling(obj);
2701 throw std::runtime_error(
2702 "GpuLibrary: Unable to get 'will use sampling' in pauli propagation "
2707 double PauliPropGetCoefficientTruncationCutoff(
void *obj) {
2708 if (!obj)
return 0.0;
2710 return fPauliPropGetCoefficientTruncationCutoff(obj);
2712 throw std::runtime_error(
2713 "GpuLibrary: Unable to get coefficient truncation cutoff in pauli "
2714 "propagation simulator");
2718 void PauliPropSetCoefficientTruncationCutoff(
void *obj,
double cutoff) {
2721 fPauliPropSetCoefficientTruncationCutoff(obj, cutoff);
2723 throw std::runtime_error(
2724 "GpuLibrary: Unable to set coefficient truncation cutoff in pauli "
2725 "propagation simulator");
2728 double PauliPropGetWeightTruncationCutoff(
void *obj) {
2729 if (!obj)
return 0.0;
2731 return fPauliPropGetWeightTruncationCutoff(obj);
2733 throw std::runtime_error(
2734 "GpuLibrary: Unable to get weight truncation cutoff in pauli "
2735 "propagation simulator");
2739 void PauliPropSetWeightTruncationCutoff(
void *obj,
double cutoff) {
2742 fPauliPropSetWeightTruncationCutoff(obj, cutoff);
2744 throw std::runtime_error(
2745 "GpuLibrary: Unable to set weight truncation cutoff in pauli "
2746 "propagation simulator");
2749 int PauliPropGetNumGatesBetweenTruncations(
void *obj) {
2752 return fPauliPropGetNumGatesBetweenTruncations(obj);
2754 throw std::runtime_error(
2755 "GpuLibrary: Unable to get number of gates between truncations in "
2756 "pauli propagation simulator");
2760 void PauliPropSetNumGatesBetweenTruncations(
void *obj,
int numGates) {
2763 fPauliPropSetNumGatesBetweenTruncations(obj, numGates);
2765 throw std::runtime_error(
2766 "GpuLibrary: Unable to set number of gates between truncations in "
2768 "propagation simulator");
2771 int PauliPropGetNumGatesBetweenDeduplications(
void *obj) {
2774 return fPauliPropGetNumGatesBetweenDeduplications(obj);
2776 throw std::runtime_error(
2777 "GpuLibrary: Unable to get number of gates between deduplications in "
2778 "pauli propagation simulator");
2782 void PauliPropSetNumGatesBetweenDeduplications(
void *obj,
int numGates) {
2785 fPauliPropSetNumGatesBetweenDeduplications(obj, numGates);
2787 throw std::runtime_error(
2788 "GpuLibrary: Unable to set number of gates between deduplications in "
2790 "propagation simulator");
2793 bool PauliPropClearOperators(
void *obj) {
2794 if (!obj)
return false;
2796 return fPauliPropClearOperators(obj) == 1;
2798 throw std::runtime_error(
2799 "GpuLibrary: Unable to clear operators in pauli propagation "
2804 bool PauliPropAllocateMemory(
void *obj,
double percentage) {
2805 if (!obj)
return false;
2807 return fPauliPropAllocateMemory(obj, percentage) == 1;
2809 throw std::runtime_error(
2810 "GpuLibrary: Unable to allocate memory in pauli propagation "
2815 double PauliPropGetExpectationValue(
void *obj) {
2816 if (!obj)
return 0.0;
2818 return fPauliPropGetExpectationValue(obj);
2820 throw std::runtime_error(
2821 "GpuLibrary: Unable to get expectation value in pauli propagation "
2826 bool PauliPropExecute(
void *obj) {
2827 if (!obj)
return false;
2829 return fPauliPropExecute(obj) == 1;
2831 throw std::runtime_error(
2832 "GpuLibrary: Unable to execute pauli propagation simulator");
2836 bool PauliPropSetInPauliExpansionUnique(
void *obj,
const char *pauliString) {
2837 if (!obj)
return false;
2839 return fPauliPropSetInPauliExpansionUnique(obj, pauliString) == 1;
2841 throw std::runtime_error(
2842 "GpuLibrary: Unable to set unique pauli in pauli propagation "
2847 bool PauliPropSetInPauliExpansionMultiple(
void *obj,
2848 const char **pauliStrings,
2849 const double *coefficients,
2851 if (!obj)
return false;
2853 return fPauliPropSetInPauliExpansionMultiple(obj, pauliStrings,
2854 coefficients, nrPaulis) == 1;
2856 throw std::runtime_error(
2857 "GpuLibrary: Unable to set multiple pauli in pauli propagation "
2862 bool PauliPropApplyX(
void *obj,
int qubit) {
2863 if (!obj)
return false;
2865 return fPauliPropApplyX(obj, qubit) == 1;
2867 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate on mps");
2871 bool PauliPropApplyY(
void *obj,
int qubit) {
2872 if (!obj)
return false;
2874 return fPauliPropApplyY(obj, qubit) == 1;
2876 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate on mps");
2880 bool PauliPropApplyZ(
void *obj,
int qubit) {
2881 if (!obj)
return false;
2883 return fPauliPropApplyZ(obj, qubit) == 1;
2885 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate on mps");
2889 bool PauliPropApplyH(
void *obj,
int qubit) {
2890 if (!obj)
return false;
2892 return fPauliPropApplyH(obj, qubit) == 1;
2894 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate on mps");
2898 bool PauliPropApplyS(
void *obj,
int qubit) {
2899 if (!obj)
return false;
2901 return fPauliPropApplyS(obj, qubit) == 1;
2903 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate on mps");
2907 bool PauliPropApplySQRTX(
void *obj,
int qubit) {
2908 if (!obj)
return false;
2910 return fPauliPropApplySQRTX(obj, qubit) == 1;
2912 throw std::runtime_error(
"GpuLibrary: Unable to apply SQRTX gate on mps");
2916 bool PauliPropApplySQRTY(
void *obj,
int qubit) {
2917 if (!obj)
return false;
2919 return fPauliPropApplySQRTY(obj, qubit) == 1;
2921 throw std::runtime_error(
"GpuLibrary: Unable to apply SQRTY gate on mps");
2925 bool PauliPropApplySQRTZ(
void *obj,
int qubit) {
2926 if (!obj)
return false;
2928 return fPauliPropApplySQRTZ(obj, qubit) == 1;
2930 throw std::runtime_error(
"GpuLibrary: Unable to apply SQRTZ gate on mps");
2934 bool PauliPropApplyCX(
void *obj,
int targetQubit,
int controlQubit) {
2935 if (!obj)
return false;
2937 return fPauliPropApplyCX(obj, targetQubit, controlQubit) == 1;
2939 throw std::runtime_error(
"GpuLibrary: Unable to apply CX gate on mps");
2943 bool PauliPropApplyCY(
void *obj,
int targetQubit,
int controlQubit) {
2944 if (!obj)
return false;
2946 return fPauliPropApplyCY(obj, targetQubit, controlQubit) == 1;
2948 throw std::runtime_error(
"GpuLibrary: Unable to apply CY gate on mps");
2952 bool PauliPropApplyCZ(
void *obj,
int targetQubit,
int controlQubit) {
2953 if (!obj)
return false;
2955 return fPauliPropApplyCZ(obj, targetQubit, controlQubit) == 1;
2957 throw std::runtime_error(
"GpuLibrary: Unable to apply CZ gate on mps");
2961 bool PauliPropApplySWAP(
void *obj,
int qubit1,
int qubit2) {
2962 if (!obj)
return false;
2964 return fPauliPropApplySWAP(obj, qubit1, qubit2) == 1;
2966 throw std::runtime_error(
"GpuLibrary: Unable to apply SWAP gate on mps");
2970 bool PauliPropApplyISWAP(
void *obj,
int qubit1,
int qubit2) {
2971 if (!obj)
return false;
2973 return fPauliPropApplyISWAP(obj, qubit1, qubit2) == 1;
2975 throw std::runtime_error(
"GpuLibrary: Unable to apply ISWAP gate on mps");
2979 bool PauliPropApplyRX(
void *obj,
int qubit,
double angle) {
2980 if (!obj)
return false;
2982 return fPauliPropApplyRX(obj, qubit, angle) == 1;
2984 throw std::runtime_error(
"GpuLibrary: Unable to apply RX gate on mps");
2988 bool PauliPropApplyRY(
void *obj,
int qubit,
double angle) {
2989 if (!obj)
return false;
2991 return fPauliPropApplyRY(obj, qubit, angle) == 1;
2993 throw std::runtime_error(
"GpuLibrary: Unable to apply RY gate on mps");
2997 bool PauliPropApplyRZ(
void *obj,
int qubit,
double angle) {
2998 if (!obj)
return false;
3000 return fPauliPropApplyRZ(obj, qubit, angle) == 1;
3002 throw std::runtime_error(
"GpuLibrary: Unable to apply RZ gate on mps");
3006 bool PauliPropAddNoiseX(
void *obj,
int qubit,
double probability) {
3007 if (!obj)
return false;
3009 return fPauliPropAddNoiseX(obj, qubit, probability) == 1;
3011 throw std::runtime_error(
"GpuLibrary: Unable to add X noise on mps");
3015 bool PauliPropAddNoiseY(
void *obj,
int qubit,
double probability) {
3016 if (!obj)
return false;
3018 return fPauliPropAddNoiseY(obj, qubit, probability) == 1;
3020 throw std::runtime_error(
"GpuLibrary: Unable to add Y noise on mps");
3024 bool PauliPropAddNoiseZ(
void *obj,
int qubit,
double probability) {
3025 if (!obj)
return false;
3027 return fPauliPropAddNoiseZ(obj, qubit, probability) == 1;
3029 throw std::runtime_error(
"GpuLibrary: Unable to add Z noise on mps");
3033 bool PauliPropAddNoiseXYZ(
void *obj,
int qubit,
double probabilityX,
3034 double probabilityY,
double probabilityZ) {
3035 if (!obj)
return false;
3037 return fPauliPropAddNoiseXYZ(obj, qubit, probabilityX, probabilityY,
3040 throw std::runtime_error(
"GpuLibrary: Unable to add XYZ noise on mps");
3044 bool PauliPropAddAmplitudeDamping(
void *obj,
int qubit,
double dampingProb,
3045 double exciteProb) {
3046 if (!obj)
return false;
3048 return fPauliPropAddAmplitudeDamping(obj, qubit, dampingProb,
3051 throw std::runtime_error(
3052 "GpuLibrary: Unable to add amplitude damping on mps");
3056 double PauliPropQubitProbability0(
void *obj,
int qubit) {
3057 if (!obj)
return 0.0;
3059 return fPauliPropQubitProbability0(obj, qubit);
3061 throw std::runtime_error(
3062 "GpuLibrary: Unable to get qubit probability 0 in pauli propagation "
3067 double PauliPropProbability(
void *obj,
unsigned long long int outcome) {
3068 if (!obj)
return 0.0;
3070 return fPauliPropProbability(obj, outcome);
3072 throw std::runtime_error(
3073 "GpuLibrary: Unable to get probability of outcome in pauli "
3074 "propagation simulator");
3078 bool PauliPropMeasureQubit(
void *obj,
int qubit) {
3079 if (!obj)
return false;
3081 return fPauliPropMeasureQubit(obj, qubit) == 1;
3083 throw std::runtime_error(
3084 "GpuLibrary: Unable to measure qubit in pauli propagation simulator");
3088 unsigned char *PauliPropSampleQubits(
void *obj,
const int *qubits,
3090 if (!obj)
return nullptr;
3092 return fPauliPropSampleQubits(obj, qubits, nrQubits);
3094 throw std::runtime_error(
3095 "GpuLibrary: Unable to sample qubits in pauli propagation simulator");
3099 void PauliPropFreeSampledQubits(
unsigned char *samples) {
3100 if (!samples)
return;
3102 fPauliPropFreeSampledQubits(samples);
3104 throw std::runtime_error(
3105 "GpuLibrary: Unable to free sampled qubits in pauli propagation "
3109 void PauliPropSaveState(
void *obj) {
3112 fPauliPropSaveState(obj);
3114 throw std::runtime_error(
3115 "GpuLibrary: Unable to save state in pauli propagation simulator");
3118 void PauliPropRestoreState(
void *obj) {
3121 fPauliPropRestoreState(obj);
3123 throw std::runtime_error(
3124 "GpuLibrary: Unable to restore state in pauli propagation simulator");
3128 void *LibraryHandle =
nullptr;
3130 int (*fValidateLicense)(
const char *) =
nullptr;
3131 void *(*InitLib)() =
nullptr;
3132 void (*FreeLib)() =
nullptr;
3134 void *(*fCreateStateVector)(
void *) =
nullptr;
3135 void (*fDestroyStateVector)(
void *) =
nullptr;
3137 int (*fSetDataType)(
void *, int) =
nullptr;
3138 int (*fIsDoublePrecision)(
void *) =
nullptr;
3139 int (*fGetNrQubits)(
void *) =
nullptr;
3140 int (*fCreate)(
void *,
unsigned int) =
nullptr;
3141 int (*fReset)(
void *) =
nullptr;
3142 int (*fCreateWithState)(
void *,
unsigned int,
const double *) =
nullptr;
3143 int (*fMeasureQubitCollapse)(
void *, int) =
nullptr;
3144 int (*fMeasureQubitNoCollapse)(
void *, int) =
nullptr;
3145 int (*fMeasureQubitsCollapse)(
void *,
int *,
int *, int) =
nullptr;
3146 int (*fMeasureQubitsNoCollapse)(
void *,
int *,
int *, int) =
nullptr;
3147 unsigned long long (*fMeasureAllQubitsCollapse)(
void *) =
nullptr;
3148 unsigned long long (*fMeasureAllQubitsNoCollapse)(
void *) =
nullptr;
3150 int (*fSaveState)(
void *) =
nullptr;
3151 int (*fSaveStateToHost)(
void *) =
nullptr;
3152 int (*fSaveStateDestructive)(
void *) =
nullptr;
3153 int (*fRestoreStateFreeSaved)(
void *) =
nullptr;
3154 int (*fRestoreStateNoFreeSaved)(
void *) =
nullptr;
3155 void (*fFreeSavedState)(
void *obj) =
nullptr;
3156 void *(*fClone)(
void *) =
nullptr;
3157 int (*fSample)(
void *,
unsigned int,
long int *,
unsigned int,
3159 int (*fSampleAll)(
void *,
unsigned int,
long int *) =
nullptr;
3160 int (*fAmplitude)(
void *,
long long int,
double *,
double *) =
nullptr;
3161 double (*fProbability)(
void *,
int *,
int *, int) =
nullptr;
3162 double (*fBasisStateProbability)(
void *,
long long int) =
nullptr;
3163 int (*fAllProbabilities)(
void *,
double *) =
nullptr;
3164 double (*fExpectationValue)(
void *,
const char *, int) =
nullptr;
3166 int (*fApplyX)(
void *, int) =
nullptr;
3167 int (*fApplyY)(
void *, int) =
nullptr;
3168 int (*fApplyZ)(
void *, int) =
nullptr;
3169 int (*fApplyH)(
void *, int) =
nullptr;
3170 int (*fApplyS)(
void *, int) =
nullptr;
3171 int (*fApplySDG)(
void *, int) =
nullptr;
3172 int (*fApplyT)(
void *, int) =
nullptr;
3173 int (*fApplyTDG)(
void *, int) =
nullptr;
3174 int (*fApplySX)(
void *, int) =
nullptr;
3175 int (*fApplySXDG)(
void *, int) =
nullptr;
3176 int (*fApplyK)(
void *, int) =
nullptr;
3177 int (*fApplyP)(
void *, int, double) =
nullptr;
3178 int (*fApplyRx)(
void *, int, double) =
nullptr;
3179 int (*fApplyRy)(
void *, int, double) =
nullptr;
3180 int (*fApplyRz)(
void *, int, double) =
nullptr;
3181 int (*fApplyU)(
void *, int, double, double, double, double) =
nullptr;
3182 int (*fApplyCX)(
void *, int, int) =
nullptr;
3183 int (*fApplyCY)(
void *, int, int) =
nullptr;
3184 int (*fApplyCZ)(
void *, int, int) =
nullptr;
3185 int (*fApplyCH)(
void *, int, int) =
nullptr;
3186 int (*fApplyCSX)(
void *, int, int) =
nullptr;
3187 int (*fApplyCSXDG)(
void *, int, int) =
nullptr;
3188 int (*fApplyCP)(
void *, int, int, double) =
nullptr;
3189 int (*fApplyCRx)(
void *, int, int, double) =
nullptr;
3190 int (*fApplyCRy)(
void *, int, int, double) =
nullptr;
3191 int (*fApplyCRz)(
void *, int, int, double) =
nullptr;
3192 int (*fApplyCCX)(
void *, int, int, int) =
nullptr;
3193 int (*fApplySwap)(
void *, int, int) =
nullptr;
3194 int (*fApplyCSwap)(
void *, int, int, int) =
nullptr;
3195 int (*fApplyCU)(
void *, int, int, double, double, double, double) =
nullptr;
3197 void *(*fCreateMPS)(
void *) =
nullptr;
3198 void (*fDestroyMPS)(
void *) =
nullptr;
3200 int (*fMPSCreate)(
void *,
unsigned int) =
nullptr;
3201 int (*fMPSReset)(
void *) =
nullptr;
3202 int (*fMPSSetInitialQubitsMap)(
void *,
const long long int *,
3203 unsigned int) =
nullptr;
3204 int (*fMPSSetUseOptimalMeetingPosition)(
void *, int) =
nullptr;
3206 int (*fMPSIsValid)(
void *) =
nullptr;
3207 int (*fMPSIsCreated)(
void *) =
nullptr;
3209 int (*fMPSSetDataType)(
void *, int) =
nullptr;
3210 int (*fMPSIsDoublePrecision)(
void *) =
nullptr;
3211 int (*fMPSSetCutoff)(
void *, double) =
nullptr;
3212 double (*fMPSGetCutoff)(
void *) =
nullptr;
3213 int (*fMPSSetGesvdJ)(
void *, int) =
nullptr;
3214 int (*fMPSGetGesvdJ)(
void *) =
nullptr;
3215 int (*fMPSSetMaxExtent)(
void *,
long int) =
nullptr;
3216 long int (*fMPSGetMaxExtent)(
void *) =
nullptr;
3217 int (*fMPSGetNrQubits)(
void *) =
nullptr;
3218 int (*fMPSAmplitude)(
void *,
long int,
long int *,
double *,
3219 double *) =
nullptr;
3220 double (*fMPSProbability0)(
void *,
unsigned int) =
nullptr;
3221 int (*fMPSMeasure)(
void *,
unsigned int) =
nullptr;
3222 int (*fMPSMeasureQubits)(
void *,
long int,
unsigned int *,
int *) =
nullptr;
3223 void *(*fMPSGetMapForSample)() =
nullptr;
3224 int (*fMPSFreeMapForSample)(
void *) =
nullptr;
3225 int (*fMPSSample)(
void *,
long int,
long int,
unsigned int *,
3228 int (*fMPSSaveState)(
void *) =
nullptr;
3229 int (*fMPSRestoreState)(
void *) =
nullptr;
3230 int (*fMPSCleanSavedState)(
void *) =
nullptr;
3231 void *(*fMPSClone)(
void *) =
nullptr;
3233 double (*fMPSExpectationValue)(
void *,
const char *, int) =
nullptr;
3234 int (*fMPSProjectOnZero)(
void *,
double *,
double *) =
nullptr;
3236 int (*fMPSApplyX)(
void *,
unsigned int) =
nullptr;
3237 int (*fMPSApplyY)(
void *,
unsigned int) =
nullptr;
3238 int (*fMPSApplyZ)(
void *,
unsigned int) =
nullptr;
3239 int (*fMPSApplyH)(
void *,
unsigned int) =
nullptr;
3240 int (*fMPSApplyS)(
void *,
unsigned int) =
nullptr;
3241 int (*fMPSApplySDG)(
void *,
unsigned int) =
nullptr;
3242 int (*fMPSApplyT)(
void *,
unsigned int) =
nullptr;
3243 int (*fMPSApplyTDG)(
void *,
unsigned int) =
nullptr;
3244 int (*fMPSApplySX)(
void *,
unsigned int) =
nullptr;
3245 int (*fMPSApplySXDG)(
void *,
unsigned int) =
nullptr;
3246 int (*fMPSApplyK)(
void *,
unsigned int) =
nullptr;
3247 int (*fMPSApplyP)(
void *,
unsigned int, double) =
nullptr;
3248 int (*fMPSApplyRx)(
void *,
unsigned int, double) =
nullptr;
3249 int (*fMPSApplyRy)(
void *,
unsigned int, double) =
nullptr;
3250 int (*fMPSApplyRz)(
void *,
unsigned int, double) =
nullptr;
3251 int (*fMPSApplyU)(
void *,
unsigned int, double, double, double,
3253 int (*fMPSApplySwap)(
void *,
unsigned int,
unsigned int) =
nullptr;
3254 int (*fMPSApplyCX)(
void *,
unsigned int,
unsigned int) =
nullptr;
3255 int (*fMPSApplyCY)(
void *,
unsigned int,
unsigned int) =
nullptr;
3256 int (*fMPSApplyCZ)(
void *,
unsigned int,
unsigned int) =
nullptr;
3257 int (*fMPSApplyCH)(
void *,
unsigned int,
unsigned int) =
nullptr;
3258 int (*fMPSApplyCSX)(
void *,
unsigned int,
unsigned int) =
nullptr;
3259 int (*fMPSApplyCSXDG)(
void *,
unsigned int,
unsigned int) =
nullptr;
3260 int (*fMPSApplyCP)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3261 int (*fMPSApplyCRx)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3262 int (*fMPSApplyCRy)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3263 int (*fMPSApplyCRz)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3264 int (*fMPSApplyCU)(
void *,
unsigned int,
unsigned int, double, double, double,
3268 void *(*fCreateTensorNet)(
void *) =
nullptr;
3269 void (*fDestroyTensorNet)(
void *) =
nullptr;
3271 int (*fTNCreate)(
void *,
unsigned int) =
nullptr;
3272 int (*fTNReset)(
void *) =
nullptr;
3273 int (*fTNIsValid)(
void *) =
nullptr;
3274 int (*fTNIsCreated)(
void *) =
nullptr;
3276 int (*fTNSetDataType)(
void *, int) =
nullptr;
3277 int (*fTNIsDoublePrecision)(
void *) =
nullptr;
3278 int (*fTNSetCutoff)(
void *, double) =
nullptr;
3279 double (*fTNGetCutoff)(
void *) =
nullptr;
3280 int (*fTNSetGesvdJ)(
void *, int) =
nullptr;
3281 int (*fTNGetGesvdJ)(
void *) =
nullptr;
3282 int (*fTNSetMaxExtent)(
void *,
long int) =
nullptr;
3283 long int (*fTNGetMaxExtent)(
void *) =
nullptr;
3284 int (*fTNGetNrQubits)(
void *) =
nullptr;
3285 int (*fTNAmplitude)(
void *,
long int,
long int *,
double *,
3286 double *) =
nullptr;
3287 double (*fTNProbability0)(
void *,
unsigned int) =
nullptr;
3288 int (*fTNMeasure)(
void *,
unsigned int) =
nullptr;
3289 int (*fTNMeasureQubits)(
void *,
long int,
unsigned int *,
int *) =
nullptr;
3290 void *(*fTNGetMapForSample)() =
nullptr;
3291 int (*fTNFreeMapForSample)(
void *) =
nullptr;
3292 int (*fTNSample)(
void *,
long int,
long int,
unsigned int *,
3295 int (*fTNSaveState)(
void *) =
nullptr;
3296 int (*fTNRestoreState)(
void *) =
nullptr;
3297 int (*fTNCleanSavedState)(
void *) =
nullptr;
3298 void *(*fTNClone)(
void *) =
nullptr;
3300 double (*fTNExpectationValue)(
void *,
const char *, int) =
nullptr;
3302 int (*fTNApplyX)(
void *,
unsigned int) =
nullptr;
3303 int (*fTNApplyY)(
void *,
unsigned int) =
nullptr;
3304 int (*fTNApplyZ)(
void *,
unsigned int) =
nullptr;
3305 int (*fTNApplyH)(
void *,
unsigned int) =
nullptr;
3306 int (*fTNApplyS)(
void *,
unsigned int) =
nullptr;
3307 int (*fTNApplySDG)(
void *,
unsigned int) =
nullptr;
3308 int (*fTNApplyT)(
void *,
unsigned int) =
nullptr;
3309 int (*fTNApplyTDG)(
void *,
unsigned int) =
nullptr;
3310 int (*fTNApplySX)(
void *,
unsigned int) =
nullptr;
3311 int (*fTNApplySXDG)(
void *,
unsigned int) =
nullptr;
3312 int (*fTNApplyK)(
void *,
unsigned int) =
nullptr;
3313 int (*fTNApplyP)(
void *,
unsigned int, double) =
nullptr;
3314 int (*fTNApplyRx)(
void *,
unsigned int, double) =
nullptr;
3315 int (*fTNApplyRy)(
void *,
unsigned int, double) =
nullptr;
3316 int (*fTNApplyRz)(
void *,
unsigned int, double) =
nullptr;
3317 int (*fTNApplyU)(
void *,
unsigned int, double, double, double,
3319 int (*fTNApplySwap)(
void *,
unsigned int,
unsigned int) =
nullptr;
3320 int (*fTNApplyCX)(
void *,
unsigned int,
unsigned int) =
nullptr;
3321 int (*fTNApplyCY)(
void *,
unsigned int,
unsigned int) =
nullptr;
3322 int (*fTNApplyCZ)(
void *,
unsigned int,
unsigned int) =
nullptr;
3323 int (*fTNApplyCH)(
void *,
unsigned int,
unsigned int) =
nullptr;
3324 int (*fTNApplyCSX)(
void *,
unsigned int,
unsigned int) =
nullptr;
3325 int (*fTNApplyCSXDG)(
void *,
unsigned int,
unsigned int) =
nullptr;
3326 int (*fTNApplyCP)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3327 int (*fTNApplyCRx)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3328 int (*fTNApplyCRy)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3329 int (*fTNApplyCRz)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
3330 int (*fTNApplyCU)(
void *,
unsigned int,
unsigned int, double, double, double,
3332 int (*fTNApplyCCX)(
void *,
unsigned int,
unsigned int,
3333 unsigned int) =
nullptr;
3334 int (*fTNApplyCSwap)(
void *,
unsigned int,
unsigned int,
3335 unsigned int) =
nullptr;
3337 void *(*fCreateStabilizerSimulator)(
long long int,
long long int,
3338 long long int,
long long int) =
nullptr;
3339 void (*fDestroyStabilizerSimulator)(
void *) =
nullptr;
3340 int (*fExecuteStabilizerCircuit)(
void *,
const char *, int,
3341 unsigned long long int) =
nullptr;
3342 long long (*fGetStabilizerXZTableSize)(
void *) =
nullptr;
3343 long long (*fGetStabilizerMTableSize)(
void *) =
nullptr;
3344 long long (*fGetStabilizerTableStrideMajor)(
void *) =
nullptr;
3345 long long (*fGetStabilizerNumQubits)(
void *) =
nullptr;
3346 long long (*fGetStabilizerNumShots)(
void *) =
nullptr;
3347 long long (*fGetStabilizerNumMeasurements)(
void *) =
nullptr;
3348 long long (*fGetStabilizerNumDetectors)(
void *) =
nullptr;
3349 int (*fCopyStabilizerXTable)(
void *,
unsigned int *) =
nullptr;
3350 int (*fCopyStabilizerZTable)(
void *,
unsigned int *) =
nullptr;
3351 int (*fCopyStabilizerMTable)(
void *,
unsigned int *) =
nullptr;
3352 int (*fInitStabilizerXTable)(
void *,
const unsigned int *) =
nullptr;
3353 int (*fInitStabilizerZTable)(
void *,
const unsigned int *) =
nullptr;
3355 void *(*fCreatePauliPropSimulator)(int) =
nullptr;
3356 void (*fDestroyPauliPropSimulator)(
void *) =
nullptr;
3358 int (*fPauliPropGetNrQubits)(
void *) =
nullptr;
3359 int (*fPauliPropSetWillUseSampling)(
void *, int) =
nullptr;
3360 int (*fPauliPropGetWillUseSampling)(
void *) =
nullptr;
3361 double (*fPauliPropGetCoefficientTruncationCutoff)(
void *) =
nullptr;
3362 void (*fPauliPropSetCoefficientTruncationCutoff)(
void *, double) =
nullptr;
3363 double (*fPauliPropGetWeightTruncationCutoff)(
void *) =
nullptr;
3364 void (*fPauliPropSetWeightTruncationCutoff)(
void *, double) =
nullptr;
3365 int (*fPauliPropGetNumGatesBetweenTruncations)(
void *) =
nullptr;
3366 void (*fPauliPropSetNumGatesBetweenTruncations)(
void *, int) =
nullptr;
3367 int (*fPauliPropGetNumGatesBetweenDeduplications)(
void *) =
nullptr;
3368 void (*fPauliPropSetNumGatesBetweenDeduplications)(
void *, int) =
nullptr;
3369 int (*fPauliPropClearOperators)(
void *) =
nullptr;
3370 int (*fPauliPropAllocateMemory)(
void *, double) =
nullptr;
3371 double (*fPauliPropGetExpectationValue)(
void *) =
nullptr;
3372 int (*fPauliPropExecute)(
void *) =
nullptr;
3373 int (*fPauliPropSetInPauliExpansionUnique)(
void *,
const char *) =
nullptr;
3374 int (*fPauliPropSetInPauliExpansionMultiple)(
void *,
const char **,
3375 const double *, int) =
nullptr;
3377 int (*fPauliPropApplyX)(
void *, int) =
nullptr;
3378 int (*fPauliPropApplyY)(
void *, int) =
nullptr;
3379 int (*fPauliPropApplyZ)(
void *, int) =
nullptr;
3380 int (*fPauliPropApplyH)(
void *, int) =
nullptr;
3381 int (*fPauliPropApplyS)(
void *, int) =
nullptr;
3382 int (*fPauliPropApplySQRTX)(
void *, int) =
nullptr;
3383 int (*fPauliPropApplySQRTY)(
void *, int) =
nullptr;
3384 int (*fPauliPropApplySQRTZ)(
void *, int) =
nullptr;
3385 int (*fPauliPropApplyCX)(
void *, int, int) =
nullptr;
3386 int (*fPauliPropApplyCY)(
void *, int, int) =
nullptr;
3387 int (*fPauliPropApplyCZ)(
void *, int, int) =
nullptr;
3388 int (*fPauliPropApplySWAP)(
void *, int, int) =
nullptr;
3389 int (*fPauliPropApplyISWAP)(
void *, int, int) =
nullptr;
3390 int (*fPauliPropApplyRX)(
void *, int, double) =
nullptr;
3391 int (*fPauliPropApplyRY)(
void *, int, double) =
nullptr;
3392 int (*fPauliPropApplyRZ)(
void *, int, double) =
nullptr;
3393 int (*fPauliPropAddNoiseX)(
void *, int, double) =
nullptr;
3394 int (*fPauliPropAddNoiseY)(
void *, int, double) =
nullptr;
3395 int (*fPauliPropAddNoiseZ)(
void *, int, double) =
nullptr;
3396 int (*fPauliPropAddNoiseXYZ)(
void *, int, double, double, double) =
nullptr;
3397 int (*fPauliPropAddAmplitudeDamping)(
void *, int, double, double) =
nullptr;
3398 double (*fPauliPropQubitProbability0)(
void *, int) =
nullptr;
3399 double (*fPauliPropProbability)(
void *,
unsigned long long int) =
nullptr;
3401 int (*fPauliPropMeasureQubit)(
void *, int) =
nullptr;
3402 unsigned char *(*fPauliPropSampleQubits)(
void *,
const int *, int) =
nullptr;
3403 void (*fPauliPropFreeSampledQubits)(
unsigned char *) =
nullptr;
3404 void (*fPauliPropSaveState)(
void *) =
nullptr;
3405 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