50#include <unordered_map>
61 GpuLibrary()
noexcept =
default;
64 static std::shared_ptr<GpuLibrary> GetInstance() {
65 static const auto instance = std::shared_ptr<GpuLibrary>(
new GpuLibrary());
69 GpuLibrary(
const GpuLibrary &) =
delete;
70 GpuLibrary &operator=(
const GpuLibrary &) =
delete;
71 GpuLibrary(GpuLibrary &&) =
delete;
72 GpuLibrary &operator=(GpuLibrary &&) =
delete;
74 ~GpuLibrary()
override {
75 if (LibraryHandle && FreeLib) FreeLib();
81 std::unique_lock<std::recursive_mutex> LockInitialization() {
82 return std::unique_lock<std::recursive_mutex>(initializationMutex);
85 bool Load(
const char *libName)
noexcept {
86 auto lock = LockInitialization();
88 if (loadedPath == libName)
return true;
90 std::cerr <<
"GpuLibrary: singleton already loaded from " << loadedPath
91 <<
"; cannot load " << libName << std::endl;
96 fGetGpuDeviceCount = (int (*)())GetFunction(
"GetGpuDeviceCount");
97 fSetGpuDevice = (int (*)(int))GetFunction(
"SetGpuDevice");
98 fGetStateVectorGpuId = (int (*)(
void*))GetFunction(
"GetStateVectorGpuId");
99 fMPSGetGpuId = (int (*)(
void*))GetFunction(
"MPSGetGpuId");
100 fTNGetGpuId = (int (*)(
void*))GetFunction(
"TNGetGpuId");
101 fDMGetGpuId = (int (*)(
void*))GetFunction(
"DMGetGpuId");
102 fMPOGetGpuId = (int (*)(
void*))GetFunction(
"MPOGetGpuId");
103 fGetStabilizerGpuId = (int (*)(
void*))GetFunction(
"GetStabilizerGpuId");
104 fPauliPropGetGpuId = (int (*)(
void*))GetFunction(
"PauliPropGetGpuId");
109 int DiscoverDevices(
const char *path) {
110 auto lock = LockInitialization();
112 return Load(path) ? GetGpuDeviceCount() : 0;
115 bool InitializeForDevice(
const char *path,
int device,
bool mute =
false) {
116 auto lock = LockInitialization();
118 if (device < 0)
throw std::invalid_argument(
"gpu_device must be nonnegative");
119 if (!Load(path))
return false;
120 const int count = GetGpuDeviceCount();
121 if (device >= count) {
123 std::cerr <<
"GpuLibrary: GPU device " << device <<
" is unavailable ("
124 << count <<
" visible devices)" << std::endl;
129 if (!SetGpuDevice(device)) {
131 std::cerr <<
"GpuLibrary: Unable to select GPU device " << device << std::endl;
137 bool Init(
const char *libName)
noexcept override {
138 auto lock = LockInitialization();
139 if (!Load(libName))
return false;
140 if (IsValid())
return true;
145 fValidateLicense = (int (*)(
const char *))GetFunction(
"ValidateLicense");
146 if (!fValidateLicense) {
148 std::cerr <<
"GpuLibrary: License validation symbol not found. "
149 "The GPU library must export ValidateLicense."
153 const char *licenseKey = std::getenv(
"MAESTRO_LICENSE_KEY");
154 int licenseStatus = fValidateLicense(licenseKey);
155 if (licenseStatus != 1) {
157 std::cerr <<
"GpuLibrary: License validation failed. ";
159 std::cerr <<
"Set MAESTRO_LICENSE_KEY environment variable "
160 "or activate the license first."
163 std::cerr <<
"Check that your license key is correct." << std::endl;
168 FreeLib = (void (*)())GetFunction(
"FreeLib");
169 if (!fSetGpuDevice || !FreeLib) {
171 std::cerr <<
"GpuLibrary: SetGpuDevice and FreeLib are required." << std::endl;
175 InitLib = (
void *(*)())GetFunction(
"InitLib");
176 CheckFunction((
void *)InitLib, __LINE__);
178 LibraryHandle = InitLib();
180 FreeLib = (void (*)())GetFunction(
"FreeLib");
181 CheckFunction((
void *)FreeLib, __LINE__);
186 (
void *(*)(
void *))GetFunction(
"CreateStateVector");
187 CheckFunction((
void *)fCreateStateVector, __LINE__);
188 fDestroyStateVector =
189 (void (*)(
void *))GetFunction(
"DestroyStateVector");
190 CheckFunction((
void *)fDestroyStateVector, __LINE__);
192 fCreate = (int (*)(
void *,
unsigned int))GetFunction(
"Create");
193 CheckFunction((
void *)fCreate, __LINE__);
195 (int (*)(
void *,
unsigned int,
const double *))GetFunction(
197 CheckFunction((
void *)fCreateWithState, __LINE__);
198 fReset = (int (*)(
void *))GetFunction(
"Reset");
199 CheckFunction((
void *)fReset, __LINE__);
201 fSetDataType = (int (*)(
void *, int))GetFunction(
"SetDataType");
202 CheckFunction((
void *)fSetDataType, __LINE__);
204 (int (*)(
void *))GetFunction(
"IsDoublePrecision");
205 CheckFunction((
void *)fIsDoublePrecision, __LINE__);
206 fGetNrQubits = (int (*)(
void *))GetFunction(
"GetNrQubits");
207 CheckFunction((
void *)fGetNrQubits, __LINE__);
209 fMeasureQubitCollapse =
210 (int (*)(
void *, int))GetFunction(
"MeasureQubitCollapse");
211 CheckFunction((
void *)fMeasureQubitCollapse, __LINE__);
212 fMeasureQubitNoCollapse =
213 (int (*)(
void *, int))GetFunction(
"MeasureQubitNoCollapse");
214 CheckFunction((
void *)fMeasureQubitNoCollapse, __LINE__);
215 fMeasureQubitsCollapse = (int (*)(
216 void *,
int *,
int *, int))GetFunction(
"MeasureQubitsCollapse");
217 CheckFunction((
void *)fMeasureQubitsCollapse, __LINE__);
218 fMeasureQubitsNoCollapse = (int (*)(
219 void *,
int *,
int *, int))GetFunction(
"MeasureQubitsNoCollapse");
220 CheckFunction((
void *)fMeasureQubitsNoCollapse, __LINE__);
221 fMeasureAllQubitsCollapse = (
unsigned long long (*)(
222 void *))GetFunction(
"MeasureAllQubitsCollapse");
223 CheckFunction((
void *)fMeasureAllQubitsCollapse, __LINE__);
224 fMeasureAllQubitsNoCollapse = (
unsigned long long (*)(
225 void *))GetFunction(
"MeasureAllQubitsNoCollapse");
226 CheckFunction((
void *)fMeasureAllQubitsNoCollapse, __LINE__);
228 fSaveState = (int (*)(
void *))GetFunction(
"SaveState");
229 CheckFunction((
void *)fSaveState, __LINE__);
230 fSaveStateToHost = (int (*)(
void *))GetFunction(
"SaveStateToHost");
231 CheckFunction((
void *)fSaveStateToHost, __LINE__);
232 fSaveStateDestructive =
233 (int (*)(
void *))GetFunction(
"SaveStateDestructive");
234 CheckFunction((
void *)fSaveStateDestructive, __LINE__);
235 fRestoreStateFreeSaved =
236 (int (*)(
void *))GetFunction(
"RestoreStateFreeSaved");
237 CheckFunction((
void *)fRestoreStateFreeSaved, __LINE__);
238 fRestoreStateNoFreeSaved =
239 (int (*)(
void *))GetFunction(
"RestoreStateNoFreeSaved");
240 CheckFunction((
void *)fRestoreStateNoFreeSaved, __LINE__);
241 fFreeSavedState = (void (*)(
void *))GetFunction(
"FreeSavedState");
242 CheckFunction((
void *)fFreeSavedState, __LINE__);
243 fClone = (
void *(*)(
void *))GetFunction(
"Clone");
244 CheckFunction((
void *)fClone, __LINE__);
246 (int (*)(
void *,
unsigned long long))GetFunction(
"SetSeed");
247 CheckFunction((
void *)fSetSeed, __LINE__);
249 fSample = (int (*)(
void *,
unsigned int,
long int *,
unsigned int,
250 int *))GetFunction(
"Sample");
251 CheckFunction((
void *)fSample, __LINE__);
252 fSampleAll = (int (*)(
void *,
unsigned int,
long int *))GetFunction(
254 CheckFunction((
void *)fSampleAll, __LINE__);
255 fAmplitude = (int (*)(
void *,
long long int,
double *,
256 double *))GetFunction(
"Amplitude");
257 CheckFunction((
void *)fAmplitude, __LINE__);
259 (double (*)(
void *,
int *,
int *, int))GetFunction(
"Probability");
260 CheckFunction((
void *)fProbability, __LINE__);
261 fBasisStateProbability = (double (*)(
262 void *,
long long int))GetFunction(
"BasisStateProbability");
263 CheckFunction((
void *)fBasisStateProbability, __LINE__);
264 fAllProbabilities = (int (*)(
265 void *obj,
double *probabilities))GetFunction(
"AllProbabilities");
266 CheckFunction((
void *)fAllProbabilities, __LINE__);
267 fExpectationValue = (double (*)(
void *,
const char *,
268 int))GetFunction(
"ExpectationValue");
269 CheckFunction((
void *)fExpectationValue, __LINE__);
271 fApplyX = (int (*)(
void *, int))GetFunction(
"ApplyX");
272 CheckFunction((
void *)fApplyX, __LINE__);
273 fApplyY = (int (*)(
void *, int))GetFunction(
"ApplyY");
274 CheckFunction((
void *)fApplyY, __LINE__);
275 fApplyZ = (int (*)(
void *, int))GetFunction(
"ApplyZ");
276 CheckFunction((
void *)fApplyZ, __LINE__);
277 fApplyH = (int (*)(
void *, int))GetFunction(
"ApplyH");
278 CheckFunction((
void *)fApplyH, __LINE__);
279 fApplyS = (int (*)(
void *, int))GetFunction(
"ApplyS");
280 CheckFunction((
void *)fApplyS, __LINE__);
281 fApplySDG = (int (*)(
void *, int))GetFunction(
"ApplySDG");
282 CheckFunction((
void *)fApplySDG, __LINE__);
283 fApplyT = (int (*)(
void *, int))GetFunction(
"ApplyT");
284 CheckFunction((
void *)fApplyT, __LINE__);
285 fApplyTDG = (int (*)(
void *, int))GetFunction(
"ApplyTDG");
286 CheckFunction((
void *)fApplyTDG, __LINE__);
287 fApplySX = (int (*)(
void *, int))GetFunction(
"ApplySX");
288 CheckFunction((
void *)fApplySX, __LINE__);
289 fApplySXDG = (int (*)(
void *, int))GetFunction(
"ApplySXDG");
290 CheckFunction((
void *)fApplySXDG, __LINE__);
291 fApplyK = (int (*)(
void *, int))GetFunction(
"ApplyK");
292 CheckFunction((
void *)fApplyK, __LINE__);
293 fApplyP = (int (*)(
void *, int, double))GetFunction(
"ApplyP");
294 CheckFunction((
void *)fApplyP, __LINE__);
295 fApplyRx = (int (*)(
void *, int, double))GetFunction(
"ApplyRx");
296 CheckFunction((
void *)fApplyRx, __LINE__);
297 fApplyRy = (int (*)(
void *, int, double))GetFunction(
"ApplyRy");
298 CheckFunction((
void *)fApplyRy, __LINE__);
299 fApplyRz = (int (*)(
void *, int, double))GetFunction(
"ApplyRz");
300 CheckFunction((
void *)fApplyRz, __LINE__);
301 fApplyU = (int (*)(
void *, int, double, double, double,
302 double))GetFunction(
"ApplyU");
303 CheckFunction((
void *)fApplyU, __LINE__);
304 fApplyCX = (int (*)(
void *, int, int))GetFunction(
"ApplyCX");
305 CheckFunction((
void *)fApplyCX, __LINE__);
306 fApplyCY = (int (*)(
void *, int, int))GetFunction(
"ApplyCY");
307 CheckFunction((
void *)fApplyCY, __LINE__);
308 fApplyCZ = (int (*)(
void *, int, int))GetFunction(
"ApplyCZ");
309 CheckFunction((
void *)fApplyCZ, __LINE__);
310 fApplyCH = (int (*)(
void *, int, int))GetFunction(
"ApplyCH");
311 CheckFunction((
void *)fApplyCH, __LINE__);
312 fApplyCSX = (int (*)(
void *, int, int))GetFunction(
"ApplyCSX");
313 CheckFunction((
void *)fApplyCSX, __LINE__);
314 fApplyCSXDG = (int (*)(
void *, int, int))GetFunction(
"ApplyCSXDG");
315 CheckFunction((
void *)fApplyCSXDG, __LINE__);
316 fApplyCP = (int (*)(
void *, int, int, double))GetFunction(
"ApplyCP");
317 CheckFunction((
void *)fApplyCP, __LINE__);
319 (int (*)(
void *, int, int, double))GetFunction(
"ApplyCRx");
320 CheckFunction((
void *)fApplyCRx, __LINE__);
322 (int (*)(
void *, int, int, double))GetFunction(
"ApplyCRy");
323 CheckFunction((
void *)fApplyCRy, __LINE__);
325 (int (*)(
void *, int, int, double))GetFunction(
"ApplyCRz");
326 CheckFunction((
void *)fApplyCRz, __LINE__);
327 fApplyCCX = (int (*)(
void *, int, int, int))GetFunction(
"ApplyCCX");
328 CheckFunction((
void *)fApplyCCX, __LINE__);
329 fApplySwap = (int (*)(
void *, int, int))GetFunction(
"ApplySwap");
330 CheckFunction((
void *)fApplySwap, __LINE__);
332 (int (*)(
void *, int, int, int))GetFunction(
"ApplyCSwap");
333 CheckFunction((
void *)fApplyCSwap, __LINE__);
334 fApplyCU = (int (*)(
void *, int, int, double, double, double,
335 double))GetFunction(
"ApplyCU");
336 CheckFunction((
void *)fApplyCU, __LINE__);
339#define LOAD_DM(name, type) \
340 f##name = reinterpret_cast<type>(GetFunction(#name)); \
341 CheckFunction(reinterpret_cast<void *>(f##name), __LINE__)
342 LOAD_DM(CreateDensityMatrix,
void *(*)(
void *));
343 LOAD_DM(DestroyDensityMatrix,
void (*)(
void *));
344 LOAD_DM(DMCreate,
int (*)(
void *,
unsigned int));
345 LOAD_DM(DMCreateWithState,
346 int (*)(
void *,
unsigned int,
const double *));
347 LOAD_DM(DMCreateWithBasisState,
348 int (*)(
void *,
unsigned int,
unsigned long long));
349 LOAD_DM(DMCreateWithMixtureOfBasisStates,
350 int (*)(
void *,
unsigned int,
const unsigned long long *,
351 const double *,
int));
352 LOAD_DM(DMReset,
int (*)(
void *));
353 LOAD_DM(DMIsValid,
int (*)(
void *));
354 LOAD_DM(DMIsCreated,
int (*)(
void *));
355 LOAD_DM(DMSetDataType,
int (*)(
void *,
int));
356 LOAD_DM(DMIsDoublePrecision,
int (*)(
void *));
357 LOAD_DM(DMGetNrQubits,
int (*)(
void *));
358 LOAD_DM(DMSaveState,
int (*)(
void *));
359 LOAD_DM(DMRestoreState,
int (*)(
void *));
360 LOAD_DM(DMCleanSavedState,
int (*)(
void *));
361 LOAD_DM(DMClone,
void *(*)(
void *));
362 LOAD_DM(DMSetSeed,
int (*)(
void *,
unsigned long long));
363 LOAD_DM(DMMeasureQubitCollapse,
int (*)(
void *,
int));
364 LOAD_DM(DMMeasureQubitNoCollapse,
int (*)(
void *,
int));
365 LOAD_DM(DMMeasureQubitsCollapse,
int (*)(
void *,
int *,
int *,
int));
366 LOAD_DM(DMMeasureQubitsNoCollapse,
int (*)(
void *,
int *,
int *,
int));
367 LOAD_DM(DMMeasureAllQubitsCollapse,
unsigned long long (*)(
void *));
368 LOAD_DM(DMMeasureAllQubitsNoCollapse,
unsigned long long (*)(
void *));
369 LOAD_DM(DMSample,
int (*)(
void *,
unsigned int,
long int *,
unsigned int,
int *));
371 int (*)(
void *,
unsigned int,
long int *));
372 LOAD_DM(DMGetElement,
373 int (*)(
void *,
long long,
long long,
double *,
double *));
374 LOAD_DM(DMBasisStateProbability,
double (*)(
void *,
long long));
375 LOAD_DM(DMAllProbabilities,
int (*)(
void *,
double *));
376 LOAD_DM(DMExpectationValue,
377 double (*)(
void *,
const char *,
int));
378 LOAD_DM(DMQubitProbability0,
double (*)(
void *,
unsigned int));
379 LOAD_DM(DMTrace,
double (*)(
void *));
380 LOAD_DM(DMPurity,
double (*)(
void *));
381 LOAD_DM(DMIsHermitian,
int (*)(
void *,
double));
382 LOAD_DM(DMPartialTrace,
int (*)(
void *,
const int *,
int,
double *));
383 LOAD_DM(DMHilbertSchmidtOverlap,
int (*)(
void *,
void *,
double *,
double *));
384 LOAD_DM(DMFidelityWithStatevector,
int (*)(
void *,
const double *,
double *));
385 LOAD_DM(DMApplyKraus,
386 int (*)(
void *,
int,
const int *,
int,
const double *));
387#define LOAD_DM_GATE1(name) LOAD_DM(name, int (*)(void *, int))
388#define LOAD_DM_GATE2(name) LOAD_DM(name, int (*)(void *, int, int))
389#define LOAD_DM_ROT1(name) LOAD_DM(name, int (*)(void *, int, double))
390#define LOAD_DM_ROT2(name) LOAD_DM(name, int (*)(void *, int, int, double))
391 LOAD_DM_GATE1(DMApplyReset);
392 LOAD_DM_ROT1(DMApplyBitFlipNoise); LOAD_DM_ROT1(DMApplyPhaseFlipNoise);
393 LOAD_DM_ROT1(DMApplyDepolarizingNoise); LOAD_DM_ROT1(DMApplyAmplitudeDamping);
394 LOAD_DM_ROT1(DMApplyPhaseDamping);
395 LOAD_DM_GATE1(DMApplyNonSelectiveMeasurement);
396 LOAD_DM_GATE1(DMApplyX); LOAD_DM_GATE1(DMApplyY);
397 LOAD_DM_GATE1(DMApplyZ); LOAD_DM_GATE1(DMApplyH);
398 LOAD_DM_GATE1(DMApplyS); LOAD_DM_GATE1(DMApplySDG);
399 LOAD_DM_GATE1(DMApplyT); LOAD_DM_GATE1(DMApplyTDG);
400 LOAD_DM_GATE1(DMApplySX); LOAD_DM_GATE1(DMApplySXDG);
401 LOAD_DM_GATE1(DMApplyK);
402 LOAD_DM_ROT1(DMApplyP); LOAD_DM_ROT1(DMApplyRx);
403 LOAD_DM_ROT1(DMApplyRy); LOAD_DM_ROT1(DMApplyRz);
405 int (*)(
void *,
int,
double,
double,
double,
double));
406 LOAD_DM_GATE2(DMApplyCX); LOAD_DM_GATE2(DMApplyCY);
407 LOAD_DM_GATE2(DMApplyCZ); LOAD_DM_GATE2(DMApplyCH);
408 LOAD_DM_GATE2(DMApplyCSX); LOAD_DM_GATE2(DMApplyCSXDG);
409 LOAD_DM_ROT2(DMApplyCP); LOAD_DM_ROT2(DMApplyCRx);
410 LOAD_DM_ROT2(DMApplyCRy); LOAD_DM_ROT2(DMApplyCRz);
411 LOAD_DM(DMApplyCCX,
int (*)(
void *,
int,
int,
int));
412 LOAD_DM_GATE2(DMApplySwap);
413 LOAD_DM(DMApplyCSwap,
int (*)(
void *,
int,
int,
int));
415 int (*)(
void *,
int,
int,
double,
double,
double,
double));
423#define LOAD_MPO(name, type) \
424 f##name = reinterpret_cast<type>(GetFunction(#name)); \
425 CheckFunction(reinterpret_cast<void *>(f##name), __LINE__)
426 LOAD_MPO(CreateMPO,
void *(*)(
void *));
427 LOAD_MPO(DestroyMPO,
void (*)(
void *));
428 LOAD_MPO(MPOCreate,
int (*)(
void *,
unsigned int));
429 LOAD_MPO(MPOCreateWithState,
430 int (*)(
void *,
unsigned int,
const double *));
431 LOAD_MPO(MPOCreateWithBasisState,
432 int (*)(
void *,
unsigned int,
unsigned long long));
433 LOAD_MPO(MPOCreateWithBasisStateBits,
434 int (*)(
void *,
unsigned int,
const unsigned char *));
435 LOAD_MPO(MPOCreateWithMixtureOfBasisStates,
436 int (*)(
void *,
unsigned int,
const unsigned long long *,
437 const double *,
int));
438 LOAD_MPO(MPOCreateWithMixtureOfBasisStatesBits,
439 int (*)(
void *,
unsigned int,
const unsigned char *,
440 const double *,
int));
441 LOAD_MPO(MPOReset,
int (*)(
void *));
442 LOAD_MPO(MPOSetInitialQubitsMap,
443 int (*)(
void *,
const long long int *,
int));
444 LOAD_MPO(MPOSetUseOptimalMeetingPosition,
int (*)(
void *,
int));
445 LOAD_MPO(MPOGetUseOptimalMeetingPosition,
int (*)(
void *));
446 LOAD_MPO(MPOIsValid,
int (*)(
void *));
447 LOAD_MPO(MPOIsCreated,
int (*)(
void *));
448 LOAD_MPO(MPOSetDataType,
int (*)(
void *,
int));
449 LOAD_MPO(MPOIsDoublePrecision,
int (*)(
void *));
450 LOAD_MPO(MPOGetNrQubits,
int (*)(
void *));
451 LOAD_MPO(MPOSetCutoff,
int (*)(
void *,
double));
452 LOAD_MPO(MPOGetCutoff,
double (*)(
void *));
453 LOAD_MPO(MPOSetTruncationMode,
int (*)(
void *,
int));
454 LOAD_MPO(MPOGetTruncationMode,
int (*)(
void *));
455 LOAD_MPO(MPOSetGesvdJ,
int (*)(
void *,
int));
456 LOAD_MPO(MPOGetGesvdJ,
int (*)(
void *));
458 fMPOSetGesvdP = (int (*)(
void *, int))GetFunction(
"MPOSetGesvdP");
459 fMPOGetGesvdP = (int (*)(
void *))GetFunction(
"MPOGetGesvdP");
460 fMPOSetGesvdR = (int (*)(
void *, int))GetFunction(
"MPOSetGesvdR");
461 fMPOGetGesvdR = (int (*)(
void *))GetFunction(
"MPOGetGesvdR");
462 fMPOGetLastSvdAlgo = (int (*)(
void *))GetFunction(
"MPOGetLastSvdAlgo");
464 LOAD_MPO(MPOSetMaxExtent,
int (*)(
void *,
long int));
465 LOAD_MPO(MPOGetMaxExtent,
long int (*)(
void *));
466 LOAD_MPO(MPOGetBondDimensions,
467 int (*)(
void *,
long long int *));
468 LOAD_MPO(MPOSetCallbackContext,
int (*)(
void *,
void *));
469 LOAD_MPO(MPOSetMeetingPositionCallback,
470 int (*)(
void *, int64_t (*)(
void *,
const int64_t *)));
471 LOAD_MPO(MPOSetBondDimensionsCallback,
472 int (*)(
void *,
void (*)(
void *,
const int64_t *)));
473 LOAD_MPO(MPOReCanonicalize,
int (*)(
void *,
int));
474 LOAD_MPO(MPOTrim,
int (*)(
void *,
double,
long int,
int));
475 LOAD_MPO(MPOSaveState,
int (*)(
void *));
476 LOAD_MPO(MPORestoreState,
int (*)(
void *));
477 LOAD_MPO(MPOCleanSavedState,
int (*)(
void *));
478 LOAD_MPO(MPOClone,
void *(*)(
void *));
479 LOAD_MPO(MPOSetSeed,
int (*)(
void *,
unsigned long long));
480 LOAD_MPO(MPOMeasureQubitCollapse,
int (*)(
void *,
int));
481 LOAD_MPO(MPOMeasureQubitNoCollapse,
int (*)(
void *,
int));
482 LOAD_MPO(MPOMeasureQubitsCollapse,
int (*)(
void *,
int *,
int *,
int));
483 LOAD_MPO(MPOMeasureQubitsNoCollapse,
int (*)(
void *,
int *,
int *,
int));
484 LOAD_MPO(MPOMeasureAllQubitsCollapse,
unsigned long long (*)(
void *));
485 LOAD_MPO(MPOMeasureAllQubitsNoCollapse,
unsigned long long (*)(
void *));
487 int (*)(
void *,
unsigned int,
long int *,
unsigned int,
489 LOAD_MPO(MPOSampleAll,
490 int (*)(
void *,
unsigned int,
long int *));
491 LOAD_MPO(MPOGetElement,
492 int (*)(
void *,
long long,
long long,
double *,
double *));
493 LOAD_MPO(MPOBasisStateProbability,
double (*)(
void *,
long long));
494 LOAD_MPO(MPOAllProbabilities,
int (*)(
void *,
double *));
495 LOAD_MPO(MPOExpectationValue,
496 double (*)(
void *,
const char *,
int));
497 LOAD_MPO(MPOQubitProbability0,
double (*)(
void *,
unsigned int));
498 LOAD_MPO(MPOPartialTrace,
int (*)(
void *,
const int *,
int,
double *));
499 LOAD_MPO(MPOHilbertSchmidtOverlap,
int (*)(
void *,
void *,
double *,
double *));
500 LOAD_MPO(MPOFidelityWithStatevector,
int (*)(
void *,
const double *,
double *));
501 LOAD_MPO(MPOTrace,
double (*)(
void *));
502 LOAD_MPO(MPOPurity,
double (*)(
void *));
503 LOAD_MPO(MPOHermiticityResidual,
double (*)(
void *));
504 LOAD_MPO(MPOIsHermitian,
int (*)(
void *,
double));
505 LOAD_MPO(MPOTraceOfSquare,
double (*)(
void *));
506 LOAD_MPO(MPORestoreTrace,
int (*)(
void *));
507 LOAD_MPO(MPOHermitize,
int (*)(
void *));
508 LOAD_MPO(MPOSetKrausCompletenessCheck,
int (*)(
void *,
int));
509 LOAD_MPO(MPOGetKrausCompletenessCheck,
int (*)(
void *));
510 LOAD_MPO(MPOApplyKraus,
511 int (*)(
void *,
int,
const int *,
int,
const double *));
512#define LOAD_MPO_GATE1(name) LOAD_MPO(name, int (*)(void *, int))
513#define LOAD_MPO_GATE2(name) LOAD_MPO(name, int (*)(void *, int, int))
514#define LOAD_MPO_ROT1(name) LOAD_MPO(name, int (*)(void *, int, double))
515#define LOAD_MPO_ROT2(name) LOAD_MPO(name, int (*)(void *, int, int, double))
516 LOAD_MPO_GATE1(MPOApplyReset);
517 LOAD_MPO_ROT1(MPOApplyBitFlipNoise); LOAD_MPO_ROT1(MPOApplyPhaseFlipNoise);
518 LOAD_MPO_ROT1(MPOApplyDepolarizingNoise); LOAD_MPO_ROT1(MPOApplyAmplitudeDamping);
519 LOAD_MPO_ROT1(MPOApplyPhaseDamping);
520 LOAD_MPO_GATE1(MPOApplyNonSelectiveMeasurement);
521 LOAD_MPO_GATE1(MPOApplyX); LOAD_MPO_GATE1(MPOApplyY);
522 LOAD_MPO_GATE1(MPOApplyZ); LOAD_MPO_GATE1(MPOApplyH);
523 LOAD_MPO_GATE1(MPOApplyS); LOAD_MPO_GATE1(MPOApplySDG);
524 LOAD_MPO_GATE1(MPOApplyT); LOAD_MPO_GATE1(MPOApplyTDG);
525 LOAD_MPO_GATE1(MPOApplySX); LOAD_MPO_GATE1(MPOApplySXDG);
526 LOAD_MPO_GATE1(MPOApplyK);
527 LOAD_MPO_ROT1(MPOApplyP); LOAD_MPO_ROT1(MPOApplyRx);
528 LOAD_MPO_ROT1(MPOApplyRy); LOAD_MPO_ROT1(MPOApplyRz);
530 int (*)(
void *,
int,
double,
double,
double,
double));
531 LOAD_MPO(MPOApplyOneQubitMatrix,
532 int (*)(
void *,
int,
const double *));
533 LOAD_MPO(MPOApplyTwoQubitMatrix,
534 int (*)(
void *,
int,
int,
const double *));
535 LOAD_MPO_GATE2(MPOApplyCX); LOAD_MPO_GATE2(MPOApplyCY);
536 LOAD_MPO_GATE2(MPOApplyCZ); LOAD_MPO_GATE2(MPOApplyCH);
537 LOAD_MPO_GATE2(MPOApplyCSX); LOAD_MPO_GATE2(MPOApplyCSXDG);
538 LOAD_MPO_ROT2(MPOApplyCP); LOAD_MPO_ROT2(MPOApplyCRx);
539 LOAD_MPO_ROT2(MPOApplyCRy); LOAD_MPO_ROT2(MPOApplyCRz);
540 LOAD_MPO_GATE2(MPOApplySwap);
542 int (*)(
void *,
int,
int,
double,
double,
double,
double));
555 fCreateMPS = (
void *(*)(
void *))GetFunction(
"CreateMPS");
556 CheckFunction((
void *)fCreateMPS, __LINE__);
557 fDestroyMPS = (void (*)(
void *))GetFunction(
"DestroyMPS");
558 CheckFunction((
void *)fDestroyMPS, __LINE__);
560 fMPSCreate = (int (*)(
void *,
unsigned int))GetFunction(
"MPSCreate");
561 CheckFunction((
void *)fMPSCreate, __LINE__);
562 fMPSCreateWithBasisState =
563 (int (*)(
void *,
unsigned int,
unsigned long long))GetFunction(
564 "MPSCreateWithBasisState");
565 CheckFunction((
void *)fMPSCreateWithBasisState, __LINE__);
566 fMPSCreateWithBasisStateBits =
567 (int (*)(
void *,
unsigned int,
const unsigned char *))
568 GetFunction(
"MPSCreateWithBasisStateBits");
569 CheckFunction((
void *)fMPSCreateWithBasisStateBits, __LINE__);
570 fMPSReset = (int (*)(
void *))GetFunction(
"MPSReset");
571 CheckFunction((
void *)fMPSReset, __LINE__);
572 fMPSSetInitialQubitsMap =
573 (int (*)(
void *,
const long long int *, int))GetFunction(
574 "MPSSetInitialQubitsMap");
575 CheckFunction((
void *)fMPSSetInitialQubitsMap, __LINE__);
576 fMPSSetUseOptimalMeetingPosition = (int (*)(
void *, int))GetFunction(
577 "MPSSetUseOptimalMeetingPosition");
578 CheckFunction((
void *)fMPSSetUseOptimalMeetingPosition, __LINE__);
579 fMPSGetUseOptimalMeetingPosition = (int (*)(
void *))GetFunction(
580 "MPSGetUseOptimalMeetingPosition");
581 CheckFunction((
void *)fMPSGetUseOptimalMeetingPosition, __LINE__);
583 fMPSIsValid = (int (*)(
void *))GetFunction(
"MPSIsValid");
584 CheckFunction((
void *)fMPSIsValid, __LINE__);
585 fMPSIsCreated = (int (*)(
void *))GetFunction(
"MPSIsCreated");
586 CheckFunction((
void *)fMPSIsCreated, __LINE__);
588 fMPSSetDataType = (int (*)(
void *, int))GetFunction(
"MPSSetDataType");
589 CheckFunction((
void *)fMPSSetDataType, __LINE__);
590 fMPSIsDoublePrecision =
591 (int (*)(
void *))GetFunction(
"MPSIsDoublePrecision");
592 CheckFunction((
void *)fMPSIsDoublePrecision, __LINE__);
593 fMPSSetCutoff = (int (*)(
void *, double))GetFunction(
"MPSSetCutoff");
594 CheckFunction((
void *)fMPSSetCutoff, __LINE__);
595 fMPSGetCutoff = (double (*)(
void *))GetFunction(
"MPSGetCutoff");
596 CheckFunction((
void *)fMPSGetCutoff, __LINE__);
597 fMPSSetTruncationMode =
598 (int (*)(
void *, int))GetFunction(
"MPSSetTruncationMode");
599 CheckFunction((
void *)fMPSSetTruncationMode, __LINE__);
600 fMPSGetTruncationMode =
601 (int (*)(
void *))GetFunction(
"MPSGetTruncationMode");
602 CheckFunction((
void *)fMPSGetTruncationMode, __LINE__);
603 fMPSSetGesvdJ = (int (*)(
void *, int))GetFunction(
"MPSSetGesvdJ");
604 CheckFunction((
void *)fMPSSetGesvdJ, __LINE__);
605 fMPSGetGesvdJ = (int (*)(
void *))GetFunction(
"MPSGetGesvdJ");
606 CheckFunction((
void *)fMPSGetGesvdJ, __LINE__);
608 fMPSSetGesvdP = (int (*)(
void *, int))GetFunction(
"MPSSetGesvdP");
609 fMPSGetGesvdP = (int (*)(
void *))GetFunction(
"MPSGetGesvdP");
610 fMPSSetGesvdR = (int (*)(
void *, int))GetFunction(
"MPSSetGesvdR");
611 fMPSGetGesvdR = (int (*)(
void *))GetFunction(
"MPSGetGesvdR");
612 fMPSGetLastSvdAlgo = (int (*)(
void *))GetFunction(
"MPSGetLastSvdAlgo");
615 (int (*)(
void *,
long int))GetFunction(
"MPSSetMaxExtent");
616 CheckFunction((
void *)fMPSSetMaxExtent, __LINE__);
618 (
long int (*)(
void *))GetFunction(
"MPSGetMaxExtent");
619 CheckFunction((
void *)fMPSGetMaxExtent, __LINE__);
620 fMPSGetNrQubits = (int (*)(
void *))GetFunction(
"MPSGetNrQubits");
621 CheckFunction((
void *)fMPSGetNrQubits, __LINE__);
622 fMPSGetBondDimensions =
623 (int (*)(
void *,
long long int *))GetFunction(
624 "MPSGetBondDimensions");
625 CheckFunction((
void *)fMPSGetBondDimensions, __LINE__);
626 fMPSSetCallbackContext =
627 (int (*)(
void *,
void *))GetFunction(
"MPSSetCallbackContext");
628 CheckFunction((
void *)fMPSSetCallbackContext, __LINE__);
630 fMPSSetMeetingPositionCallback =
631 (int (*)(
void *, int64_t (*)(
void *,
const int64_t *)))
632 GetFunction(
"MPSSetMeetingPositionCallback");
633 CheckFunction((
void *)fMPSSetMeetingPositionCallback, __LINE__);
635 fMPSSetBondDimensionsCallback =
636 (int (*)(
void*, void (*)(
void*,
const int64_t*)))GetFunction(
637 "MPSSetBondDimensionsCallback");
638 CheckFunction((
void *)fMPSSetBondDimensionsCallback, __LINE__);
640 fMPSAmplitude = (int (*)(
void *,
long int,
long int *,
double *,
641 double *))GetFunction(
"MPSAmplitude");
642 CheckFunction((
void *)fMPSAmplitude, __LINE__);
644 (double (*)(
void *,
unsigned int))GetFunction(
"MPSProbability0");
645 CheckFunction((
void *)fMPSProbability0, __LINE__);
647 (int (*)(
void *,
unsigned int))GetFunction(
"MPSMeasure");
648 CheckFunction((
void *)fMPSMeasure, __LINE__);
649 fMPSMeasureQubits = (int (*)(
void *,
long int,
unsigned int *,
650 int *))GetFunction(
"MPSMeasureQubits");
651 CheckFunction((
void *)fMPSMeasureQubits, __LINE__);
653 fMPSGetMapForSample = (
void *(*)())GetFunction(
"MPSGetMapForSample");
654 CheckFunction((
void *)fMPSGetMapForSample, __LINE__);
655 fMPSFreeMapForSample =
656 (int (*)(
void *))GetFunction(
"MPSFreeMapForSample");
657 CheckFunction((
void *)fMPSFreeMapForSample, __LINE__);
658 fMPSSample = (int (*)(
void *,
long int,
long int,
unsigned int *,
659 void *))GetFunction(
"MPSSample");
660 CheckFunction((
void *)fMPSSample, __LINE__);
661 fMPSSampleRaw = (int (*)(
void *,
unsigned int,
long int *,
662 unsigned int,
const unsigned int *))
663 GetFunction(
"MPSSampleRaw");
664 CheckFunction((
void *)fMPSSampleRaw, __LINE__);
665 fMPSSampleAll = (int (*)(
void *,
unsigned int,
long int *))
666 GetFunction(
"MPSSampleAll");
667 CheckFunction((
void *)fMPSSampleAll, __LINE__);
669 fMPSSaveState = (int (*)(
void *))GetFunction(
"MPSSaveState");
670 CheckFunction((
void *)fMPSSaveState, __LINE__);
671 fMPSRestoreState = (int (*)(
void *))GetFunction(
"MPSRestoreState");
672 CheckFunction((
void *)fMPSRestoreState, __LINE__);
673 fMPSCleanSavedState =
674 (int (*)(
void *))GetFunction(
"MPSCleanSavedState");
675 CheckFunction((
void *)fMPSCleanSavedState, __LINE__);
676 fMPSClone = (
void *(*)(
void *))GetFunction(
"MPSClone");
677 CheckFunction((
void *)fMPSClone, __LINE__);
678 fMPSSetSeed = (int (*)(
void *,
unsigned long long))
679 GetFunction(
"MPSSetSeed");
680 CheckFunction((
void *)fMPSSetSeed, __LINE__);
682 fMPSExpectationValue = (double (*)(
683 void *,
const char *, int))GetFunction(
"MPSExpectationValue");
684 CheckFunction((
void *)fMPSExpectationValue, __LINE__);
686 (int (*)(
void *,
double *,
double *))GetFunction(
"MPSProjectOnZero");
687 CheckFunction((
void *)fMPSProjectOnZero, __LINE__);
689 fMPSApplyX = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyX");
690 CheckFunction((
void *)fMPSApplyX, __LINE__);
691 fMPSApplyY = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyY");
692 CheckFunction((
void *)fMPSApplyY, __LINE__);
693 fMPSApplyZ = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyZ");
694 CheckFunction((
void *)fMPSApplyZ, __LINE__);
695 fMPSApplyH = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyH");
696 CheckFunction((
void *)fMPSApplyH, __LINE__);
697 fMPSApplyS = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyS");
698 CheckFunction((
void *)fMPSApplyS, __LINE__);
700 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySDG");
701 CheckFunction((
void *)fMPSApplySDG, __LINE__);
702 fMPSApplyT = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyT");
703 CheckFunction((
void *)fMPSApplyT, __LINE__);
705 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyTDG");
706 CheckFunction((
void *)fMPSApplyTDG, __LINE__);
708 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySX");
709 CheckFunction((
void *)fMPSApplySX, __LINE__);
711 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySXDG");
712 CheckFunction((
void *)fMPSApplySXDG, __LINE__);
713 fMPSApplyK = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyK");
714 CheckFunction((
void *)fMPSApplyK, __LINE__);
716 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyP");
717 CheckFunction((
void *)fMPSApplyP, __LINE__);
719 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRx");
720 CheckFunction((
void *)fMPSApplyRx, __LINE__);
722 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRy");
723 CheckFunction((
void *)fMPSApplyRy, __LINE__);
725 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRz");
726 CheckFunction((
void *)fMPSApplyRz, __LINE__);
727 fMPSApplyU = (int (*)(
void *,
unsigned int, double, double, double,
728 double))GetFunction(
"MPSApplyU");
729 CheckFunction((
void *)fMPSApplyU, __LINE__);
730 fMPSApplyOneQubitMatrix =
731 (int (*)(
void *,
unsigned int,
const double *))GetFunction(
732 "MPSApplyOneQubitMatrix");
733 CheckFunction((
void *)fMPSApplyOneQubitMatrix, __LINE__);
734 fMPSApplyTwoQubitMatrix =
735 (int (*)(
void *,
unsigned int,
unsigned int,
736 const double *))GetFunction(
"MPSApplyTwoQubitMatrix");
737 CheckFunction((
void *)fMPSApplyTwoQubitMatrix, __LINE__);
738 fMPSApplySwap = (int (*)(
void *,
unsigned int,
739 unsigned int))GetFunction(
"MPSApplySwap");
740 CheckFunction((
void *)fMPSApplySwap, __LINE__);
741 fMPSApplyCX = (int (*)(
void *,
unsigned int,
742 unsigned int))GetFunction(
"MPSApplyCX");
743 CheckFunction((
void *)fMPSApplyCX, __LINE__);
744 fMPSApplyCY = (int (*)(
void *,
unsigned int,
745 unsigned int))GetFunction(
"MPSApplyCY");
746 CheckFunction((
void *)fMPSApplyCY, __LINE__);
747 fMPSApplyCZ = (int (*)(
void *,
unsigned int,
748 unsigned int))GetFunction(
"MPSApplyCZ");
749 CheckFunction((
void *)fMPSApplyCZ, __LINE__);
750 fMPSApplyCH = (int (*)(
void *,
unsigned int,
751 unsigned int))GetFunction(
"MPSApplyCH");
752 CheckFunction((
void *)fMPSApplyCH, __LINE__);
753 fMPSApplyCSX = (int (*)(
void *,
unsigned int,
754 unsigned int))GetFunction(
"MPSApplyCSX");
755 CheckFunction((
void *)fMPSApplyCSX, __LINE__);
756 fMPSApplyCSXDG = (int (*)(
void *,
unsigned int,
757 unsigned int))GetFunction(
"MPSApplyCSXDG");
758 CheckFunction((
void *)fMPSApplyCSXDG, __LINE__);
759 fMPSApplyCP = (int (*)(
void *,
unsigned int,
unsigned int,
760 double))GetFunction(
"MPSApplyCP");
761 CheckFunction((
void *)fMPSApplyCP, __LINE__);
762 fMPSApplyCRx = (int (*)(
void *,
unsigned int,
unsigned int,
763 double))GetFunction(
"MPSApplyCRx");
764 CheckFunction((
void *)fMPSApplyCRx, __LINE__);
765 fMPSApplyCRy = (int (*)(
void *,
unsigned int,
unsigned int,
766 double))GetFunction(
"MPSApplyCRy");
767 CheckFunction((
void *)fMPSApplyCRy, __LINE__);
768 fMPSApplyCRz = (int (*)(
void *,
unsigned int,
unsigned int,
769 double))GetFunction(
"MPSApplyCRz");
770 CheckFunction((
void *)fMPSApplyCRz, __LINE__);
772 (int (*)(
void *,
unsigned int,
unsigned int, double, double,
773 double, double))GetFunction(
"MPSApplyCU");
774 CheckFunction((
void *)fMPSApplyCU, __LINE__);
778 fCreateTensorNet = (
void *(*)(
void *))GetFunction(
"CreateTensorNet");
779 CheckFunction((
void *)fCreateTensorNet, __LINE__);
780 fDestroyTensorNet = (void (*)(
void *))GetFunction(
"DestroyTensorNet");
781 CheckFunction((
void *)fDestroyTensorNet, __LINE__);
783 fTNCreate = (int (*)(
void *,
unsigned int))GetFunction(
"TNCreate");
784 CheckFunction((
void *)fTNCreate, __LINE__);
785 fTNReset = (int (*)(
void *))GetFunction(
"TNReset");
786 CheckFunction((
void *)fTNReset, __LINE__);
788 fTNIsValid = (int (*)(
void *))GetFunction(
"TNIsValid");
789 CheckFunction((
void *)fTNIsValid, __LINE__);
790 fTNIsCreated = (int (*)(
void *))GetFunction(
"TNIsCreated");
791 CheckFunction((
void *)fTNIsCreated, __LINE__);
793 fTNSetDataType = (int (*)(
void *, int))GetFunction(
"TNSetDataType");
794 CheckFunction((
void *)fTNSetDataType, __LINE__);
795 fTNIsDoublePrecision =
796 (int (*)(
void *))GetFunction(
"TNIsDoublePrecision");
797 CheckFunction((
void *)fTNIsDoublePrecision, __LINE__);
798 fTNSetCutoff = (int (*)(
void *, double))GetFunction(
"TNSetCutoff");
799 CheckFunction((
void *)fTNSetCutoff, __LINE__);
800 fTNGetCutoff = (double (*)(
void *))GetFunction(
"TNGetCutoff");
801 CheckFunction((
void *)fTNGetCutoff, __LINE__);
802 fTNSetTruncationMode =
803 (int (*)(
void *, int))GetFunction(
"TNSetTruncationMode");
804 CheckFunction((
void *)fTNSetTruncationMode, __LINE__);
805 fTNGetTruncationMode =
806 (int (*)(
void *))GetFunction(
"TNGetTruncationMode");
807 CheckFunction((
void *)fTNGetTruncationMode, __LINE__);
808 fTNSetGesvdJ = (int (*)(
void *, int))GetFunction(
"TNSetGesvdJ");
809 CheckFunction((
void *)fTNSetGesvdJ, __LINE__);
810 fTNGetGesvdJ = (int (*)(
void *))GetFunction(
"TNGetGesvdJ");
811 CheckFunction((
void *)fTNGetGesvdJ, __LINE__);
813 fTNSetGesvdP = (int (*)(
void *, int))GetFunction(
"TNSetGesvdP");
814 fTNGetGesvdP = (int (*)(
void *))GetFunction(
"TNGetGesvdP");
815 fTNSetGesvdR = (int (*)(
void *, int))GetFunction(
"TNSetGesvdR");
816 fTNGetGesvdR = (int (*)(
void *))GetFunction(
"TNGetGesvdR");
819 (int (*)(
void *,
long int))GetFunction(
"TNSetMaxExtent");
820 CheckFunction((
void *)fTNSetMaxExtent, __LINE__);
821 fTNGetMaxExtent = (
long int (*)(
void *))GetFunction(
"TNGetMaxExtent");
822 CheckFunction((
void *)fTNGetMaxExtent, __LINE__);
823 fTNGetNrQubits = (int (*)(
void *))GetFunction(
"TNGetNrQubits");
824 CheckFunction((
void *)fTNGetNrQubits, __LINE__);
825 fTNAmplitude = (int (*)(
void *,
long int,
long int *,
double *,
826 double *))GetFunction(
"TNAmplitude");
827 CheckFunction((
void *)fTNAmplitude, __LINE__);
829 (double (*)(
void *,
unsigned int))GetFunction(
"TNProbability0");
830 CheckFunction((
void *)fTNProbability0, __LINE__);
831 fTNMeasure = (int (*)(
void *,
unsigned int))GetFunction(
"TNMeasure");
832 CheckFunction((
void *)fTNMeasure, __LINE__);
833 fTNMeasureQubits = (int (*)(
void *,
long int,
unsigned int *,
834 int *))GetFunction(
"TNMeasureQubits");
835 CheckFunction((
void *)fTNMeasureQubits, __LINE__);
837 fTNGetMapForSample = (
void *(*)())GetFunction(
"TNGetMapForSample");
838 CheckFunction((
void *)fTNGetMapForSample, __LINE__);
839 fTNFreeMapForSample =
840 (int (*)(
void *))GetFunction(
"TNFreeMapForSample");
841 CheckFunction((
void *)fTNFreeMapForSample, __LINE__);
842 fTNSample = (int (*)(
void *,
long int,
long int,
unsigned int *,
843 void *))GetFunction(
"TNSample");
844 CheckFunction((
void *)fTNSample, __LINE__);
846 fTNSaveState = (int (*)(
void *))GetFunction(
"TNSaveState");
847 CheckFunction((
void *)fTNSaveState, __LINE__);
848 fTNRestoreState = (int (*)(
void *))GetFunction(
"TNRestoreState");
849 CheckFunction((
void *)fTNRestoreState, __LINE__);
851 (int (*)(
void *))GetFunction(
"TNCleanSavedState");
852 CheckFunction((
void *)fTNCleanSavedState, __LINE__);
853 fTNClone = (
void *(*)(
void *))GetFunction(
"TNClone");
854 CheckFunction((
void *)fTNClone, __LINE__);
855 fTNSetSeed = (int (*)(
void *,
unsigned long long))
856 GetFunction(
"TNSetSeed");
857 CheckFunction((
void *)fTNSetSeed, __LINE__);
859 fTNExpectationValue = (double (*)(
860 void *,
const char *, int))GetFunction(
"TNExpectationValue");
861 CheckFunction((
void *)fTNExpectationValue, __LINE__);
863 fTNApplyX = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyX");
864 CheckFunction((
void *)fTNApplyX, __LINE__);
865 fTNApplyY = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyY");
866 CheckFunction((
void *)fTNApplyY, __LINE__);
867 fTNApplyZ = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyZ");
868 CheckFunction((
void *)fTNApplyZ, __LINE__);
869 fTNApplyH = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyH");
870 CheckFunction((
void *)fTNApplyH, __LINE__);
871 fTNApplyS = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyS");
872 CheckFunction((
void *)fTNApplyS, __LINE__);
874 (int (*)(
void *,
unsigned int))GetFunction(
"TNApplySDG");
875 CheckFunction((
void *)fTNApplySDG, __LINE__);
876 fTNApplyT = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyT");
877 CheckFunction((
void *)fTNApplyT, __LINE__);
879 (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyTDG");
880 CheckFunction((
void *)fTNApplyTDG, __LINE__);
881 fTNApplySX = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplySX");
882 CheckFunction((
void *)fTNApplySX, __LINE__);
884 (int (*)(
void *,
unsigned int))GetFunction(
"TNApplySXDG");
885 CheckFunction((
void *)fTNApplySXDG, __LINE__);
886 fTNApplyK = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyK");
887 CheckFunction((
void *)fTNApplyK, __LINE__);
889 (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyP");
890 CheckFunction((
void *)fTNApplyP, __LINE__);
892 (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyRx");
893 CheckFunction((
void *)fTNApplyRx, __LINE__);
895 (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyRy");
896 CheckFunction((
void *)fTNApplyRy, __LINE__);
898 (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyRz");
899 CheckFunction((
void *)fTNApplyRz, __LINE__);
900 fTNApplyU = (int (*)(
void *,
unsigned int, double, double, double,
901 double))GetFunction(
"TNApplyU");
902 CheckFunction((
void *)fTNApplyU, __LINE__);
903 fTNApplySwap = (int (*)(
void *,
unsigned int,
904 unsigned int))GetFunction(
"TNApplySwap");
905 CheckFunction((
void *)fTNApplySwap, __LINE__);
906 fTNApplyCX = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
908 CheckFunction((
void *)fTNApplyCX, __LINE__);
909 fTNApplyCY = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
911 CheckFunction((
void *)fTNApplyCY, __LINE__);
912 fTNApplyCZ = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
914 CheckFunction((
void *)fTNApplyCZ, __LINE__);
915 fTNApplyCH = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
917 CheckFunction((
void *)fTNApplyCH, __LINE__);
918 fTNApplyCSX = (int (*)(
void *,
unsigned int,
919 unsigned int))GetFunction(
"TNApplyCSX");
920 CheckFunction((
void *)fTNApplyCSX, __LINE__);
921 fTNApplyCSXDG = (int (*)(
void *,
unsigned int,
922 unsigned int))GetFunction(
"TNApplyCSXDG");
923 CheckFunction((
void *)fTNApplyCSXDG, __LINE__);
924 fTNApplyCP = (int (*)(
void *,
unsigned int,
unsigned int,
925 double))GetFunction(
"TNApplyCP");
926 CheckFunction((
void *)fTNApplyCP, __LINE__);
927 fTNApplyCRx = (int (*)(
void *,
unsigned int,
unsigned int,
928 double))GetFunction(
"TNApplyCRx");
929 CheckFunction((
void *)fTNApplyCRx, __LINE__);
930 fTNApplyCRy = (int (*)(
void *,
unsigned int,
unsigned int,
931 double))GetFunction(
"TNApplyCRy");
932 CheckFunction((
void *)fTNApplyCRy, __LINE__);
933 fTNApplyCRz = (int (*)(
void *,
unsigned int,
unsigned int,
934 double))GetFunction(
"TNApplyCRz");
935 CheckFunction((
void *)fTNApplyCRz, __LINE__);
937 (int (*)(
void *,
unsigned int,
unsigned int, double, double,
938 double, double))GetFunction(
"TNApplyCU");
939 CheckFunction((
void *)fTNApplyCU, __LINE__);
941 fTNApplyCCX = (int (*)(
void *,
unsigned int,
unsigned int,
942 unsigned int))GetFunction(
"TNApplyCCX");
943 CheckFunction((
void *)fTNApplyCCX, __LINE__);
944 fTNApplyCSwap = (int (*)(
void *,
unsigned int,
unsigned int,
945 unsigned int))GetFunction(
"TNApplyCSwap");
946 CheckFunction((
void *)fTNApplyCSwap, __LINE__);
949 fCreateStabilizerSimulator = (
void *(*)(
long long int,
long long int,
950 long long int,
long long int))
951 GetFunction(
"CreateStabilizerSimulator");
952 CheckFunction((
void *)fCreateStabilizerSimulator, __LINE__);
953 fDestroyStabilizerSimulator =
954 (void (*)(
void *))GetFunction(
"DestroyStabilizerSimulator");
955 CheckFunction((
void *)fDestroyStabilizerSimulator, __LINE__);
956 fExecuteStabilizerCircuit = (int (*)(
957 void *,
const char *, int,
958 unsigned long long int))GetFunction(
"ExecuteStabilizerCircuit");
959 CheckFunction((
void *)fExecuteStabilizerCircuit, __LINE__);
960 fGetStabilizerXZTableSize =
961 (
long long (*)(
void *))GetFunction(
"GetStabilizerXZTableSize");
962 CheckFunction((
void *)fGetStabilizerXZTableSize, __LINE__);
963 fGetStabilizerMTableSize =
964 (
long long (*)(
void *))GetFunction(
"GetStabilizerMTableSize");
965 CheckFunction((
void *)fGetStabilizerMTableSize, __LINE__);
967 fGetStabilizerTableStrideMajor = (
long long (*)(
void *))GetFunction(
968 "GetStabilizerTableStrideMajor");
969 CheckFunction((
void *)fGetStabilizerTableStrideMajor, __LINE__);
971 fGetStabilizerNumQubits =
972 (
long long (*)(
void *))GetFunction(
"GetStabilizerNumQubits");
973 CheckFunction((
void *)fGetStabilizerNumQubits, __LINE__);
974 fGetStabilizerNumShots =
975 (
long long (*)(
void *))GetFunction(
"GetStabilizerNumShots");
976 CheckFunction((
void *)fGetStabilizerNumShots, __LINE__);
977 fGetStabilizerNumMeasurements = (
long long (*)(
void *))GetFunction(
978 "GetStabilizerNumMeasurements");
979 CheckFunction((
void *)fGetStabilizerNumMeasurements, __LINE__);
980 fGetStabilizerNumDetectors =
981 (
long long (*)(
void *))GetFunction(
"GetStabilizerNumDetectors");
982 CheckFunction((
void *)fGetStabilizerNumDetectors, __LINE__);
983 fCopyStabilizerXTable = (int (*)(
void *,
unsigned int *))GetFunction(
984 "CopyStabilizerXTable");
985 CheckFunction((
void *)fCopyStabilizerXTable, __LINE__);
986 fCopyStabilizerZTable = (int (*)(
void *,
unsigned int *))GetFunction(
987 "CopyStabilizerZTable");
988 CheckFunction((
void *)fCopyStabilizerZTable, __LINE__);
989 fCopyStabilizerMTable = (int (*)(
void *,
unsigned int *))GetFunction(
990 "CopyStabilizerMTable");
991 CheckFunction((
void *)fCopyStabilizerMTable, __LINE__);
993 fInitStabilizerXTable =
994 (int (*)(
void *,
const unsigned int *))GetFunction(
"InitXTable");
995 CheckFunction((
void *)fInitStabilizerXTable, __LINE__);
996 fInitStabilizerZTable =
997 (int (*)(
void *,
const unsigned int *))GetFunction(
"InitZTable");
998 CheckFunction((
void *)fInitStabilizerZTable, __LINE__);
1001 fCreatePauliPropSimulator =
1002 (
void *(*)(
int))GetFunction(
"CreatePauliPropSimulator");
1003 CheckFunction((
void *)fCreatePauliPropSimulator, __LINE__);
1004 fDestroyPauliPropSimulator =
1005 (void (*)(
void *))GetFunction(
"DestroyPauliPropSimulator");
1006 CheckFunction((
void *)fDestroyPauliPropSimulator, __LINE__);
1008 fPauliPropGetNrQubits =
1009 (int (*)(
void *))GetFunction(
"PauliPropGetNrQubits");
1010 CheckFunction((
void *)fPauliPropGetNrQubits, __LINE__);
1011 fPauliPropSetWillUseSampling =
1012 (int (*)(
void *, int))GetFunction(
"PauliPropSetWillUseSampling");
1013 CheckFunction((
void *)fPauliPropSetWillUseSampling, __LINE__);
1014 fPauliPropGetWillUseSampling =
1015 (int (*)(
void *))GetFunction(
"PauliPropGetWillUseSampling");
1016 CheckFunction((
void *)fPauliPropGetWillUseSampling, __LINE__);
1018 fPauliPropGetCoefficientTruncationCutoff = (double (*)(
1019 void *))GetFunction(
"PauliPropGetCoefficientTruncationCutoff");
1020 CheckFunction((
void *)fPauliPropGetCoefficientTruncationCutoff,
1022 fPauliPropSetCoefficientTruncationCutoff =
1023 (void (*)(
void *, double))GetFunction(
1024 "PauliPropSetCoefficientTruncationCutoff");
1025 CheckFunction((
void *)fPauliPropSetCoefficientTruncationCutoff,
1027 fPauliPropGetWeightTruncationCutoff = (double (*)(
void *))GetFunction(
1028 "PauliPropGetWeightTruncationCutoff");
1029 CheckFunction((
void *)fPauliPropGetWeightTruncationCutoff, __LINE__);
1030 fPauliPropSetWeightTruncationCutoff = (void (*)(
1031 void *, double))GetFunction(
"PauliPropSetWeightTruncationCutoff");
1032 CheckFunction((
void *)fPauliPropSetWeightTruncationCutoff, __LINE__);
1033 fPauliPropGetNumGatesBetweenTruncations = (int (*)(
1034 void *))GetFunction(
"PauliPropGetNumGatesBetweenTruncations");
1035 CheckFunction((
void *)fPauliPropGetNumGatesBetweenTruncations,
1037 fPauliPropSetNumGatesBetweenTruncations =
1038 (void (*)(
void *, int))GetFunction(
1039 "PauliPropSetNumGatesBetweenTruncations");
1040 CheckFunction((
void *)fPauliPropSetNumGatesBetweenTruncations,
1042 fPauliPropGetNumGatesBetweenDeduplications = (int (*)(
1043 void *))GetFunction(
"PauliPropGetNumGatesBetweenDeduplications");
1044 CheckFunction((
void *)fPauliPropGetNumGatesBetweenDeduplications,
1046 fPauliPropSetNumGatesBetweenDeduplications =
1047 (void (*)(
void *, int))GetFunction(
1048 "PauliPropSetNumGatesBetweenDeduplications");
1049 CheckFunction((
void *)fPauliPropSetNumGatesBetweenDeduplications,
1052 fPauliPropClearOperators =
1053 (int (*)(
void *))GetFunction(
"PauliPropClearOperators");
1054 CheckFunction((
void *)fPauliPropClearOperators, __LINE__);
1055 fPauliPropAllocateMemory =
1056 (int (*)(
void *, double))GetFunction(
"PauliPropAllocateMemory");
1057 CheckFunction((
void *)fPauliPropAllocateMemory, __LINE__);
1059 fPauliPropGetExpectationValue =
1060 (double (*)(
void *))GetFunction(
"PauliPropGetExpectationValue");
1061 CheckFunction((
void *)fPauliPropGetExpectationValue, __LINE__);
1062 fPauliPropExecute = (int (*)(
void *))GetFunction(
"PauliPropExecute");
1063 CheckFunction((
void *)fPauliPropExecute, __LINE__);
1064 fPauliPropSetSeed = (int (*)(
void *,
unsigned long long))
1065 GetFunction(
"PauliPropSetSeed");
1066 CheckFunction((
void *)fPauliPropSetSeed, __LINE__);
1067 fPauliPropSetInPauliExpansionUnique =
1068 (int (*)(
void *,
const char *))GetFunction(
1069 "PauliPropSetInPauliExpansionUnique");
1070 CheckFunction((
void *)fPauliPropSetInPauliExpansionUnique, __LINE__);
1071 fPauliPropSetInPauliExpansionMultiple =
1072 (int (*)(
void *,
const char **,
const double *, int))GetFunction(
1073 "PauliPropSetInPauliExpansionMultiple");
1074 CheckFunction((
void *)fPauliPropSetInPauliExpansionMultiple,
1078 (int (*)(
void *, int))GetFunction(
"PauliPropApplyX");
1079 CheckFunction((
void *)fPauliPropApplyX, __LINE__);
1081 (int (*)(
void *, int))GetFunction(
"PauliPropApplyY");
1082 CheckFunction((
void *)fPauliPropApplyY, __LINE__);
1084 (int (*)(
void *, int))GetFunction(
"PauliPropApplyZ");
1085 CheckFunction((
void *)fPauliPropApplyZ, __LINE__);
1087 (int (*)(
void *, int))GetFunction(
"PauliPropApplyH");
1088 CheckFunction((
void *)fPauliPropApplyH, __LINE__);
1090 (int (*)(
void *, int))GetFunction(
"PauliPropApplyS");
1091 CheckFunction((
void *)fPauliPropApplyS, __LINE__);
1093 fPauliPropApplySQRTX =
1094 (int (*)(
void *, int))GetFunction(
"PauliPropApplySQRTX");
1095 CheckFunction((
void *)fPauliPropApplySQRTX, __LINE__);
1096 fPauliPropApplySQRTY =
1097 (int (*)(
void *, int))GetFunction(
"PauliPropApplySQRTY");
1098 CheckFunction((
void *)fPauliPropApplySQRTY, __LINE__);
1099 fPauliPropApplySQRTZ =
1100 (int (*)(
void *, int))GetFunction(
"PauliPropApplySQRTZ");
1101 CheckFunction((
void *)fPauliPropApplySQRTZ, __LINE__);
1103 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyCX");
1104 CheckFunction((
void *)fPauliPropApplyCX, __LINE__);
1106 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyCY");
1107 CheckFunction((
void *)fPauliPropApplyCY, __LINE__);
1109 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyCZ");
1110 CheckFunction((
void *)fPauliPropApplyCZ, __LINE__);
1111 fPauliPropApplySWAP =
1112 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplySWAP");
1113 CheckFunction((
void *)fPauliPropApplySWAP, __LINE__);
1114 fPauliPropApplyISWAP =
1115 (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyISWAP");
1116 CheckFunction((
void *)fPauliPropApplyISWAP, __LINE__);
1118 (int (*)(
void *, int, double))GetFunction(
"PauliPropApplyRX");
1119 CheckFunction((
void *)fPauliPropApplyRX, __LINE__);
1121 (int (*)(
void *, int, double))GetFunction(
"PauliPropApplyRY");
1122 CheckFunction((
void *)fPauliPropApplyRY, __LINE__);
1124 (int (*)(
void *, int, double))GetFunction(
"PauliPropApplyRZ");
1125 CheckFunction((
void *)fPauliPropApplyRZ, __LINE__);
1127 fPauliPropAddNoiseX =
1128 (int (*)(
void *, int, double))GetFunction(
"PauliPropAddNoiseX");
1129 CheckFunction((
void *)fPauliPropAddNoiseX, __LINE__);
1130 fPauliPropAddNoiseY =
1131 (int (*)(
void *, int, double))GetFunction(
"PauliPropAddNoiseY");
1132 CheckFunction((
void *)fPauliPropAddNoiseY, __LINE__);
1133 fPauliPropAddNoiseZ =
1134 (int (*)(
void *, int, double))GetFunction(
"PauliPropAddNoiseZ");
1135 CheckFunction((
void *)fPauliPropAddNoiseZ, __LINE__);
1136 fPauliPropAddNoiseXYZ =
1137 (int (*)(
void *, int, double, double, double))GetFunction(
1138 "PauliPropAddNoiseXYZ");
1139 CheckFunction((
void *)fPauliPropAddNoiseXYZ, __LINE__);
1140 fPauliPropAddAmplitudeDamping =
1141 (int (*)(
void *, int, double, double))GetFunction(
1142 "PauliPropAddAmplitudeDamping");
1143 CheckFunction((
void *)fPauliPropAddAmplitudeDamping, __LINE__);
1144 fPauliPropQubitProbability0 = (double (*)(
void *, int))GetFunction(
1145 "PauliPropQubitProbability0");
1146 CheckFunction((
void *)fPauliPropQubitProbability0, __LINE__);
1147 fPauliPropProbability =
1148 (double (*)(
void *,
unsigned long long int))GetFunction(
1149 "PauliPropProbability");
1150 CheckFunction((
void *)fPauliPropProbability, __LINE__);
1152 fPauliPropMeasureQubit =
1153 (int (*)(
void *, int))GetFunction(
"PauliPropMeasureQubit");
1154 CheckFunction((
void *)fPauliPropMeasureQubit, __LINE__);
1156 fPauliPropSampleQubits =
1157 (
unsigned char *(*)(
void *,
const int *,
int))GetFunction(
1158 "PauliPropSampleQubits");
1159 CheckFunction((
void *)fPauliPropSampleQubits, __LINE__);
1160 fPauliPropFreeSampledQubits = (void (*)(
unsigned char *))GetFunction(
1161 "PauliPropFreeSampledQubits");
1162 CheckFunction((
void *)fPauliPropFreeSampledQubits, __LINE__);
1163 fPauliPropSaveState =
1164 (void (*)(
void *))GetFunction(
"PauliPropSaveState");
1165 CheckFunction((
void *)fPauliPropSaveState, __LINE__);
1166 fPauliPropRestoreState =
1167 (void (*)(
void *))GetFunction(
"PauliPropRestoreState");
1168 CheckFunction((
void *)fPauliPropRestoreState, __LINE__);
1171 }
else if (!IsMuted())
1172 std::cerr <<
"GpuLibrary: Unable to initialize gpu library"
1174 }
else if (!IsMuted())
1175 std::cerr <<
"GpuLibrary: Unable to get initialization function for "
1183 void CheckFunction(
void *func,
int line)
const {
1184 if (!func && !IsMuted()) {
1185 std::cerr <<
"GpuLibrary: Unable to load function, line #: " << line;
1186 const char *dlsym_error = dlerror();
1187 if (dlsym_error) std::cerr <<
", error: " << dlsym_error;
1189 std::cerr << std::endl;
1193 bool IsValid()
const {
return LibraryHandle !=
nullptr; }
1198 int GetGpuDeviceCount()
const {
1199 return fGetGpuDeviceCount ? fGetGpuDeviceCount() : 0;
1204 bool SetGpuDevice(
int device) {
1205 auto lock = LockInitialization();
1206 if (device < 0 || !fSetGpuDevice || !fSetGpuDevice(device))
return false;
1207 creationDevice = device;
1210 int GetCreationDevice()
const {
return creationDevice; }
1212 int GetStateVectorGpuId(
void* obj)
const {
1213 return obj && fGetStateVectorGpuId ? fGetStateVectorGpuId(obj) : -1;
1215 int MPSGetGpuId(
void* obj)
const {
1216 return obj && fMPSGetGpuId ? fMPSGetGpuId(obj) : -1;
1218 int TNGetGpuId(
void* obj)
const {
1219 return obj && fTNGetGpuId ? fTNGetGpuId(obj) : -1;
1221 int DMGetGpuId(
void* obj)
const {
1222 return obj && fDMGetGpuId ? fDMGetGpuId(obj) : -1;
1224 int MPOGetGpuId(
void* obj)
const {
1225 return obj && fMPOGetGpuId ? fMPOGetGpuId(obj) : -1;
1227 int GetStabilizerGpuId(
void* obj)
const {
1228 return obj && fGetStabilizerGpuId ? fGetStabilizerGpuId(obj) : -1;
1230 int PauliPropGetGpuId(
void* obj)
const {
1231 return obj && fPauliPropGetGpuId ? fPauliPropGetGpuId(obj) : -1;
1234 bool HasDensityMatrixAPI()
const {
1235 return IsValid() && fCreateDensityMatrix && fDestroyDensityMatrix &&
1236 fDMCreate && fDMCreateWithState && fDMReset && fDMIsCreated &&
1238 fDMSaveState && fDMRestoreState && fDMCleanSavedState && fDMClone &&
1240 fDMMeasureQubitCollapse && fDMSampleAll &&
1241 fDMBasisStateProbability && fDMAllProbabilities &&
1242 fDMExpectationValue && fDMTrace && fDMPurity && fDMIsHermitian &&
1243 fDMPartialTrace && fDMHilbertSchmidtOverlap &&
1244 fDMFidelityWithStatevector && fDMApplyKraus && fDMApplyReset &&
1245 fDMApplyX && fDMApplyY && fDMApplyZ && fDMApplyH && fDMApplyS &&
1246 fDMApplySDG && fDMApplyT && fDMApplyTDG && fDMApplySX &&
1247 fDMApplySXDG && fDMApplyK && fDMApplyP && fDMApplyRx &&
1248 fDMApplyRy && fDMApplyRz && fDMApplyU && fDMApplyCX &&
1249 fDMApplyCY && fDMApplyCZ && fDMApplyCH && fDMApplyCSX &&
1250 fDMApplyCSXDG && fDMApplyCP && fDMApplyCRx && fDMApplyCRy &&
1251 fDMApplyCRz && fDMApplyCCX && fDMApplySwap && fDMApplyCSwap &&
1254 bool HasMPOAPI()
const {
1255 return IsValid() && fCreateMPO && fDestroyMPO &&
1256 fMPOCreate && fMPOCreateWithState && fMPOReset && fMPOIsCreated &&
1258 fMPOSaveState && fMPORestoreState && fMPOCleanSavedState &&
1259 fMPOClone && fMPOSetSeed && fMPOMeasureQubitCollapse &&
1261 fMPOBasisStateProbability && fMPOAllProbabilities &&
1262 fMPOExpectationValue && fMPOPartialTrace &&
1263 fMPOHilbertSchmidtOverlap && fMPOFidelityWithStatevector &&
1264 fMPOTrace && fMPOPurity && fMPOHermiticityResidual &&
1265 fMPOIsHermitian && fMPOTraceOfSquare && fMPORestoreTrace &&
1266 fMPOHermitize && fMPOReCanonicalize && fMPOTrim &&
1267 fMPOApplyKraus && fMPOApplyReset &&
1268 fMPOApplyX && fMPOApplyY && fMPOApplyZ && fMPOApplyH &&
1269 fMPOApplyS && fMPOApplySDG && fMPOApplyT && fMPOApplyTDG &&
1270 fMPOApplySX && fMPOApplySXDG && fMPOApplyK && fMPOApplyP &&
1271 fMPOApplyRx && fMPOApplyRy && fMPOApplyRz && fMPOApplyU &&
1272 fMPOApplyCX && fMPOApplyCY && fMPOApplyCZ && fMPOApplyCH &&
1273 fMPOApplyCSX && fMPOApplyCSXDG && fMPOApplyCP && fMPOApplyCRx &&
1274 fMPOApplyCRy && fMPOApplyCRz && fMPOApplySwap && fMPOApplyCU;
1279 void *CreateStateVector() {
1281 return fCreateStateVector(LibraryHandle);
1283 throw std::runtime_error(
"GpuLibrary: Unable to create state vector");
1286 void DestroyStateVector(
void *obj) {
1288 fDestroyStateVector(obj);
1290 throw std::runtime_error(
"GpuLibrary: Unable to destroy state vector");
1293 bool Create(
void *obj,
unsigned int nrQubits) {
1295 return fCreate(obj, nrQubits) == 1;
1297 throw std::runtime_error(
1298 "GpuLibrary: Unable to create state vector state");
1303 bool CreateWithState(
void *obj,
unsigned int nrQubits,
const double *state) {
1305 return fCreateWithState(obj, nrQubits, state) == 1;
1307 throw std::runtime_error(
1308 "GpuLibrary: Unable to create state vector state with a state");
1313 bool Reset(
void *obj) {
1315 return fReset(obj) == 1;
1317 throw std::runtime_error(
"GpuLibrary: Unable to reset state vector");
1322 bool SetDataType(
void *obj,
int dataType) {
1324 return fSetDataType(obj, dataType) == 1;
1326 throw std::runtime_error(
"GpuLibrary: Unable to set data type");
1331 bool IsDoublePrecision(
void *obj)
const {
1333 return fIsDoublePrecision(obj) == 1;
1335 throw std::runtime_error(
1336 "GpuLibrary: Unable to check if double precision");
1341 int GetNrQubits(
void *obj)
const {
1343 return fGetNrQubits(obj);
1345 throw std::runtime_error(
"GpuLibrary: Unable to get number of qubits");
1349 bool MeasureQubitCollapse(
void *obj,
int qubitIndex) {
1351 return fMeasureQubitCollapse(obj, qubitIndex) == 1;
1353 throw std::runtime_error(
1354 "GpuLibrary: Unable to measure qubit with collapse");
1359 bool MeasureQubitNoCollapse(
void *obj,
int qubitIndex) {
1361 return fMeasureQubitNoCollapse(obj, qubitIndex) == 1;
1363 throw std::runtime_error(
1364 "GpuLibrary: Unable to measure qubit no collapse");
1369 bool MeasureQubitsCollapse(
void *obj,
int *qubits,
int *bitstring,
1372 return fMeasureQubitsCollapse(obj, qubits, bitstring, bitstringLen) == 1;
1374 throw std::runtime_error(
1375 "GpuLibrary: Unable to measure qubits with collapse");
1380 bool MeasureQubitsNoCollapse(
void *obj,
int *qubits,
int *bitstring,
1383 return fMeasureQubitsNoCollapse(obj, qubits, bitstring, bitstringLen) ==
1386 throw std::runtime_error(
1387 "GpuLibrary: Unable to measure qubits with no collapse");
1392 unsigned long long MeasureAllQubitsCollapse(
void *obj) {
1394 return fMeasureAllQubitsCollapse(obj);
1396 throw std::runtime_error(
1397 "GpuLibrary: Unable to measure all qubits with collapse");
1402 unsigned long long MeasureAllQubitsNoCollapse(
void *obj) {
1404 return fMeasureAllQubitsNoCollapse(obj);
1406 throw std::runtime_error(
1407 "GpuLibrary: Unable to measure all qubits with no collapse");
1414 return fSaveState(obj) == 1;
1416 throw std::runtime_error(
"GpuLibrary: Unable to save state");
1421 bool SaveStateToHost(
void *obj) {
1423 return fSaveStateToHost(obj) == 1;
1425 throw std::runtime_error(
"GpuLibrary: Unable to save state to host");
1430 bool SaveStateDestructive(
void *obj) {
1432 return fSaveStateDestructive(obj) == 1;
1434 throw std::runtime_error(
1435 "GpuLibrary: Unable to save state destructively");
1440 bool RestoreStateFreeSaved(
void *obj) {
1442 return fRestoreStateFreeSaved(obj) == 1;
1444 throw std::runtime_error(
1445 "GpuLibrary: Unable to restore state free saved");
1450 bool RestoreStateNoFreeSaved(
void *obj) {
1452 return fRestoreStateNoFreeSaved(obj) == 1;
1454 throw std::runtime_error(
1455 "GpuLibrary: Unable to restore state no free saved");
1460 void FreeSavedState(
void *obj) {
1462 fFreeSavedState(obj);
1464 throw std::runtime_error(
"GpuLibrary: Unable to free saved state");
1467 void *Clone(
void *obj)
const {
1471 throw std::runtime_error(
"GpuLibrary: Unable to clone state vector");
1476 bool SetSeed(
void *obj,
unsigned long long seed)
const {
1477 return obj && fSetSeed && fSetSeed(obj, seed) == 1;
1480 bool Sample(
void *obj,
unsigned int nSamples,
long int *samples,
1481 unsigned int nBits,
int *bits) {
1483 return fSample(obj, nSamples, samples, nBits, bits) == 1;
1485 throw std::runtime_error(
"GpuLibrary: Unable to sample state vector");
1490 bool SampleAll(
void *obj,
unsigned int nSamples,
long int *samples) {
1492 return fSampleAll(obj, nSamples, samples) == 1;
1494 throw std::runtime_error(
"GpuLibrary: Unable to sample state vector");
1499 bool Amplitude(
void *obj,
long long int state,
double *real,
1500 double *imaginary)
const {
1502 return fAmplitude(obj, state, real, imaginary) == 1;
1504 throw std::runtime_error(
"GpuLibrary: Unable to get amplitude");
1509 double Probability(
void *obj,
int *qubits,
int *mask,
int len)
const {
1511 return fProbability(obj, qubits, mask, len);
1513 throw std::runtime_error(
"GpuLibrary: Unable to get probability");
1518 double BasisStateProbability(
void *obj,
long long int state)
const {
1520 return fBasisStateProbability(obj, state);
1522 throw std::runtime_error(
1523 "GpuLibrary: Unable to get basis state probability");
1530 return fAllProbabilities(obj, probabilities) == 1;
1532 throw std::runtime_error(
"GpuLibrary: Unable to get all probabilities");
1537 double ExpectationValue(
void *obj,
const char *pauliString,
int len)
const {
1539 return fExpectationValue(obj, pauliString, len);
1541 throw std::runtime_error(
"GpuLibrary: Unable to get expectation value");
1546 bool ApplyX(
void *obj,
int qubit) {
1548 return fApplyX(obj, qubit) == 1;
1550 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate");
1555 bool ApplyY(
void *obj,
int qubit) {
1557 return fApplyY(obj, qubit) == 1;
1559 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate");
1564 bool ApplyZ(
void *obj,
int qubit) {
1566 return fApplyZ(obj, qubit) == 1;
1568 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate");
1573 bool ApplyH(
void *obj,
int qubit) {
1575 return fApplyH(obj, qubit) == 1;
1577 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate");
1582 bool ApplyS(
void *obj,
int qubit) {
1584 return fApplyS(obj, qubit) == 1;
1586 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate");
1591 bool ApplySDG(
void *obj,
int qubit) {
1593 return fApplySDG(obj, qubit) == 1;
1595 throw std::runtime_error(
"GpuLibrary: Unable to apply SDG gate");
1600 bool ApplyT(
void *obj,
int qubit) {
1602 return fApplyT(obj, qubit) == 1;
1604 throw std::runtime_error(
"GpuLibrary: Unable to apply T gate");
1609 bool ApplyTDG(
void *obj,
int qubit) {
1611 return fApplyTDG(obj, qubit) == 1;
1613 throw std::runtime_error(
"GpuLibrary: Unable to apply TDG gate");
1618 bool ApplySX(
void *obj,
int qubit) {
1620 return fApplySX(obj, qubit) == 1;
1622 throw std::runtime_error(
"GpuLibrary: Unable to apply SX gate");
1629 return fApplySXDG(obj, qubit) == 1;
1631 throw std::runtime_error(
"GpuLibrary: Unable to apply SXDG gate");
1636 bool ApplyK(
void *obj,
int qubit) {
1638 return fApplyK(obj, qubit) == 1;
1640 throw std::runtime_error(
"GpuLibrary: Unable to apply K gate");
1645 bool ApplyP(
void *obj,
int qubit,
double theta) {
1647 return fApplyP(obj, qubit, theta) == 1;
1649 throw std::runtime_error(
"GpuLibrary: Unable to apply P gate");
1654 bool ApplyRx(
void *obj,
int qubit,
double theta) {
1656 return fApplyRx(obj, qubit, theta) == 1;
1658 throw std::runtime_error(
"GpuLibrary: Unable to apply Rx gate");
1663 bool ApplyRy(
void *obj,
int qubit,
double theta) {
1665 return fApplyRy(obj, qubit, theta) == 1;
1667 throw std::runtime_error(
"GpuLibrary: Unable to apply Ry gate");
1672 bool ApplyRz(
void *obj,
int qubit,
double theta) {
1674 return fApplyRz(obj, qubit, theta) == 1;
1676 throw std::runtime_error(
"GpuLibrary: Unable to apply Rz gate");
1681 bool ApplyU(
void *obj,
int qubit,
double theta,
double phi,
double lambda,
1684 return fApplyU(obj, qubit, theta, phi, lambda, gamma) == 1;
1686 throw std::runtime_error(
"GpuLibrary: Unable to apply U gate");
1691 bool ApplyCX(
void *obj,
int controlQubit,
int targetQubit) {
1693 return fApplyCX(obj, controlQubit, targetQubit) == 1;
1695 throw std::runtime_error(
"GpuLibrary: Unable to apply CX gate");
1700 bool ApplyCY(
void *obj,
int controlQubit,
int targetQubit) {
1702 return fApplyCY(obj, controlQubit, targetQubit) == 1;
1704 throw std::runtime_error(
"GpuLibrary: Unable to apply CY gate");
1709 bool ApplyCZ(
void *obj,
int controlQubit,
int targetQubit) {
1711 return fApplyCZ(obj, controlQubit, targetQubit) == 1;
1713 throw std::runtime_error(
"GpuLibrary: Unable to apply CZ gate");
1718 bool ApplyCH(
void *obj,
int controlQubit,
int targetQubit) {
1720 return fApplyCH(obj, controlQubit, targetQubit) == 1;
1722 throw std::runtime_error(
"GpuLibrary: Unable to apply CH gate");
1727 bool ApplyCSX(
void *obj,
int controlQubit,
int targetQubit) {
1729 return fApplyCSX(obj, controlQubit, targetQubit) == 1;
1731 throw std::runtime_error(
"GpuLibrary: Unable to apply CSX gate");
1736 bool ApplyCSXDG(
void *obj,
int controlQubit,
int targetQubit) {
1738 return fApplyCSXDG(obj, controlQubit, targetQubit) == 1;
1740 throw std::runtime_error(
"GpuLibrary: Unable to apply CSXDG gate");
1745 bool ApplyCP(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
1747 return fApplyCP(obj, controlQubit, targetQubit, theta) == 1;
1749 throw std::runtime_error(
"GpuLibrary: Unable to apply CP gate");
1754 bool ApplyCRx(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
1756 return fApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
1758 throw std::runtime_error(
"GpuLibrary: Unable to apply CRx gate");
1763 bool ApplyCRy(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
1765 return fApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
1767 throw std::runtime_error(
"GpuLibrary: Unable to apply CRy gate");
1772 bool ApplyCRz(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
1774 return fApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
1776 throw std::runtime_error(
"GpuLibrary: Unable to apply CRz gate");
1781 bool ApplyCCX(
void *obj,
int controlQubit1,
int controlQubit2,
1784 return fApplyCCX(obj, controlQubit1, controlQubit2, targetQubit) == 1;
1786 throw std::runtime_error(
"GpuLibrary: Unable to apply CCX gate");
1791 bool ApplySwap(
void *obj,
int qubit1,
int qubit2) {
1793 return fApplySwap(obj, qubit1, qubit2) == 1;
1795 throw std::runtime_error(
"GpuLibrary: Unable to apply Swap gate");
1800 bool ApplyCSwap(
void *obj,
int controlQubit,
int qubit1,
int qubit2) {
1802 return fApplyCSwap(obj, controlQubit, qubit1, qubit2) == 1;
1804 throw std::runtime_error(
"GpuLibrary: Unable to apply CSwap gate");
1809 bool ApplyCU(
void *obj,
int controlQubit,
int targetQubit,
double theta,
1810 double phi,
double lambda,
double gamma) {
1812 return fApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda,
1815 throw std::runtime_error(
"GpuLibrary: Unable to apply CU gate");
1822 void *CreateDensityMatrix() {
1823 if (!LibraryHandle || !fCreateDensityMatrix)
return nullptr;
1824 return fCreateDensityMatrix(LibraryHandle);
1826 void DestroyDensityMatrix(
void *obj) {
1827 if (obj && fDestroyDensityMatrix) fDestroyDensityMatrix(obj);
1829#define DM_BOOL0(name) \
1830 bool name(void *obj) { return obj && f##name && f##name(obj) == 1; }
1831#define DM_BOOL1(name, type) \
1832 bool name(void *obj, type a) { return obj && f##name && f##name(obj, a) == 1; }
1833#define DM_BOOL2(name, type1, type2) \
1834 bool name(void *obj, type1 a, type2 b) { \
1835 return obj && f##name && f##name(obj, a, b) == 1; \
1837#define DM_BOOL3(name, type1, type2, type3) \
1838 bool name(void *obj, type1 a, type2 b, type3 c) { \
1839 return obj && f##name && f##name(obj, a, b, c) == 1; \
1841 DM_BOOL1(DMCreate,
unsigned int)
1842 bool DMCreateWithState(
void *obj,
unsigned int n,
const double *data) {
1843 return obj && fDMCreateWithState && fDMCreateWithState(obj, n, data) == 1;
1845 bool DMCreateWithBasisState(
void *obj,
unsigned int n,
1846 unsigned long long state) {
1847 return obj && fDMCreateWithBasisState &&
1848 fDMCreateWithBasisState(obj, n, state) == 1;
1850 bool DMCreateWithMixtureOfBasisStates(
void *obj,
unsigned int n,
1851 const unsigned long long *states,
1852 const double *weights,
int nTerms) {
1853 return obj && fDMCreateWithMixtureOfBasisStates &&
1854 fDMCreateWithMixtureOfBasisStates(obj, n, states, weights,
1857 DM_BOOL0(DMReset) DM_BOOL0(DMIsValid) DM_BOOL0(DMIsCreated)
1858 DM_BOOL1(DMSetDataType,
int) DM_BOOL0(DMIsDoublePrecision)
1859 int DMGetNrQubits(
void *obj)
const {
1860 return obj && fDMGetNrQubits ? fDMGetNrQubits(obj) : 0;
1862 DM_BOOL0(DMSaveState) DM_BOOL0(DMRestoreState)
1863 DM_BOOL0(DMCleanSavedState)
1864 void *DMClone(
void *obj) {
return obj && fDMClone ? fDMClone(obj) :
nullptr; }
1865 bool DMSetSeed(
void *obj,
unsigned long long seed)
const {
1866 return obj && fDMSetSeed && fDMSetSeed(obj, seed) == 1;
1868 bool DMMeasureQubitCollapse(
void *obj,
int q) {
1869 return obj && fDMMeasureQubitCollapse && fDMMeasureQubitCollapse(obj, q);
1871 DM_BOOL1(DMMeasureQubitNoCollapse,
int)
1872 bool DMMeasureQubitsCollapse(
void *obj,
int *q,
int *bits,
int n) {
1873 return obj && fDMMeasureQubitsCollapse && fDMMeasureQubitsCollapse(obj, q, bits, n) == 1;
1875 bool DMMeasureQubitsNoCollapse(
void *obj,
int *q,
int *bits,
int n) {
1876 return obj && fDMMeasureQubitsNoCollapse && fDMMeasureQubitsNoCollapse(obj, q, bits, n) == 1;
1878 unsigned long long DMMeasureAllQubitsCollapse(
void *obj) {
return obj && fDMMeasureAllQubitsCollapse ? fDMMeasureAllQubitsCollapse(obj) : 0; }
1879 unsigned long long DMMeasureAllQubitsNoCollapse(
void *obj) {
return obj && fDMMeasureAllQubitsNoCollapse ? fDMMeasureAllQubitsNoCollapse(obj) : 0; }
1880 bool DMGetElement(
void *obj,
long long row,
long long col,
double *re,
double *im)
const {
1881 return obj && fDMGetElement && fDMGetElement(obj, row, col, re, im) == 1;
1883 bool DMSample(
void *obj,
unsigned int n,
long int *samples,
unsigned int nBits,
int *order) {
1884 return obj && fDMSample && fDMSample(obj, n, samples, nBits, order) == 1;
1886 bool DMSampleAll(
void *obj,
unsigned int shots,
long int *samples) {
1887 return obj && fDMSampleAll && fDMSampleAll(obj, shots, samples) == 1;
1889 double DMBasisStateProbability(
void *obj,
long long state)
const {
1890 return obj && fDMBasisStateProbability
1891 ? fDMBasisStateProbability(obj, state) : 0.0;
1893 bool DMAllProbabilities(
void *obj,
double *values) {
1894 return obj && fDMAllProbabilities && fDMAllProbabilities(obj, values) == 1;
1896 double DMExpectationValue(
void *obj,
const char *pauli,
int len)
const {
1897 return obj && fDMExpectationValue ? fDMExpectationValue(obj, pauli, len) : 0.0;
1899 double DMQubitProbability0(
void *obj,
unsigned int q)
const {
return obj && fDMQubitProbability0 ? fDMQubitProbability0(obj, q) : 0.; }
1900 double DMTrace(
void *obj)
const {
return obj && fDMTrace ? fDMTrace(obj) : 0.; }
1901 double DMPurity(
void *obj)
const {
return obj && fDMPurity ? fDMPurity(obj) : 0.; }
1902 bool DMIsHermitian(
void *obj,
double eps)
const {
return obj && fDMIsHermitian && fDMIsHermitian(obj, eps) == 1; }
1903 bool DMPartialTrace(
void *obj,
const int *q,
int n,
double *out) {
return obj && fDMPartialTrace && fDMPartialTrace(obj, q, n, out) == 1; }
1904 bool DMHilbertSchmidtOverlap(
void *obj,
void *other,
double *re,
double *im) {
return obj && other && fDMHilbertSchmidtOverlap && fDMHilbertSchmidtOverlap(obj, other, re, im) == 1; }
1905 bool DMFidelityWithStatevector(
void *obj,
const double *state,
double *out) {
return obj && fDMFidelityWithStatevector && fDMFidelityWithStatevector(obj, state, out) == 1; }
1906 bool DMApplyKraus(
void *obj,
int n,
const int *qubits,
int count,
1907 const double *operators) {
1908 return obj && fDMApplyKraus &&
1909 fDMApplyKraus(obj, n, qubits, count, operators) == 1;
1911 DM_BOOL1(DMApplyReset,
int)
1912 DM_BOOL2(DMApplyBitFlipNoise,
int,
double) DM_BOOL2(DMApplyPhaseFlipNoise,
int,
double)
1913 DM_BOOL2(DMApplyDepolarizingNoise,
int,
double) DM_BOOL2(DMApplyAmplitudeDamping,
int,
double)
1914 DM_BOOL2(DMApplyPhaseDamping,
int,
double) DM_BOOL1(DMApplyNonSelectiveMeasurement,
int)
1915 DM_BOOL1(DMApplyX,
int) DM_BOOL1(DMApplyY,
int)
1916 DM_BOOL1(DMApplyZ,
int) DM_BOOL1(DMApplyH,
int)
1917 DM_BOOL1(DMApplyS,
int) DM_BOOL1(DMApplySDG,
int)
1918 DM_BOOL1(DMApplyT,
int) DM_BOOL1(DMApplyTDG,
int)
1919 DM_BOOL1(DMApplySX,
int) DM_BOOL1(DMApplySXDG,
int)
1920 DM_BOOL1(DMApplyK,
int)
1921 DM_BOOL2(DMApplyP,
int,
double) DM_BOOL2(DMApplyRx,
int,
double)
1922 DM_BOOL2(DMApplyRy,
int,
double) DM_BOOL2(DMApplyRz,
int,
double)
1923 bool DMApplyU(
void *o,
int q,
double a,
double b,
double c,
double d) {
1924 return o && fDMApplyU && fDMApplyU(o, q, a, b, c, d) == 1;
1926 DM_BOOL2(DMApplyCX,
int,
int) DM_BOOL2(DMApplyCY,
int,
int)
1927 DM_BOOL2(DMApplyCZ,
int,
int) DM_BOOL2(DMApplyCH,
int,
int)
1928 DM_BOOL2(DMApplyCSX,
int,
int) DM_BOOL2(DMApplyCSXDG,
int,
int)
1929 DM_BOOL3(DMApplyCP,
int,
int,
double)
1930 DM_BOOL3(DMApplyCRx,
int,
int,
double)
1931 DM_BOOL3(DMApplyCRy,
int,
int,
double)
1932 DM_BOOL3(DMApplyCRz,
int,
int,
double)
1933 DM_BOOL3(DMApplyCCX,
int,
int,
int)
1934 DM_BOOL2(DMApplySwap,
int,
int)
1935 DM_BOOL3(DMApplyCSwap,
int,
int,
int)
1936 bool DMApplyCU(
void *o,
int c,
int t,
double a,
double b,
double d,
1938 return o && fDMApplyCU && fDMApplyCU(o, c, t, a, b, d, g) == 1;
1948 if (!LibraryHandle || !fCreateMPO)
return nullptr;
1949 return fCreateMPO(LibraryHandle);
1951 void DestroyMPO(
void *obj) {
1952 if (obj && fDestroyMPO) fDestroyMPO(obj);
1954#define MPO_BOOL0(name) \
1955 bool name(void *obj) { return obj && f##name && f##name(obj) == 1; }
1956#define MPO_BOOL1(name, type) \
1957 bool name(void *obj, type a) { return obj && f##name && f##name(obj, a) == 1; }
1958#define MPO_BOOL2(name, type1, type2) \
1959 bool name(void *obj, type1 a, type2 b) { \
1960 return obj && f##name && f##name(obj, a, b) == 1; \
1962#define MPO_BOOL3(name, type1, type2, type3) \
1963 bool name(void *obj, type1 a, type2 b, type3 c) { \
1964 return obj && f##name && f##name(obj, a, b, c) == 1; \
1966 MPO_BOOL1(MPOCreate,
unsigned int)
1967 bool MPOCreateWithState(
void *obj,
unsigned int n,
const double *data) {
1968 return obj && fMPOCreateWithState && fMPOCreateWithState(obj, n, data) == 1;
1970 bool MPOCreateWithBasisState(
void *obj,
unsigned int n,
1971 unsigned long long state) {
1972 return obj && fMPOCreateWithBasisState &&
1973 fMPOCreateWithBasisState(obj, n, state) == 1;
1975 bool MPOCreateWithBasisStateBits(
void *obj,
unsigned int n,
1976 const unsigned char *stateBits) {
1977 return obj && fMPOCreateWithBasisStateBits &&
1978 fMPOCreateWithBasisStateBits(obj, n, stateBits) == 1;
1980 bool MPOCreateWithMixtureOfBasisStates(
void *obj,
unsigned int n,
1981 const unsigned long long *states,
1982 const double *weights,
int nTerms) {
1983 return obj && fMPOCreateWithMixtureOfBasisStates &&
1984 fMPOCreateWithMixtureOfBasisStates(obj, n, states, weights,
1987 bool MPOCreateWithMixtureOfBasisStatesBits(
void *obj,
unsigned int n,
1988 const unsigned char *stateBitsFlat,
1989 const double *weights,
1991 return obj && fMPOCreateWithMixtureOfBasisStatesBits &&
1992 fMPOCreateWithMixtureOfBasisStatesBits(obj, n, stateBitsFlat,
1993 weights, nTerms) == 1;
1996 bool MPOSetInitialQubitsMap(
void *obj,
1997 const std::vector<long long int> &initialMap) {
1998 return obj && fMPOSetInitialQubitsMap &&
1999 fMPOSetInitialQubitsMap(obj, initialMap.data(),
2000 static_cast<int>(initialMap.size())) == 1;
2002 MPO_BOOL1(MPOSetUseOptimalMeetingPosition,
int)
2003 bool MPOGetUseOptimalMeetingPosition(
void *obj)
const {
2004 return obj && fMPOGetUseOptimalMeetingPosition &&
2005 fMPOGetUseOptimalMeetingPosition(obj) == 1;
2007 MPO_BOOL0(MPOIsValid) MPO_BOOL0(MPOIsCreated)
2008 MPO_BOOL1(MPOSetDataType,
int) MPO_BOOL0(MPOIsDoublePrecision)
2009 int MPOGetNrQubits(
void *obj)
const {
2010 return obj && fMPOGetNrQubits ? fMPOGetNrQubits(obj) : 0;
2012 MPO_BOOL1(MPOSetCutoff,
double)
2013 double MPOGetCutoff(
void *obj)
const {
2014 return obj && fMPOGetCutoff ? fMPOGetCutoff(obj) : 0.0;
2016 MPO_BOOL1(MPOSetTruncationMode,
int)
2017 int MPOGetTruncationMode(
void *obj)
const {
2018 return obj && fMPOGetTruncationMode ? fMPOGetTruncationMode(obj) : 0;
2020 MPO_BOOL1(MPOSetGesvdJ,
int)
2021 bool MPOGetGesvdJ(
void *obj)
const {
return obj && fMPOGetGesvdJ && fMPOGetGesvdJ(obj) == 1; }
2022 bool MPOSetGesvdP(
void *obj,
int val) {
2023 return LibraryHandle && obj && fMPOSetGesvdP &&
2024 fMPOSetGesvdP(obj, val) == 1;
2027 bool MPOGetGesvdP(
void *obj)
const {
2028 if (!LibraryHandle || !obj || !fMPOGetGesvdP)
2029 throw std::runtime_error(
"GpuLibrary: MPOGetGesvdP is unavailable");
2030 return fMPOGetGesvdP(obj) == 1;
2033 bool MPOSetGesvdR(
void *obj,
int val) {
2034 return LibraryHandle && obj && fMPOSetGesvdR &&
2035 fMPOSetGesvdR(obj, val) == 1;
2038 bool MPOGetGesvdR(
void *obj)
const {
2039 if (!LibraryHandle || !obj || !fMPOGetGesvdR)
2040 throw std::runtime_error(
"GpuLibrary: MPOGetGesvdR is unavailable");
2041 return fMPOGetGesvdR(obj) == 1;
2045 int MPOGetLastSvdAlgo(
void *obj)
const {
2046 if (!LibraryHandle || !obj || !fMPOGetLastSvdAlgo)
2047 throw std::runtime_error(
"GpuLibrary: MPOGetLastSvdAlgo is unavailable");
2048 return fMPOGetLastSvdAlgo(obj);
2051 MPO_BOOL1(MPOSetMaxExtent,
long int)
2052 long int MPOGetMaxExtent(
void *obj)
const {
2053 return obj && fMPOGetMaxExtent ? fMPOGetMaxExtent(obj) : 0;
2055 bool MPOGetBondDimensions(
void *obj,
long long int *bondDims) {
2056 return obj && fMPOGetBondDimensions &&
2057 fMPOGetBondDimensions(obj, bondDims) == 1;
2059 bool MPOSetCallbackContext(
void *obj,
void *context) {
2060 return obj && fMPOSetCallbackContext &&
2061 fMPOSetCallbackContext(obj, context) == 1;
2063 bool MPOSetMeetingPositionCallback(
2064 void *obj, int64_t (*callback)(
void *,
const int64_t *)) {
2065 return obj && fMPOSetMeetingPositionCallback &&
2066 fMPOSetMeetingPositionCallback(obj, callback) == 1;
2068 bool MPOSetBondDimensionsCallback(
2069 void *obj,
void (*callback)(
void *,
const int64_t *)) {
2070 return obj && fMPOSetBondDimensionsCallback &&
2071 fMPOSetBondDimensionsCallback(obj, callback) == 1;
2073 MPO_BOOL1(MPOReCanonicalize,
int)
2074 bool MPOTrim(
void *obj,
double cutoff,
long int maxExtent,
int center) {
return obj && fMPOTrim && fMPOTrim(obj, cutoff, maxExtent, center) == 1; }
2075 MPO_BOOL0(MPOSaveState) MPO_BOOL0(MPORestoreState)
2076 MPO_BOOL0(MPOCleanSavedState)
2077 void *MPOClone(
void *obj) {
2078 return obj && fMPOClone ? fMPOClone(obj) :
nullptr;
2080 bool MPOSetSeed(
void *obj,
unsigned long long seed)
const {
2081 return obj && fMPOSetSeed && fMPOSetSeed(obj, seed) == 1;
2083 bool MPOMeasureQubitCollapse(
void *obj,
int q) {
2084 return obj && fMPOMeasureQubitCollapse && fMPOMeasureQubitCollapse(obj, q);
2086 MPO_BOOL1(MPOMeasureQubitNoCollapse,
int)
2087 bool MPOMeasureQubitsCollapse(
void *obj,
int *q,
int *bits,
int n) {
return obj && fMPOMeasureQubitsCollapse && fMPOMeasureQubitsCollapse(obj, q, bits, n) == 1; }
2088 bool MPOMeasureQubitsNoCollapse(
void *obj,
int *q,
int *bits,
int n) {
return obj && fMPOMeasureQubitsNoCollapse && fMPOMeasureQubitsNoCollapse(obj, q, bits, n) == 1; }
2089 unsigned long long MPOMeasureAllQubitsCollapse(
void *obj) {
return obj && fMPOMeasureAllQubitsCollapse ? fMPOMeasureAllQubitsCollapse(obj) : 0; }
2090 unsigned long long MPOMeasureAllQubitsNoCollapse(
void *obj) {
return obj && fMPOMeasureAllQubitsNoCollapse ? fMPOMeasureAllQubitsNoCollapse(obj) : 0; }
2091 bool MPOGetElement(
void *obj,
long long row,
long long col,
double *re,
double *im)
const {
2092 return obj && fMPOGetElement && fMPOGetElement(obj, row, col, re, im) == 1;
2094 bool MPOSample(
void *obj,
unsigned int nSamples,
long int *samples,
2095 unsigned int nBits,
int *bitOrdering) {
2096 return obj && fMPOSample &&
2097 fMPOSample(obj, nSamples, samples, nBits, bitOrdering) == 1;
2099 bool MPOSampleAll(
void *obj,
unsigned int shots,
long int *samples) {
2100 return obj && fMPOSampleAll && fMPOSampleAll(obj, shots, samples) == 1;
2102 double MPOBasisStateProbability(
void *obj,
long long state)
const {
2103 return obj && fMPOBasisStateProbability
2104 ? fMPOBasisStateProbability(obj, state) : 0.0;
2106 bool MPOAllProbabilities(
void *obj,
double *values) {
2107 return obj && fMPOAllProbabilities && fMPOAllProbabilities(obj, values) == 1;
2109 double MPOExpectationValue(
void *obj,
const char *pauli,
int len)
const {
2110 return obj && fMPOExpectationValue ? fMPOExpectationValue(obj, pauli, len)
2113 double MPOQubitProbability0(
void *obj,
unsigned int q)
const {
return obj && fMPOQubitProbability0 ? fMPOQubitProbability0(obj, q) : 0.; }
2114 bool MPOPartialTrace(
void *obj,
const int *q,
int n,
double *out) {
return obj && fMPOPartialTrace && fMPOPartialTrace(obj, q, n, out) == 1; }
2115 bool MPOHilbertSchmidtOverlap(
void *obj,
void *other,
double *re,
double *im) {
return obj && other && fMPOHilbertSchmidtOverlap && fMPOHilbertSchmidtOverlap(obj, other, re, im) == 1; }
2116 bool MPOFidelityWithStatevector(
void *obj,
const double *state,
double *out) {
return obj && fMPOFidelityWithStatevector && fMPOFidelityWithStatevector(obj, state, out) == 1; }
2117 double MPOTrace(
void *obj)
const {
return obj && fMPOTrace ? fMPOTrace(obj) : 0.; }
2118 double MPOPurity(
void *obj)
const {
return obj && fMPOPurity ? fMPOPurity(obj) : 0.; }
2119 double MPOHermiticityResidual(
void *obj)
const {
return obj && fMPOHermiticityResidual ? fMPOHermiticityResidual(obj) : 0.; }
2120 bool MPOIsHermitian(
void *obj,
double eps)
const {
return obj && fMPOIsHermitian && fMPOIsHermitian(obj, eps) == 1; }
2121 double MPOTraceOfSquare(
void *obj)
const {
return obj && fMPOTraceOfSquare ? fMPOTraceOfSquare(obj) : 0.; }
2122 MPO_BOOL0(MPORestoreTrace) MPO_BOOL0(MPOHermitize)
2123 MPO_BOOL1(MPOSetKrausCompletenessCheck,
int)
2124 int MPOGetKrausCompletenessCheck(
void *obj)
const {
return obj && fMPOGetKrausCompletenessCheck ? fMPOGetKrausCompletenessCheck(obj) : -1; }
2125 bool MPOApplyKraus(
void *obj,
int n,
const int *qubits,
int count,
2126 const double *operators) {
2127 return obj && fMPOApplyKraus &&
2128 fMPOApplyKraus(obj, n, qubits, count, operators) == 1;
2130 MPO_BOOL1(MPOApplyReset,
int)
2131 MPO_BOOL2(MPOApplyBitFlipNoise,
int,
double) MPO_BOOL2(MPOApplyPhaseFlipNoise,
int,
double)
2132 MPO_BOOL2(MPOApplyDepolarizingNoise,
int,
double) MPO_BOOL2(MPOApplyAmplitudeDamping,
int,
double)
2133 MPO_BOOL2(MPOApplyPhaseDamping,
int,
double) MPO_BOOL1(MPOApplyNonSelectiveMeasurement,
int)
2134 MPO_BOOL1(MPOApplyX,
int) MPO_BOOL1(MPOApplyY,
int)
2135 MPO_BOOL1(MPOApplyZ,
int) MPO_BOOL1(MPOApplyH,
int)
2136 MPO_BOOL1(MPOApplyS,
int) MPO_BOOL1(MPOApplySDG,
int)
2137 MPO_BOOL1(MPOApplyT,
int) MPO_BOOL1(MPOApplyTDG,
int)
2138 MPO_BOOL1(MPOApplySX,
int) MPO_BOOL1(MPOApplySXDG,
int)
2139 MPO_BOOL1(MPOApplyK,
int)
2140 MPO_BOOL2(MPOApplyP,
int,
double) MPO_BOOL2(MPOApplyRx,
int,
double)
2141 MPO_BOOL2(MPOApplyRy,
int,
double) MPO_BOOL2(MPOApplyRz,
int,
double)
2142 bool MPOApplyU(
void *o,
int q,
double a,
double b,
double c,
double d) {
2143 return o && fMPOApplyU && fMPOApplyU(o, q, a, b, c, d) == 1;
2145 bool MPOApplyOneQubitMatrix(
void *obj,
int qubit,
2146 const double *matrixInterleaved) {
2147 return obj && fMPOApplyOneQubitMatrix &&
2148 fMPOApplyOneQubitMatrix(obj, qubit, matrixInterleaved) == 1;
2150 bool MPOApplyTwoQubitMatrix(
void *obj,
int qubit1,
int qubit2,
2151 const double *matrixInterleaved) {
2152 return obj && fMPOApplyTwoQubitMatrix &&
2153 fMPOApplyTwoQubitMatrix(obj, qubit1, qubit2, matrixInterleaved) ==
2156 MPO_BOOL2(MPOApplyCX,
int,
int) MPO_BOOL2(MPOApplyCY,
int,
int)
2157 MPO_BOOL2(MPOApplyCZ,
int,
int) MPO_BOOL2(MPOApplyCH,
int,
int)
2158 MPO_BOOL2(MPOApplyCSX,
int,
int) MPO_BOOL2(MPOApplyCSXDG,
int,
int)
2159 MPO_BOOL3(MPOApplyCP,
int,
int,
double)
2160 MPO_BOOL3(MPOApplyCRx,
int,
int,
double)
2161 MPO_BOOL3(MPOApplyCRy,
int,
int,
double)
2162 MPO_BOOL3(MPOApplyCRz,
int,
int,
double)
2163 MPO_BOOL2(MPOApplySwap,
int,
int)
2164 bool MPOApplyCU(
void *o,
int c,
int t,
double a,
double b,
double d,
2166 return o && fMPOApplyCU && fMPOApplyCU(o, c, t, a, b, d, g) == 1;
2175 void *(*fCreateDensityMatrix)(
void *) =
nullptr;
2176 void (*fDestroyDensityMatrix)(
void *) =
nullptr;
2177 int (*fDMCreate)(
void *,
unsigned int) =
nullptr;
2178 int (*fDMCreateWithState)(
void *,
unsigned int,
const double *) =
nullptr;
2179 int (*fDMCreateWithBasisState)(
void *,
unsigned int,
2180 unsigned long long) =
nullptr;
2181 int (*fDMCreateWithMixtureOfBasisStates)(
void *,
unsigned int,
2182 const unsigned long long *,
2183 const double *, int) =
nullptr;
2184 int (*fDMReset)(
void *) =
nullptr;
2185 int (*fDMIsValid)(
void *) =
nullptr;
2186 int (*fDMIsCreated)(
void *) =
nullptr;
2187 int (*fDMSetDataType)(
void *, int) =
nullptr;
2188 int (*fDMIsDoublePrecision)(
void *) =
nullptr;
2189 int (*fDMGetNrQubits)(
void *) =
nullptr;
2190 int (*fDMSaveState)(
void *) =
nullptr;
2191 int (*fDMRestoreState)(
void *) =
nullptr;
2192 int (*fDMCleanSavedState)(
void *) =
nullptr;
2193 void *(*fDMClone)(
void *) =
nullptr;
2194 int (*fDMSetSeed)(
void *,
unsigned long long) =
nullptr;
2195 int (*fDMMeasureQubitCollapse)(
void *, int) =
nullptr;
2196 int (*fDMMeasureQubitNoCollapse)(
void *, int) =
nullptr;
2197 int (*fDMMeasureQubitsCollapse)(
void *,
int *,
int *, int) =
nullptr;
2198 int (*fDMMeasureQubitsNoCollapse)(
void *,
int *,
int *, int) =
nullptr;
2199 unsigned long long (*fDMMeasureAllQubitsCollapse)(
void *) =
nullptr;
2200 unsigned long long (*fDMMeasureAllQubitsNoCollapse)(
void *) =
nullptr;
2201 int (*fDMSample)(
void *,
unsigned int,
long int *,
unsigned int,
int *) =
nullptr;
2202 int (*fDMSampleAll)(
void *,
unsigned int,
long int *) =
nullptr;
2203 int (*fDMGetElement)(
void *,
long long,
long long,
double *,
double *) =
nullptr;
2204 double (*fDMBasisStateProbability)(
void *,
long long) =
nullptr;
2205 int (*fDMAllProbabilities)(
void *,
double *) =
nullptr;
2206 double (*fDMExpectationValue)(
void *,
const char *, int) =
nullptr;
2207 double (*fDMQubitProbability0)(
void *,
unsigned int) =
nullptr;
2208 double (*fDMTrace)(
void *) =
nullptr;
2209 double (*fDMPurity)(
void *) =
nullptr;
2210 int (*fDMIsHermitian)(
void *, double) =
nullptr;
2211 int (*fDMPartialTrace)(
void *,
const int *, int,
double *) =
nullptr;
2212 int (*fDMHilbertSchmidtOverlap)(
void *,
void *,
double *,
double *) =
nullptr;
2213 int (*fDMFidelityWithStatevector)(
void *,
const double *,
double *) =
nullptr;
2214 int (*fDMApplyKraus)(
void *, int,
const int *, int,
const double *) =
nullptr;
2215 int (*fDMApplyReset)(
void *, int) =
nullptr;
2216#define DECL_DM1(name) int (*f##name)(void *, int) = nullptr
2217#define DECL_DM2(name) int (*f##name)(void *, int, int) = nullptr
2218#define DECL_DMR1(name) int (*f##name)(void *, int, double) = nullptr
2219#define DECL_DMR2(name) int (*f##name)(void *, int, int, double) = nullptr
2220 DECL_DMR1(DMApplyBitFlipNoise); DECL_DMR1(DMApplyPhaseFlipNoise);
2221 DECL_DMR1(DMApplyDepolarizingNoise); DECL_DMR1(DMApplyAmplitudeDamping);
2222 DECL_DMR1(DMApplyPhaseDamping); DECL_DM1(DMApplyNonSelectiveMeasurement);
2223 DECL_DM1(DMApplyX); DECL_DM1(DMApplyY); DECL_DM1(DMApplyZ);
2224 DECL_DM1(DMApplyH); DECL_DM1(DMApplyS); DECL_DM1(DMApplySDG);
2225 DECL_DM1(DMApplyT); DECL_DM1(DMApplyTDG); DECL_DM1(DMApplySX);
2226 DECL_DM1(DMApplySXDG); DECL_DM1(DMApplyK);
2227 DECL_DMR1(DMApplyP); DECL_DMR1(DMApplyRx); DECL_DMR1(DMApplyRy);
2228 DECL_DMR1(DMApplyRz);
2229 int (*fDMApplyU)(
void *, int, double, double, double, double) =
nullptr;
2230 DECL_DM2(DMApplyCX); DECL_DM2(DMApplyCY); DECL_DM2(DMApplyCZ);
2231 DECL_DM2(DMApplyCH); DECL_DM2(DMApplyCSX); DECL_DM2(DMApplyCSXDG);
2232 DECL_DMR2(DMApplyCP); DECL_DMR2(DMApplyCRx); DECL_DMR2(DMApplyCRy);
2233 DECL_DMR2(DMApplyCRz);
2234 int (*fDMApplyCCX)(
void *, int, int, int) =
nullptr;
2235 DECL_DM2(DMApplySwap);
2236 int (*fDMApplyCSwap)(
void *, int, int, int) =
nullptr;
2237 int (*fDMApplyCU)(
void *, int, int, double, double, double, double) =
nullptr;
2245 void *(*fCreateMPO)(
void *) =
nullptr;
2246 void (*fDestroyMPO)(
void *) =
nullptr;
2247 int (*fMPOCreate)(
void *,
unsigned int) =
nullptr;
2248 int (*fMPOCreateWithState)(
void *,
unsigned int,
const double *) =
nullptr;
2249 int (*fMPOCreateWithBasisState)(
void *,
unsigned int,
2250 unsigned long long) =
nullptr;
2251 int (*fMPOCreateWithBasisStateBits)(
void *,
unsigned int,
2252 const unsigned char *) =
nullptr;
2253 int (*fMPOCreateWithMixtureOfBasisStates)(
void *,
unsigned int,
2254 const unsigned long long *,
2255 const double *, int) =
nullptr;
2256 int (*fMPOCreateWithMixtureOfBasisStatesBits)(
void *,
unsigned int,
2257 const unsigned char *,
2260 int (*fMPOReset)(
void *) =
nullptr;
2261 int (*fMPOSetInitialQubitsMap)(
void *,
const long long int *,
2263 int (*fMPOSetUseOptimalMeetingPosition)(
void *, int) =
nullptr;
2264 int (*fMPOGetUseOptimalMeetingPosition)(
void *) =
nullptr;
2265 int (*fMPOIsValid)(
void *) =
nullptr;
2266 int (*fMPOIsCreated)(
void *) =
nullptr;
2267 int (*fMPOSetDataType)(
void *, int) =
nullptr;
2268 int (*fMPOIsDoublePrecision)(
void *) =
nullptr;
2269 int (*fMPOGetNrQubits)(
void *) =
nullptr;
2270 int (*fMPOSetCutoff)(
void *, double) =
nullptr;
2271 double (*fMPOGetCutoff)(
void *) =
nullptr;
2272 int (*fMPOSetTruncationMode)(
void *, int) =
nullptr;
2273 int (*fMPOGetTruncationMode)(
void *) =
nullptr;
2274 int (*fMPOSetGesvdJ)(
void *, int) =
nullptr;
2275 int (*fMPOGetGesvdJ)(
void *) =
nullptr;
2276 int (*fMPOSetGesvdP)(
void *, int) =
nullptr;
2277 int (*fMPOGetGesvdP)(
void *) =
nullptr;
2278 int (*fMPOSetGesvdR)(
void *, int) =
nullptr;
2279 int (*fMPOGetGesvdR)(
void *) =
nullptr;
2280 int (*fMPOGetLastSvdAlgo)(
void *) =
nullptr;
2281 int (*fMPOSetMaxExtent)(
void *,
long int) =
nullptr;
2282 long int (*fMPOGetMaxExtent)(
void *) =
nullptr;
2283 int (*fMPOGetBondDimensions)(
void *,
long long int *) =
nullptr;
2284 int (*fMPOSetCallbackContext)(
void *,
void *) =
nullptr;
2285 int (*fMPOSetMeetingPositionCallback)(
void *, int64_t (*)(
void *,
const int64_t *)) =
nullptr;
2286 int (*fMPOSetBondDimensionsCallback)(
void *, void (*)(
void *,
const int64_t *)) =
nullptr;
2287 int (*fMPOReCanonicalize)(
void *, int) =
nullptr;
2288 int (*fMPOTrim)(
void *, double,
long int, int) =
nullptr;
2289 int (*fMPOSaveState)(
void *) =
nullptr;
2290 int (*fMPORestoreState)(
void *) =
nullptr;
2291 int (*fMPOCleanSavedState)(
void *) =
nullptr;
2292 void *(*fMPOClone)(
void *) =
nullptr;
2293 int (*fMPOSetSeed)(
void *,
unsigned long long) =
nullptr;
2294 int (*fMPOMeasureQubitCollapse)(
void *, int) =
nullptr;
2295 int (*fMPOMeasureQubitNoCollapse)(
void *, int) =
nullptr;
2296 int (*fMPOMeasureQubitsCollapse)(
void *,
int *,
int *, int) =
nullptr;
2297 int (*fMPOMeasureQubitsNoCollapse)(
void *,
int *,
int *, int) =
nullptr;
2298 unsigned long long (*fMPOMeasureAllQubitsCollapse)(
void *) =
nullptr;
2299 unsigned long long (*fMPOMeasureAllQubitsNoCollapse)(
void *) =
nullptr;
2300 int (*fMPOSample)(
void *,
unsigned int,
long int *,
unsigned int,
2302 int (*fMPOSampleAll)(
void *,
unsigned int,
long int *) =
nullptr;
2303 int (*fMPOGetElement)(
void *,
long long,
long long,
double *,
2304 double *) =
nullptr;
2305 double (*fMPOBasisStateProbability)(
void *,
long long) =
nullptr;
2306 int (*fMPOAllProbabilities)(
void *,
double *) =
nullptr;
2307 double (*fMPOExpectationValue)(
void *,
const char *, int) =
nullptr;
2308 double (*fMPOQubitProbability0)(
void *,
unsigned int) =
nullptr;
2309 int (*fMPOPartialTrace)(
void *,
const int *, int,
double *) =
nullptr;
2310 int (*fMPOHilbertSchmidtOverlap)(
void *,
void *,
double *,
double *) =
nullptr;
2311 int (*fMPOFidelityWithStatevector)(
void *,
const double *,
double *) =
nullptr;
2312 double (*fMPOTrace)(
void *) =
nullptr;
2313 double (*fMPOPurity)(
void *) =
nullptr;
2314 double (*fMPOHermiticityResidual)(
void *) =
nullptr;
2315 int (*fMPOIsHermitian)(
void *, double) =
nullptr;
2316 double (*fMPOTraceOfSquare)(
void *) =
nullptr;
2317 int (*fMPORestoreTrace)(
void *) =
nullptr;
2318 int (*fMPOHermitize)(
void *) =
nullptr;
2319 int (*fMPOSetKrausCompletenessCheck)(
void *, int) =
nullptr;
2320 int (*fMPOGetKrausCompletenessCheck)(
void *) =
nullptr;
2321 int (*fMPOApplyKraus)(
void *, int,
const int *, int,
2322 const double *) =
nullptr;
2323 int (*fMPOApplyReset)(
void *, int) =
nullptr;
2324#define DECL_MPO1(name) int (*f##name)(void *, int) = nullptr
2325#define DECL_MPO2(name) int (*f##name)(void *, int, int) = nullptr
2326#define DECL_MPOR1(name) int (*f##name)(void *, int, double) = nullptr
2327#define DECL_MPOR2(name) int (*f##name)(void *, int, int, double) = nullptr
2328 DECL_MPOR1(MPOApplyBitFlipNoise); DECL_MPOR1(MPOApplyPhaseFlipNoise);
2329 DECL_MPOR1(MPOApplyDepolarizingNoise); DECL_MPOR1(MPOApplyAmplitudeDamping);
2330 DECL_MPOR1(MPOApplyPhaseDamping); DECL_MPO1(MPOApplyNonSelectiveMeasurement);
2331 DECL_MPO1(MPOApplyX); DECL_MPO1(MPOApplyY); DECL_MPO1(MPOApplyZ);
2332 DECL_MPO1(MPOApplyH); DECL_MPO1(MPOApplyS); DECL_MPO1(MPOApplySDG);
2333 DECL_MPO1(MPOApplyT); DECL_MPO1(MPOApplyTDG); DECL_MPO1(MPOApplySX);
2334 DECL_MPO1(MPOApplySXDG); DECL_MPO1(MPOApplyK);
2335 DECL_MPOR1(MPOApplyP); DECL_MPOR1(MPOApplyRx); DECL_MPOR1(MPOApplyRy);
2336 DECL_MPOR1(MPOApplyRz);
2337 int (*fMPOApplyU)(
void *, int, double, double, double, double) =
nullptr;
2338 int (*fMPOApplyOneQubitMatrix)(
void *, int,
const double *) =
nullptr;
2339 int (*fMPOApplyTwoQubitMatrix)(
void *, int, int,
const double *) =
nullptr;
2340 DECL_MPO2(MPOApplyCX); DECL_MPO2(MPOApplyCY); DECL_MPO2(MPOApplyCZ);
2341 DECL_MPO2(MPOApplyCH); DECL_MPO2(MPOApplyCSX); DECL_MPO2(MPOApplyCSXDG);
2342 DECL_MPOR2(MPOApplyCP); DECL_MPOR2(MPOApplyCRx); DECL_MPOR2(MPOApplyCRy);
2343 DECL_MPOR2(MPOApplyCRz);
2344 DECL_MPO2(MPOApplySwap);
2345 int (*fMPOApplyCU)(
void *, int, int, double, double, double,
2357 return fCreateMPS(LibraryHandle);
2359 throw std::runtime_error(
"GpuLibrary: Unable to create mps");
2362 void DestroyMPS(
void *obj) {
2366 throw std::runtime_error(
"GpuLibrary: Unable to destroy mps");
2369 bool MPSCreate(
void *obj,
unsigned int nrQubits) {
2371 return fMPSCreate(obj, nrQubits) == 1;
2373 throw std::runtime_error(
2374 "GpuLibrary: Unable to create mps with the "
2375 "specified number of qubits");
2380 bool MPSCreateWithBasisState(
void *obj,
unsigned int nrQubits,
2381 unsigned long long state) {
2383 return fMPSCreateWithBasisState(obj, nrQubits, state) == 1;
2385 throw std::runtime_error(
2386 "GpuLibrary: Unable to create mps with a basis state");
2391 bool MPSCreateWithBasisStateBits(
void *obj,
unsigned int nrQubits,
2392 const unsigned char *stateBits) {
2394 return fMPSCreateWithBasisStateBits(obj, nrQubits, stateBits) == 1;
2396 throw std::runtime_error(
2397 "GpuLibrary: Unable to create mps with a basis state (bits)");
2402 bool MPSReset(
void *obj) {
2404 return fMPSReset(obj) == 1;
2406 throw std::runtime_error(
"GpuLibrary: Unable to reset mps");
2411 bool MPSSetInitialQubitsMap(
void *obj,
2412 const std::vector<long long int> &initialMap) {
2414 return fMPSSetInitialQubitsMap(obj, initialMap.data(),
2415 initialMap.size()) == 1;
2417 throw std::runtime_error(
2418 "GpuLibrary: Unable to set initial qubits map for mps");
2423 bool MPSSetUseOptimalMeetingPosition(
void *obj,
int val) {
2425 return fMPSSetUseOptimalMeetingPosition(obj, val) == 1;
2427 throw std::runtime_error(
2428 "GpuLibrary: Unable to set use optimal meeting position for mps");
2432 bool MPSGetUseOptimalMeetingPosition(
void *obj)
const {
2434 return fMPSGetUseOptimalMeetingPosition(obj) == 1;
2436 throw std::runtime_error(
2437 "GpuLibrary: Unable to get use optimal meeting position for mps");
2441 bool MPSIsValid(
void *obj)
const {
2443 return fMPSIsValid(obj) == 1;
2445 throw std::runtime_error(
"GpuLibrary: Unable to check if mps is valid");
2450 bool MPSIsCreated(
void *obj)
const {
2452 return fMPSIsCreated(obj) == 1;
2454 throw std::runtime_error(
"GpuLibrary: Unable to check if mps is created");
2459 bool MPSSetDataType(
void *obj,
int useDoublePrecision) {
2461 return fMPSSetDataType(obj, useDoublePrecision) == 1;
2463 throw std::runtime_error(
"GpuLibrary: Unable to set precision for mps");
2468 bool MPSIsDoublePrecision(
void *obj)
const {
2470 return fMPSIsDoublePrecision(obj) == 1;
2472 throw std::runtime_error(
"GpuLibrary: Unable to get precision for mps");
2477 bool MPSSetCutoff(
void *obj,
double val) {
2479 return fMPSSetCutoff(obj, val) == 1;
2481 throw std::runtime_error(
"GpuLibrary: Unable to set cutoff for mps");
2486 double MPSGetCutoff(
void *obj)
const {
2488 return fMPSGetCutoff(obj);
2490 throw std::runtime_error(
"GpuLibrary: Unable to get cutoff for mps");
2493 bool MPSSetTruncationMode(
void *obj,
int mode) {
2495 return fMPSSetTruncationMode(obj, mode) == 1;
2497 throw std::runtime_error(
2498 "GpuLibrary: Unable to set truncation mode for mps");
2503 int MPSGetTruncationMode(
void *obj)
const {
2505 return fMPSGetTruncationMode(obj);
2507 throw std::runtime_error(
2508 "GpuLibrary: Unable to get truncation mode for mps");
2511 bool MPSSetGesvdJ(
void *obj,
int val) {
2512 if (LibraryHandle && obj && fMPSSetGesvdJ)
2513 return fMPSSetGesvdJ(obj, val) == 1;
2515 throw std::runtime_error(
"GpuLibrary: Unable to set GesvdJ for mps");
2520 bool MPSGetGesvdJ(
void *obj)
const {
2521 if (LibraryHandle && obj && fMPSGetGesvdJ)
2522 return fMPSGetGesvdJ(obj) == 1;
2524 throw std::runtime_error(
"GpuLibrary: Unable to get GesvdJ for mps");
2529 bool MPSSetGesvdP(
void *obj,
int val) {
2530 return LibraryHandle && obj && fMPSSetGesvdP &&
2531 fMPSSetGesvdP(obj, val) == 1;
2534 bool MPSGetGesvdP(
void *obj)
const {
2535 if (!LibraryHandle || !obj || !fMPSGetGesvdP)
2536 throw std::runtime_error(
"GpuLibrary: MPSGetGesvdP is unavailable");
2537 return fMPSGetGesvdP(obj) == 1;
2540 bool MPSSetGesvdR(
void *obj,
int val) {
2541 return LibraryHandle && obj && fMPSSetGesvdR &&
2542 fMPSSetGesvdR(obj, val) == 1;
2545 bool MPSGetGesvdR(
void *obj)
const {
2546 if (!LibraryHandle || !obj || !fMPSGetGesvdR)
2547 throw std::runtime_error(
"GpuLibrary: MPSGetGesvdR is unavailable");
2548 return fMPSGetGesvdR(obj) == 1;
2552 int MPSGetLastSvdAlgo(
void *obj)
const {
2553 if (!LibraryHandle || !obj || !fMPSGetLastSvdAlgo)
2554 throw std::runtime_error(
"GpuLibrary: MPSGetLastSvdAlgo is unavailable");
2555 return fMPSGetLastSvdAlgo(obj);
2558 bool MPSSetMaxExtent(
void *obj,
long int val) {
2560 return fMPSSetMaxExtent(obj, val) == 1;
2562 throw std::runtime_error(
"GpuLibrary: Unable to set max extent for mps");
2567 long int MPSGetMaxExtent(
void *obj) {
2569 return fMPSGetMaxExtent(obj);
2571 throw std::runtime_error(
"GpuLibrary: Unable to get max extent for mps");
2576 int MPSGetNrQubits(
void *obj) {
2578 return fMPSGetNrQubits(obj);
2580 throw std::runtime_error(
"GpuLibrary: Unable to get nr qubits for mps");
2585 bool MPSGetBondDimensions(
void *obj,
long long int *bondDims) {
2587 return fMPSGetBondDimensions(obj, bondDims) == 1;
2589 throw std::runtime_error(
2590 "GpuLibrary: Unable to get bond dimensions for mps");
2595 bool MPSSetCallbackContext(
void *obj,
void *context) {
2597 return fMPSSetCallbackContext(obj, context) == 1;
2599 throw std::runtime_error(
2600 "GpuLibrary: Unable to set callback context for mps");
2604 bool MPSSetMeetingPositionCallback(
void *obj, int64_t(*callback)(
void*,
const int64_t*)) {
2606 return fMPSSetMeetingPositionCallback(obj, callback) == 1;
2608 throw std::runtime_error(
2609 "GpuLibrary: Unable to set meeting position callback for mps");
2613 bool MPSSetBondDimensionsCallback(
void* obj,
void (*callback)(
void*,
const int64_t*)) {
2615 return fMPSSetBondDimensionsCallback(obj, callback) == 1;
2617 throw std::runtime_error(
2618 "GpuLibrary: Unable to set bond dimensions callback for mps");
2622 bool MPSAmplitude(
void *obj,
long int numFixedValues,
long int *fixedValues,
2623 double *real,
double *imaginary) {
2625 return fMPSAmplitude(obj, numFixedValues, fixedValues, real, imaginary) ==
2628 throw std::runtime_error(
"GpuLibrary: Unable to get mps amplitude");
2633 double MPSProbability0(
void *obj,
unsigned int qubit) {
2635 return fMPSProbability0(obj, qubit);
2637 throw std::runtime_error(
2638 "GpuLibrary: Unable to get probability for 0 for mps");
2643 bool MPSMeasure(
void *obj,
unsigned int qubit) {
2645 return fMPSMeasure(obj, qubit) == 1;
2647 throw std::runtime_error(
"GpuLibrary: Unable to measure qubit on mps");
2652 bool MPSMeasureQubits(
void *obj,
long int numQubits,
unsigned int *qubits,
2655 return fMPSMeasureQubits(obj, numQubits, qubits, result) == 1;
2657 throw std::runtime_error(
"GpuLibrary: Unable to measure qubits on mps");
2662 std::unordered_map<std::vector<bool>, int64_t> *MPSGetMapForSample() {
2664 return (std::unordered_map<std::vector<bool>, int64_t> *)
2665 fMPSGetMapForSample();
2667 throw std::runtime_error(
2668 "GpuLibrary: Unable to get map for sample for mps");
2673 bool MPSFreeMapForSample(
2674 std::unordered_map<std::vector<bool>, int64_t> *map) {
2676 return fMPSFreeMapForSample((
void *)map) == 1;
2678 throw std::runtime_error(
2679 "GpuLibrary: Unable to free map for sample for mps");
2684 bool MPSSample(
void *obj,
long int numShots,
long int numQubits,
2685 unsigned int *qubits,
void *resultMap) {
2687 return fMPSSample(obj, numShots, numQubits, qubits, resultMap) == 1;
2689 throw std::runtime_error(
"GpuLibrary: Unable to sample mps");
2694 bool MPSSampleRaw(
void *obj,
unsigned int nSamples,
long int *samples,
2695 unsigned int nBits,
const unsigned int *bitOrdering) {
2697 return fMPSSampleRaw(obj, nSamples, samples, nBits, bitOrdering) == 1;
2699 throw std::runtime_error(
"GpuLibrary: Unable to raw-sample mps");
2704 bool MPSSampleAll(
void *obj,
unsigned int nSamples,
long int *samples) {
2706 return fMPSSampleAll(obj, nSamples, samples) == 1;
2708 throw std::runtime_error(
"GpuLibrary: Unable to sample all for mps");
2713 bool MPSSaveState(
void *obj) {
2715 return fMPSSaveState(obj) == 1;
2717 throw std::runtime_error(
"GpuLibrary: Unable to save mps state");
2722 bool MPSRestoreState(
void *obj) {
2724 return fMPSRestoreState(obj) == 1;
2726 throw std::runtime_error(
"GpuLibrary: Unable to restore mps state");
2731 bool MPSCleanSavedState(
void *obj) {
2733 return fMPSCleanSavedState(obj) == 1;
2735 throw std::runtime_error(
"GpuLibrary: Unable to clean mps saved state");
2740 void *MPSClone(
void *obj) {
2742 return fMPSClone(obj);
2744 throw std::runtime_error(
"GpuLibrary: Unable to clone mps");
2749 bool MPSSetSeed(
void *obj,
unsigned long long seed)
const {
2750 return obj && fMPSSetSeed && fMPSSetSeed(obj, seed) == 1;
2753 double MPSExpectationValue(
void *obj,
const char *pauliString,
2756 return fMPSExpectationValue(obj, pauliString, len);
2758 throw std::runtime_error(
2759 "GpuLibrary: Unable to get mps expectation value");
2764 std::complex<double> MPSProjectOnZero(
void* obj)
2766 if (LibraryHandle) {
2768 if (fMPSProjectOnZero(obj, &real, &imag) == 1)
2769 return std::complex<double>(real, imag);
2771 throw std::runtime_error(
2772 "GpuLibrary: Unable to project on zero for mps");
2774 throw std::runtime_error(
2775 "GpuLibrary: Unable to project on zero for mps, library handle is null");
2777 return std::complex<double>(0, 0);
2780 bool MPSApplyX(
void *obj,
unsigned int siteA) {
2782 return fMPSApplyX(obj, siteA) == 1;
2784 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate on mps");
2789 bool MPSApplyY(
void *obj,
unsigned int siteA) {
2791 return fMPSApplyY(obj, siteA) == 1;
2793 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate on mps");
2798 bool MPSApplyZ(
void *obj,
unsigned int siteA) {
2800 return fMPSApplyZ(obj, siteA) == 1;
2802 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate on mps");
2807 bool MPSApplyH(
void *obj,
unsigned int siteA) {
2809 return fMPSApplyH(obj, siteA) == 1;
2811 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate on mps");
2816 bool MPSApplyS(
void *obj,
unsigned int siteA) {
2818 return fMPSApplyS(obj, siteA) == 1;
2820 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate on mps");
2825 bool MPSApplySDG(
void *obj,
unsigned int siteA) {
2827 return fMPSApplySDG(obj, siteA) == 1;
2829 throw std::runtime_error(
"GpuLibrary: Unable to apply sdg gate on mps");
2834 bool MPSApplyT(
void *obj,
unsigned int siteA) {
2836 return fMPSApplyT(obj, siteA) == 1;
2838 throw std::runtime_error(
"GpuLibrary: Unable to apply t gate on mps");
2843 bool MPSApplyTDG(
void *obj,
unsigned int siteA) {
2845 return fMPSApplyTDG(obj, siteA) == 1;
2847 throw std::runtime_error(
"GpuLibrary: Unable to appl tdg gate on mps");
2852 bool MPSApplySX(
void *obj,
unsigned int siteA) {
2854 return fMPSApplySX(obj, siteA) == 1;
2856 throw std::runtime_error(
"GpuLibrary: Unable to apply sx gate on mps");
2861 bool MPSApplySXDG(
void *obj,
unsigned int siteA) {
2863 return fMPSApplySXDG(obj, siteA) == 1;
2865 throw std::runtime_error(
"GpuLibrary: Unable to apply sxdg gate on mps");
2870 bool MPSApplyK(
void *obj,
unsigned int siteA) {
2872 return fMPSApplyK(obj, siteA) == 1;
2874 throw std::runtime_error(
"GpuLibrary: Unable to apply k gate on mps");
2879 bool MPSApplyP(
void *obj,
unsigned int siteA,
double theta) {
2881 return fMPSApplyP(obj, siteA, theta) == 1;
2883 throw std::runtime_error(
"GpuLibrary: Unable to apply p gate on mps");
2887 bool MPSApplyRx(
void *obj,
unsigned int siteA,
double theta) {
2889 return fMPSApplyRx(obj, siteA, theta) == 1;
2891 throw std::runtime_error(
"GpuLibrary: Unable to apply rx gate on mps");
2896 bool MPSApplyRy(
void *obj,
unsigned int siteA,
double theta) {
2898 return fMPSApplyRy(obj, siteA, theta) == 1;
2900 throw std::runtime_error(
"GpuLibrary: Unable to apply ry gate on mps");
2905 bool MPSApplyRz(
void *obj,
unsigned int siteA,
double theta) {
2907 return fMPSApplyRz(obj, siteA, theta) == 1;
2909 throw std::runtime_error(
"GpuLibrary: Unable to apply rz gate on mps");
2914 bool MPSApplyU(
void *obj,
unsigned int siteA,
double theta,
double phi,
2915 double lambda,
double gamma) {
2917 return fMPSApplyU(obj, siteA, theta, phi, lambda, gamma) == 1;
2919 throw std::runtime_error(
"GpuLibrary: Unable to apply u gate on mps");
2924 bool MPSApplyOneQubitMatrix(
void *obj,
unsigned int qubit,
2925 const double *matrixInterleaved) {
2927 return fMPSApplyOneQubitMatrix(obj, qubit, matrixInterleaved) == 1;
2929 throw std::runtime_error(
2930 "GpuLibrary: Unable to apply one-qubit matrix on mps");
2935 bool MPSApplyTwoQubitMatrix(
void *obj,
unsigned int qubit1,
2936 unsigned int qubit2,
2937 const double *matrixInterleaved) {
2939 return fMPSApplyTwoQubitMatrix(obj, qubit1, qubit2,
2940 matrixInterleaved) == 1;
2942 throw std::runtime_error(
2943 "GpuLibrary: Unable to apply two-qubit matrix on mps");
2948 bool MPSApplySwap(
void *obj,
unsigned int controlQubit,
2949 unsigned int targetQubit) {
2951 return fMPSApplySwap(obj, controlQubit, targetQubit) == 1;
2953 throw std::runtime_error(
"GpuLibrary: Unable to apply swap gate on mps");
2958 bool MPSApplyCX(
void *obj,
unsigned int controlQubit,
2959 unsigned int targetQubit) {
2961 return fMPSApplyCX(obj, controlQubit, targetQubit) == 1;
2963 throw std::runtime_error(
"GpuLibrary: Unable to apply cx gate on mps");
2968 bool MPSApplyCY(
void *obj,
unsigned int controlQubit,
2969 unsigned int targetQubit) {
2971 return fMPSApplyCY(obj, controlQubit, targetQubit) == 1;
2973 throw std::runtime_error(
"GpuLibrary: Unable to apply cy gate on mps");
2978 bool MPSApplyCZ(
void *obj,
unsigned int controlQubit,
2979 unsigned int targetQubit) {
2981 return fMPSApplyCZ(obj, controlQubit, targetQubit) == 1;
2983 throw std::runtime_error(
"GpuLibrary: Unable to apply cz gate on mps");
2988 bool MPSApplyCH(
void *obj,
unsigned int controlQubit,
2989 unsigned int targetQubit) {
2991 return fMPSApplyCH(obj, controlQubit, targetQubit) == 1;
2993 throw std::runtime_error(
"GpuLibrary: Unable to apply ch gate on mps");
2998 bool MPSApplyCSX(
void *obj,
unsigned int controlQubit,
2999 unsigned int targetQubit) {
3001 return fMPSApplyCSX(obj, controlQubit, targetQubit) == 1;
3003 throw std::runtime_error(
"GpuLibrary: Unable to apply csx gate on mps");
3006 bool MPSApplyCSXDG(
void *obj,
unsigned int controlQubit,
3007 unsigned int targetQubit) {
3009 return fMPSApplyCSXDG(obj, controlQubit, targetQubit) == 1;
3011 throw std::runtime_error(
"GpuLibrary: Unable to apply csxdg gate on mps");
3016 bool MPSApplyCP(
void *obj,
unsigned int controlQubit,
3017 unsigned int targetQubit,
double theta) {
3019 return fMPSApplyCP(obj, controlQubit, targetQubit, theta) == 1;
3021 throw std::runtime_error(
"GpuLibrary: Unable to apply cp gate on mps");
3026 bool MPSApplyCRx(
void *obj,
unsigned int controlQubit,
3027 unsigned int targetQubit,
double theta) {
3029 return fMPSApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
3031 throw std::runtime_error(
"GpuLibrary: Unable to apply crx gate on mps");
3036 bool MPSApplyCRy(
void *obj,
unsigned int controlQubit,
3037 unsigned int targetQubit,
double theta) {
3039 return fMPSApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
3041 throw std::runtime_error(
"GpuLibrary: Unable to apply cry gate on mps");
3046 bool MPSApplyCRz(
void *obj,
unsigned int controlQubit,
3047 unsigned int targetQubit,
double theta) {
3049 return fMPSApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
3051 throw std::runtime_error(
"GpuLibrary: Unable to apply crz gate on mps");
3056 bool MPSApplyCU(
void *obj,
unsigned int controlQubit,
3057 unsigned int targetQubit,
double theta,
double phi,
3058 double lambda,
double gamma) {
3060 return fMPSApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda,
3063 throw std::runtime_error(
"GpuLibrary: Unable to apply cu gate on mps");
3070 void *CreateTensorNet() {
3072 return fCreateTensorNet(LibraryHandle);
3074 throw std::runtime_error(
"GpuLibrary: Unable to create tensor network");
3077 void DestroyTensorNet(
void *obj) {
3079 fDestroyTensorNet(obj);
3081 throw std::runtime_error(
"GpuLibrary: Unable to destroy tensor network");
3084 bool TNCreate(
void *obj,
unsigned int nrQubits) {
3086 return fTNCreate(obj, nrQubits) == 1;
3088 throw std::runtime_error(
3089 "GpuLibrary: Unable to create tensor network with the "
3090 "specified number of qubits");
3095 bool TNReset(
void *obj) {
3097 return fTNReset(obj) == 1;
3099 throw std::runtime_error(
"GpuLibrary: Unable to reset tensor network");
3104 bool TNIsValid(
void *obj)
const {
3106 return fTNIsValid(obj) == 1;
3108 throw std::runtime_error(
3109 "GpuLibrary: Unable to check if tensor network is valid");
3114 bool TNIsCreated(
void *obj)
const {
3116 return fTNIsCreated(obj) == 1;
3118 throw std::runtime_error(
3119 "GpuLibrary: Unable to check if tensor network is created");
3124 bool TNSetDataType(
void *obj,
int useDoublePrecision) {
3126 return fTNSetDataType(obj, useDoublePrecision) == 1;
3128 throw std::runtime_error(
3129 "GpuLibrary: Unable to set precision for tensor network");
3134 bool TNIsDoublePrecision(
void *obj)
const {
3136 return fTNIsDoublePrecision(obj) == 1;
3138 throw std::runtime_error(
3139 "GpuLibrary: Unable to get precision for tensor network");
3144 bool TNSetCutoff(
void *obj,
double val) {
3146 return fTNSetCutoff(obj, val) == 1;
3148 throw std::runtime_error(
3149 "GpuLibrary: Unable to set cutoff for tensor network");
3154 double TNGetCutoff(
void *obj)
const {
3156 return fTNGetCutoff(obj);
3158 throw std::runtime_error(
3159 "GpuLibrary: Unable to get cutoff for tensor network");
3162 bool TNSetTruncationMode(
void *obj,
int mode) {
3164 return fTNSetTruncationMode(obj, mode) == 1;
3166 throw std::runtime_error(
3167 "GpuLibrary: Unable to set truncation mode for tensor network");
3172 int TNGetTruncationMode(
void *obj)
const {
3174 return fTNGetTruncationMode(obj);
3176 throw std::runtime_error(
3177 "GpuLibrary: Unable to get truncation mode for tensor network");
3180 bool TNSetGesvdJ(
void *obj,
int val) {
3181 if (LibraryHandle && obj && fTNSetGesvdJ)
3182 return fTNSetGesvdJ(obj, val) == 1;
3184 throw std::runtime_error(
3185 "GpuLibrary: Unable to set GesvdJ for tensor network");
3190 bool TNGetGesvdJ(
void *obj)
const {
3191 if (LibraryHandle && obj && fTNGetGesvdJ)
3192 return fTNGetGesvdJ(obj) == 1;
3194 throw std::runtime_error(
3195 "GpuLibrary: Unable to get GesvdJ for tensor network");
3200 bool TNSetGesvdP(
void *obj,
int val) {
3201 return LibraryHandle && obj && fTNSetGesvdP &&
3202 fTNSetGesvdP(obj, val) == 1;
3205 bool TNGetGesvdP(
void *obj)
const {
3206 if (!LibraryHandle || !obj || !fTNGetGesvdP)
3207 throw std::runtime_error(
"GpuLibrary: TNGetGesvdP is unavailable");
3208 return fTNGetGesvdP(obj) == 1;
3211 bool TNSetGesvdR(
void *obj,
int val) {
3212 return LibraryHandle && obj && fTNSetGesvdR &&
3213 fTNSetGesvdR(obj, val) == 1;
3216 bool TNGetGesvdR(
void *obj)
const {
3217 if (!LibraryHandle || !obj || !fTNGetGesvdR)
3218 throw std::runtime_error(
"GpuLibrary: TNGetGesvdR is unavailable");
3219 return fTNGetGesvdR(obj) == 1;
3222 bool TNSetMaxExtent(
void *obj,
long int val) {
3224 return fTNSetMaxExtent(obj, val) == 1;
3226 throw std::runtime_error(
3227 "GpuLibrary: Unable to set max extent for tensor network");
3232 long int TNGetMaxExtent(
void *obj) {
3234 return fTNGetMaxExtent(obj);
3236 throw std::runtime_error(
3237 "GpuLibrary: Unable to get max extent for tensor network");
3242 int TNGetNrQubits(
void *obj) {
3244 return fTNGetNrQubits(obj);
3246 throw std::runtime_error(
3247 "GpuLibrary: Unable to get nr qubits for tensor network");
3252 bool TNAmplitude(
void *obj,
long int numFixedValues,
long int *fixedValues,
3253 double *real,
double *imaginary) {
3255 return fTNAmplitude(obj, numFixedValues, fixedValues, real, imaginary) ==
3258 throw std::runtime_error(
3259 "GpuLibrary: Unable to get tensor network amplitude");
3264 double TNProbability0(
void *obj,
unsigned int qubit) {
3266 return fTNProbability0(obj, qubit);
3268 throw std::runtime_error(
3269 "GpuLibrary: Unable to get probability for 0 for tensor network");
3274 bool TNMeasure(
void *obj,
unsigned int qubit) {
3276 return fTNMeasure(obj, qubit) == 1;
3278 throw std::runtime_error(
3279 "GpuLibrary: Unable to measure qubit on tensor network");
3284 bool TNMeasureQubits(
void *obj,
long int numQubits,
unsigned int *qubits,
3287 return fTNMeasureQubits(obj, numQubits, qubits, result) == 1;
3289 throw std::runtime_error(
3290 "GpuLibrary: Unable to measure qubits on tensor network");
3295 std::unordered_map<std::vector<bool>, int64_t> *TNGetMapForSample() {
3298 std::unordered_map<std::vector<bool>, int64_t> *)fTNGetMapForSample();
3300 throw std::runtime_error(
3301 "GpuLibrary: Unable to get map for sample for tensor network");
3306 bool TNFreeMapForSample(std::unordered_map<std::vector<bool>, int64_t> *map) {
3308 return fTNFreeMapForSample((
void *)map) == 1;
3310 throw std::runtime_error(
3311 "GpuLibrary: Unable to free map for sample for tensor network");
3316 bool TNSample(
void *obj,
long int numShots,
long int numQubits,
3317 unsigned int *qubits,
void *resultMap) {
3319 return fTNSample(obj, numShots, numQubits, qubits, resultMap) == 1;
3321 throw std::runtime_error(
"GpuLibrary: Unable to sample tensor network");
3326 bool TNSaveState(
void *obj) {
3328 return fTNSaveState(obj) == 1;
3330 throw std::runtime_error(
3331 "GpuLibrary: Unable to save tensor network state");
3336 bool TNRestoreState(
void *obj) {
3338 return fTNRestoreState(obj) == 1;
3340 throw std::runtime_error(
3341 "GpuLibrary: Unable to restore tensor network state");
3346 bool TNCleanSavedState(
void *obj) {
3348 return fTNCleanSavedState(obj) == 1;
3350 throw std::runtime_error(
3351 "GpuLibrary: Unable to clean tensor network saved state");
3356 void *TNClone(
void *obj) {
3358 return fTNClone(obj);
3360 throw std::runtime_error(
"GpuLibrary: Unable to clone tensor network");
3365 bool TNSetSeed(
void *obj,
unsigned long long seed)
const {
3366 return obj && fTNSetSeed && fTNSetSeed(obj, seed) == 1;
3369 double TNExpectationValue(
void *obj,
const char *pauliString,
int len)
const {
3371 return fTNExpectationValue(obj, pauliString, len);
3373 throw std::runtime_error(
3374 "GpuLibrary: Unable to get tensor network expectation value");
3379 bool TNApplyX(
void *obj,
unsigned int siteA) {
3381 return fTNApplyX(obj, siteA) == 1;
3383 throw std::runtime_error(
3384 "GpuLibrary: Unable to apply X gate on tensor network");
3389 bool TNApplyY(
void *obj,
unsigned int siteA) {
3391 return fTNApplyY(obj, siteA) == 1;
3393 throw std::runtime_error(
3394 "GpuLibrary: Unable to apply Y gate on tensor network");
3399 bool TNApplyZ(
void *obj,
unsigned int siteA) {
3401 return fTNApplyZ(obj, siteA) == 1;
3403 throw std::runtime_error(
3404 "GpuLibrary: Unable to apply Z gate on tensor network");
3409 bool TNApplyH(
void *obj,
unsigned int siteA) {
3411 return fTNApplyH(obj, siteA) == 1;
3413 throw std::runtime_error(
3414 "GpuLibrary: Unable to apply H gate on tensor network");
3419 bool TNApplyS(
void *obj,
unsigned int siteA) {
3421 return fTNApplyS(obj, siteA) == 1;
3423 throw std::runtime_error(
3424 "GpuLibrary: Unable to apply S gate on tensor network");
3429 bool TNApplySDG(
void *obj,
unsigned int siteA) {
3431 return fTNApplySDG(obj, siteA) == 1;
3433 throw std::runtime_error(
3434 "GpuLibrary: Unable to apply sdg gate on tensor network");
3439 bool TNApplyT(
void *obj,
unsigned int siteA) {
3441 return fTNApplyT(obj, siteA) == 1;
3443 throw std::runtime_error(
3444 "GpuLibrary: Unable to apply t gate on tensor network");
3449 bool TNApplyTDG(
void *obj,
unsigned int siteA) {
3451 return fTNApplyTDG(obj, siteA) == 1;
3453 throw std::runtime_error(
3454 "GpuLibrary: Unable to apply tdg gate on tensor network");
3459 bool TNApplySX(
void *obj,
unsigned int siteA) {
3461 return fTNApplySX(obj, siteA) == 1;
3463 throw std::runtime_error(
3464 "GpuLibrary: Unable to apply sx gate on tensor network");
3469 bool TNApplySXDG(
void *obj,
unsigned int siteA) {
3471 return fTNApplySXDG(obj, siteA) == 1;
3473 throw std::runtime_error(
3474 "GpuLibrary: Unable to apply sxdg gate on tensor network");
3479 bool TNApplyK(
void *obj,
unsigned int siteA) {
3481 return fTNApplyK(obj, siteA) == 1;
3483 throw std::runtime_error(
3484 "GpuLibrary: Unable to apply k gate on tensor network");
3489 bool TNApplyP(
void *obj,
unsigned int siteA,
double theta) {
3491 return fTNApplyP(obj, siteA, theta) == 1;
3493 throw std::runtime_error(
3494 "GpuLibrary: Unable to apply p gate on tensor network");
3498 bool TNApplyRx(
void *obj,
unsigned int siteA,
double theta) {
3500 return fTNApplyRx(obj, siteA, theta) == 1;
3502 throw std::runtime_error(
3503 "GpuLibrary: Unable to apply rx gate on tensor network");
3508 bool TNApplyRy(
void *obj,
unsigned int siteA,
double theta) {
3510 return fTNApplyRy(obj, siteA, theta) == 1;
3512 throw std::runtime_error(
3513 "GpuLibrary: Unable to apply ry gate on tensor network");
3518 bool TNApplyRz(
void *obj,
unsigned int siteA,
double theta) {
3520 return fTNApplyRz(obj, siteA, theta) == 1;
3522 throw std::runtime_error(
3523 "GpuLibrary: Unable to apply rz gate on tensor network");
3528 bool TNApplyU(
void *obj,
unsigned int siteA,
double theta,
double phi,
3529 double lambda,
double gamma) {
3531 return fTNApplyU(obj, siteA, theta, phi, lambda, gamma) == 1;
3533 throw std::runtime_error(
3534 "GpuLibrary: Unable to apply u gate on tensor network");
3539 bool TNApplySwap(
void *obj,
unsigned int controlQubit,
3540 unsigned int targetQubit) {
3542 return fTNApplySwap(obj, controlQubit, targetQubit) == 1;
3544 throw std::runtime_error(
3545 "GpuLibrary: Unable to apply swap gate on tensor network");
3550 bool TNApplyCX(
void *obj,
unsigned int controlQubit,
3551 unsigned int targetQubit) {
3553 return fTNApplyCX(obj, controlQubit, targetQubit) == 1;
3555 throw std::runtime_error(
3556 "GpuLibrary: Unable to apply cx gate on tensor network");
3561 bool TNApplyCY(
void *obj,
unsigned int controlQubit,
3562 unsigned int targetQubit) {
3564 return fTNApplyCY(obj, controlQubit, targetQubit) == 1;
3566 throw std::runtime_error(
3567 "GpuLibrary: Unable to apply cy gate on tensor network");
3572 bool TNApplyCZ(
void *obj,
unsigned int controlQubit,
3573 unsigned int targetQubit) {
3575 return fTNApplyCZ(obj, controlQubit, targetQubit) == 1;
3577 throw std::runtime_error(
3578 "GpuLibrary: Unable to apply cz gate on tensor network");
3583 bool TNApplyCH(
void *obj,
unsigned int controlQubit,
3584 unsigned int targetQubit) {
3586 return fTNApplyCH(obj, controlQubit, targetQubit) == 1;
3588 throw std::runtime_error(
3589 "GpuLibrary: Unable to apply ch gate on tensor network");
3594 bool TNApplyCSX(
void *obj,
unsigned int controlQubit,
3595 unsigned int targetQubit) {
3597 return fTNApplyCSX(obj, controlQubit, targetQubit) == 1;
3599 throw std::runtime_error(
3600 "GpuLibrary: Unable to apply csx gate on tensor network");
3603 bool TNApplyCSXDG(
void *obj,
unsigned int controlQubit,
3604 unsigned int targetQubit) {
3606 return fTNApplyCSXDG(obj, controlQubit, targetQubit) == 1;
3608 throw std::runtime_error(
3609 "GpuLibrary: Unable to apply csxdg gate on tensor network");
3614 bool TNApplyCP(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
3617 return fTNApplyCP(obj, controlQubit, targetQubit, theta) == 1;
3619 throw std::runtime_error(
3620 "GpuLibrary: Unable to apply cp gate on tensor network");
3625 bool TNApplyCRx(
void *obj,
unsigned int controlQubit,
3626 unsigned int targetQubit,
double theta) {
3628 return fTNApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
3630 throw std::runtime_error(
3631 "GpuLibrary: Unable to apply crx gate on tensor network");
3636 bool TNApplyCRy(
void *obj,
unsigned int controlQubit,
3637 unsigned int targetQubit,
double theta) {
3639 return fTNApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
3641 throw std::runtime_error(
3642 "GpuLibrary: Unable to apply cry gate on tensor network");
3647 bool TNApplyCRz(
void *obj,
unsigned int controlQubit,
3648 unsigned int targetQubit,
double theta) {
3650 return fTNApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
3652 throw std::runtime_error(
3653 "GpuLibrary: Unable to apply crz gate on tensor network");
3658 bool TNApplyCU(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
3659 double theta,
double phi,
double lambda,
double gamma) {
3661 return fTNApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda,
3664 throw std::runtime_error(
3665 "GpuLibrary: Unable to apply cu gate on tensor network");
3670 bool TNApplyCCX(
void *obj,
unsigned int controlQubit1,
3671 unsigned int controlQubit2,
unsigned int targetQubit) {
3673 return fTNApplyCCX(obj, controlQubit1, controlQubit2, targetQubit) == 1;
3675 throw std::runtime_error(
3676 "GpuLibrary: Unable to apply ccx gate on tensor network");
3680 bool TNApplyCSwap(
void *obj,
unsigned int controlQubit,
3681 unsigned int targetQubit1,
unsigned int targetQubit2) {
3683 return fTNApplyCSwap(obj, controlQubit, targetQubit1, targetQubit2) == 1;
3685 throw std::runtime_error(
3686 "GpuLibrary: Unable to apply cswap gate on tensor network");
3691 void *CreateStabilizerSimulator(
long long int numQubits,
3692 long long int numShots,
3693 long long int numMeasurements,
3694 long long int numDetectors) {
3696 return fCreateStabilizerSimulator(numQubits, numShots, numMeasurements,
3699 throw std::runtime_error(
3700 "GpuLibrary: Unable to create stabilizer simulator");
3705 void DestroyStabilizerSimulator(
void *obj) {
3708 fDestroyStabilizerSimulator(obj);
3710 throw std::runtime_error(
3711 "GpuLibrary: Unable to destroy stabilizer simulator");
3714 bool ExecuteStabilizerCircuit(
void *obj,
const char *circuitStr,
3715 int randomizeMeasurements,
3716 unsigned long long int seed) {
3717 if (!obj)
return false;
3719 return fExecuteStabilizerCircuit(obj, circuitStr, randomizeMeasurements,
3722 throw std::runtime_error(
3723 "GpuLibrary: Unable to execute stabilizer circuit");
3728 long long GetStabilizerXZTableSize(
void *obj) {
3731 return fGetStabilizerXZTableSize(obj);
3733 throw std::runtime_error(
3734 "GpuLibrary: Unable to get stabilizer XZ table size");
3739 long long GetStabilizerMTableSize(
void *obj) {
3742 return fGetStabilizerMTableSize(obj);
3744 throw std::runtime_error(
3745 "GpuLibrary: Unable to get stabilizer M table size");
3750 long long GetStabilizerTableStrideMajor(
void *obj) {
3753 return fGetStabilizerTableStrideMajor(obj);
3755 throw std::runtime_error(
3756 "GpuLibrary: Unable to get stabilizer table stride major");
3760 long long GetStabilizerNumQubits(
void *obj) {
3763 return fGetStabilizerNumQubits(obj);
3765 throw std::runtime_error(
3766 "GpuLibrary: Unable to get stabilizer number of qubits");
3771 long long GetStabilizerNumShots(
void *obj) {
3774 return fGetStabilizerNumShots(obj);
3776 throw std::runtime_error(
3777 "GpuLibrary: Unable to get stabilizer number of shots");
3782 long long GetStabilizerNumMeasurements(
void *obj) {
3785 return fGetStabilizerNumMeasurements(obj);
3787 throw std::runtime_error(
3788 "GpuLibrary: Unable to get stabilizer number of measurements");
3793 long long GetStabilizerNumDetectors(
void *obj) {
3796 return fGetStabilizerNumDetectors(obj);
3798 throw std::runtime_error(
3799 "GpuLibrary: Unable to get stabilizer number of detectors");
3804 int CopyStabilizerXTable(
void *obj,
unsigned int *xtable) {
3807 return fCopyStabilizerXTable(obj, xtable);
3809 throw std::runtime_error(
"GpuLibrary: Unable to copy stabilizer X table");
3813 int CopyStabilizerZTable(
void *obj,
unsigned int *ztable) {
3816 return fCopyStabilizerZTable(obj, ztable);
3818 throw std::runtime_error(
"GpuLibrary: Unable to copy stabilizer Z table");
3822 int CopyStabilizerMTable(
void *obj,
unsigned int *mtable) {
3825 return fCopyStabilizerMTable(obj, mtable);
3827 throw std::runtime_error(
"GpuLibrary: Unable to copy stabilizer M table");
3831 int InitStabilizerXTable(
void *obj,
const unsigned int *xtable) {
3834 return fInitStabilizerXTable(obj, xtable);
3836 throw std::runtime_error(
3837 "GpuLibrary: Unable to initialize stabilizer X table");
3841 int InitStabilizerZTable(
void *obj,
const unsigned int *ztable) {
3844 return fInitStabilizerZTable(obj, ztable);
3846 throw std::runtime_error(
3847 "GpuLibrary: Unable to initialize stabilizer Z table");
3852 void *CreatePauliPropSimulator(
int nrQubits) {
3854 return fCreatePauliPropSimulator(nrQubits);
3856 throw std::runtime_error(
3857 "GpuLibrary: Unable to create pauli propagation simulator");
3861 void DestroyPauliPropSimulator(
void *obj) {
3864 fDestroyPauliPropSimulator(obj);
3866 throw std::runtime_error(
3867 "GpuLibrary: Unable to destroy pauli propagation simulator");
3870 int PauliPropGetNrQubits(
void *obj) {
3873 return fPauliPropGetNrQubits(obj);
3875 throw std::runtime_error(
3876 "GpuLibrary: Unable to get number of qubits in pauli propagation "
3881 int PauliPropSetWillUseSampling(
void *obj,
int willUseSampling) {
3884 return fPauliPropSetWillUseSampling(obj, willUseSampling) == 1;
3886 throw std::runtime_error(
3887 "GpuLibrary: Unable to set 'will use sampling' in pauli propagation "
3892 int PauliPropGetWillUseSampling(
void *obj) {
3895 return fPauliPropGetWillUseSampling(obj);
3897 throw std::runtime_error(
3898 "GpuLibrary: Unable to get 'will use sampling' in pauli propagation "
3903 double PauliPropGetCoefficientTruncationCutoff(
void *obj) {
3904 if (!obj)
return 0.0;
3906 return fPauliPropGetCoefficientTruncationCutoff(obj);
3908 throw std::runtime_error(
3909 "GpuLibrary: Unable to get coefficient truncation cutoff in pauli "
3910 "propagation simulator");
3914 void PauliPropSetCoefficientTruncationCutoff(
void *obj,
double cutoff) {
3917 fPauliPropSetCoefficientTruncationCutoff(obj, cutoff);
3919 throw std::runtime_error(
3920 "GpuLibrary: Unable to set coefficient truncation cutoff in pauli "
3921 "propagation simulator");
3924 double PauliPropGetWeightTruncationCutoff(
void *obj) {
3925 if (!obj)
return 0.0;
3927 return fPauliPropGetWeightTruncationCutoff(obj);
3929 throw std::runtime_error(
3930 "GpuLibrary: Unable to get weight truncation cutoff in pauli "
3931 "propagation simulator");
3935 void PauliPropSetWeightTruncationCutoff(
void *obj,
double cutoff) {
3938 fPauliPropSetWeightTruncationCutoff(obj, cutoff);
3940 throw std::runtime_error(
3941 "GpuLibrary: Unable to set weight truncation cutoff in pauli "
3942 "propagation simulator");
3945 int PauliPropGetNumGatesBetweenTruncations(
void *obj) {
3948 return fPauliPropGetNumGatesBetweenTruncations(obj);
3950 throw std::runtime_error(
3951 "GpuLibrary: Unable to get number of gates between truncations in "
3952 "pauli propagation simulator");
3956 void PauliPropSetNumGatesBetweenTruncations(
void *obj,
int numGates) {
3959 fPauliPropSetNumGatesBetweenTruncations(obj, numGates);
3961 throw std::runtime_error(
3962 "GpuLibrary: Unable to set number of gates between truncations in "
3964 "propagation simulator");
3967 int PauliPropGetNumGatesBetweenDeduplications(
void *obj) {
3970 return fPauliPropGetNumGatesBetweenDeduplications(obj);
3972 throw std::runtime_error(
3973 "GpuLibrary: Unable to get number of gates between deduplications in "
3974 "pauli propagation simulator");
3978 void PauliPropSetNumGatesBetweenDeduplications(
void *obj,
int numGates) {
3981 fPauliPropSetNumGatesBetweenDeduplications(obj, numGates);
3983 throw std::runtime_error(
3984 "GpuLibrary: Unable to set number of gates between deduplications in "
3986 "propagation simulator");
3989 bool PauliPropClearOperators(
void *obj) {
3990 if (!obj)
return false;
3992 return fPauliPropClearOperators(obj) == 1;
3994 throw std::runtime_error(
3995 "GpuLibrary: Unable to clear operators in pauli propagation "
4000 bool PauliPropAllocateMemory(
void *obj,
double percentage) {
4001 if (!obj)
return false;
4003 return fPauliPropAllocateMemory(obj, percentage) == 1;
4005 throw std::runtime_error(
4006 "GpuLibrary: Unable to allocate memory in pauli propagation "
4011 double PauliPropGetExpectationValue(
void *obj) {
4012 if (!obj)
return 0.0;
4014 return fPauliPropGetExpectationValue(obj);
4016 throw std::runtime_error(
4017 "GpuLibrary: Unable to get expectation value in pauli propagation "
4022 bool PauliPropExecute(
void *obj) {
4023 if (!obj)
return false;
4025 return fPauliPropExecute(obj) == 1;
4027 throw std::runtime_error(
4028 "GpuLibrary: Unable to execute pauli propagation simulator");
4032 bool PauliPropSetSeed(
void *obj,
unsigned long long seed)
const {
4033 return obj && fPauliPropSetSeed && fPauliPropSetSeed(obj, seed) == 1;
4036 bool PauliPropSetInPauliExpansionUnique(
void *obj,
const char *pauliString) {
4037 if (!obj)
return false;
4039 return fPauliPropSetInPauliExpansionUnique(obj, pauliString) == 1;
4041 throw std::runtime_error(
4042 "GpuLibrary: Unable to set unique pauli in pauli propagation "
4047 bool PauliPropSetInPauliExpansionMultiple(
void *obj,
4048 const char **pauliStrings,
4049 const double *coefficients,
4051 if (!obj)
return false;
4053 return fPauliPropSetInPauliExpansionMultiple(obj, pauliStrings,
4054 coefficients, nrPaulis) == 1;
4056 throw std::runtime_error(
4057 "GpuLibrary: Unable to set multiple pauli in pauli propagation "
4062 bool PauliPropApplyX(
void *obj,
int qubit) {
4063 if (!obj)
return false;
4065 return fPauliPropApplyX(obj, qubit) == 1;
4067 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate on mps");
4071 bool PauliPropApplyY(
void *obj,
int qubit) {
4072 if (!obj)
return false;
4074 return fPauliPropApplyY(obj, qubit) == 1;
4076 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate on mps");
4080 bool PauliPropApplyZ(
void *obj,
int qubit) {
4081 if (!obj)
return false;
4083 return fPauliPropApplyZ(obj, qubit) == 1;
4085 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate on mps");
4089 bool PauliPropApplyH(
void *obj,
int qubit) {
4090 if (!obj)
return false;
4092 return fPauliPropApplyH(obj, qubit) == 1;
4094 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate on mps");
4098 bool PauliPropApplyS(
void *obj,
int qubit) {
4099 if (!obj)
return false;
4101 return fPauliPropApplyS(obj, qubit) == 1;
4103 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate on mps");
4107 bool PauliPropApplySQRTX(
void *obj,
int qubit) {
4108 if (!obj)
return false;
4110 return fPauliPropApplySQRTX(obj, qubit) == 1;
4112 throw std::runtime_error(
"GpuLibrary: Unable to apply SQRTX gate on mps");
4116 bool PauliPropApplySQRTY(
void *obj,
int qubit) {
4117 if (!obj)
return false;
4119 return fPauliPropApplySQRTY(obj, qubit) == 1;
4121 throw std::runtime_error(
"GpuLibrary: Unable to apply SQRTY gate on mps");
4125 bool PauliPropApplySQRTZ(
void *obj,
int qubit) {
4126 if (!obj)
return false;
4128 return fPauliPropApplySQRTZ(obj, qubit) == 1;
4130 throw std::runtime_error(
"GpuLibrary: Unable to apply SQRTZ gate on mps");
4134 bool PauliPropApplyCX(
void *obj,
int targetQubit,
int controlQubit) {
4135 if (!obj)
return false;
4137 return fPauliPropApplyCX(obj, targetQubit, controlQubit) == 1;
4139 throw std::runtime_error(
"GpuLibrary: Unable to apply CX gate on mps");
4143 bool PauliPropApplyCY(
void *obj,
int targetQubit,
int controlQubit) {
4144 if (!obj)
return false;
4146 return fPauliPropApplyCY(obj, targetQubit, controlQubit) == 1;
4148 throw std::runtime_error(
"GpuLibrary: Unable to apply CY gate on mps");
4152 bool PauliPropApplyCZ(
void *obj,
int targetQubit,
int controlQubit) {
4153 if (!obj)
return false;
4155 return fPauliPropApplyCZ(obj, targetQubit, controlQubit) == 1;
4157 throw std::runtime_error(
"GpuLibrary: Unable to apply CZ gate on mps");
4161 bool PauliPropApplySWAP(
void *obj,
int qubit1,
int qubit2) {
4162 if (!obj)
return false;
4164 return fPauliPropApplySWAP(obj, qubit1, qubit2) == 1;
4166 throw std::runtime_error(
"GpuLibrary: Unable to apply SWAP gate on mps");
4170 bool PauliPropApplyISWAP(
void *obj,
int qubit1,
int qubit2) {
4171 if (!obj)
return false;
4173 return fPauliPropApplyISWAP(obj, qubit1, qubit2) == 1;
4175 throw std::runtime_error(
"GpuLibrary: Unable to apply ISWAP gate on mps");
4179 bool PauliPropApplyRX(
void *obj,
int qubit,
double angle) {
4180 if (!obj)
return false;
4182 return fPauliPropApplyRX(obj, qubit, angle) == 1;
4184 throw std::runtime_error(
"GpuLibrary: Unable to apply RX gate on mps");
4188 bool PauliPropApplyRY(
void *obj,
int qubit,
double angle) {
4189 if (!obj)
return false;
4191 return fPauliPropApplyRY(obj, qubit, angle) == 1;
4193 throw std::runtime_error(
"GpuLibrary: Unable to apply RY gate on mps");
4197 bool PauliPropApplyRZ(
void *obj,
int qubit,
double angle) {
4198 if (!obj)
return false;
4200 return fPauliPropApplyRZ(obj, qubit, angle) == 1;
4202 throw std::runtime_error(
"GpuLibrary: Unable to apply RZ gate on mps");
4206 bool PauliPropAddNoiseX(
void *obj,
int qubit,
double probability) {
4207 if (!obj)
return false;
4209 return fPauliPropAddNoiseX(obj, qubit, probability) == 1;
4211 throw std::runtime_error(
"GpuLibrary: Unable to add X noise on mps");
4215 bool PauliPropAddNoiseY(
void *obj,
int qubit,
double probability) {
4216 if (!obj)
return false;
4218 return fPauliPropAddNoiseY(obj, qubit, probability) == 1;
4220 throw std::runtime_error(
"GpuLibrary: Unable to add Y noise on mps");
4224 bool PauliPropAddNoiseZ(
void *obj,
int qubit,
double probability) {
4225 if (!obj)
return false;
4227 return fPauliPropAddNoiseZ(obj, qubit, probability) == 1;
4229 throw std::runtime_error(
"GpuLibrary: Unable to add Z noise on mps");
4233 bool PauliPropAddNoiseXYZ(
void *obj,
int qubit,
double probabilityX,
4234 double probabilityY,
double probabilityZ) {
4235 if (!obj)
return false;
4237 return fPauliPropAddNoiseXYZ(obj, qubit, probabilityX, probabilityY,
4240 throw std::runtime_error(
"GpuLibrary: Unable to add XYZ noise on mps");
4244 bool PauliPropAddAmplitudeDamping(
void *obj,
int qubit,
double dampingProb,
4245 double exciteProb) {
4246 if (!obj)
return false;
4248 return fPauliPropAddAmplitudeDamping(obj, qubit, dampingProb,
4251 throw std::runtime_error(
4252 "GpuLibrary: Unable to add amplitude damping on mps");
4256 double PauliPropQubitProbability0(
void *obj,
int qubit) {
4257 if (!obj)
return 0.0;
4259 return fPauliPropQubitProbability0(obj, qubit);
4261 throw std::runtime_error(
4262 "GpuLibrary: Unable to get qubit probability 0 in pauli propagation "
4267 double PauliPropProbability(
void *obj,
unsigned long long int outcome) {
4268 if (!obj)
return 0.0;
4270 return fPauliPropProbability(obj, outcome);
4272 throw std::runtime_error(
4273 "GpuLibrary: Unable to get probability of outcome in pauli "
4274 "propagation simulator");
4278 bool PauliPropMeasureQubit(
void *obj,
int qubit) {
4279 if (!obj)
return false;
4281 return fPauliPropMeasureQubit(obj, qubit) == 1;
4283 throw std::runtime_error(
4284 "GpuLibrary: Unable to measure qubit in pauli propagation simulator");
4288 unsigned char *PauliPropSampleQubits(
void *obj,
const int *qubits,
4290 if (!obj)
return nullptr;
4292 return fPauliPropSampleQubits(obj, qubits, nrQubits);
4294 throw std::runtime_error(
4295 "GpuLibrary: Unable to sample qubits in pauli propagation simulator");
4299 void PauliPropFreeSampledQubits(
unsigned char *samples) {
4300 if (!samples)
return;
4302 fPauliPropFreeSampledQubits(samples);
4304 throw std::runtime_error(
4305 "GpuLibrary: Unable to free sampled qubits in pauli propagation "
4309 void PauliPropSaveState(
void *obj) {
4312 fPauliPropSaveState(obj);
4314 throw std::runtime_error(
4315 "GpuLibrary: Unable to save state in pauli propagation simulator");
4318 void PauliPropRestoreState(
void *obj) {
4321 fPauliPropRestoreState(obj);
4323 throw std::runtime_error(
4324 "GpuLibrary: Unable to restore state in pauli propagation simulator");
4328 std::recursive_mutex initializationMutex;
4329 std::string loadedPath;
4330 void *LibraryHandle =
nullptr;
4332 int (*fValidateLicense)(
const char *) =
nullptr;
4333 void *(*InitLib)() =
nullptr;
4334 void (*FreeLib)() =
nullptr;
4336 inline static thread_local int creationDevice = 0;
4337 int (*fGetStateVectorGpuId)(
void*) =
nullptr;
4338 int (*fMPSGetGpuId)(
void*) =
nullptr;
4339 int (*fTNGetGpuId)(
void*) =
nullptr;
4340 int (*fDMGetGpuId)(
void*) =
nullptr;
4341 int (*fMPOGetGpuId)(
void*) =
nullptr;
4342 int (*fGetStabilizerGpuId)(
void*) =
nullptr;
4343 int (*fPauliPropGetGpuId)(
void*) =
nullptr;
4344 int (*fSetGpuDevice)(int) =
nullptr;
4345 int (*fGetGpuDeviceCount)() =
nullptr;
4347 void *(*fCreateStateVector)(
void *) =
nullptr;
4348 void (*fDestroyStateVector)(
void *) =
nullptr;
4350 int (*fSetDataType)(
void *, int) =
nullptr;
4351 int (*fIsDoublePrecision)(
void *) =
nullptr;
4352 int (*fGetNrQubits)(
void *) =
nullptr;
4353 int (*fCreate)(
void *,
unsigned int) =
nullptr;
4354 int (*fReset)(
void *) =
nullptr;
4355 int (*fCreateWithState)(
void *,
unsigned int,
const double *) =
nullptr;
4356 int (*fMeasureQubitCollapse)(
void *, int) =
nullptr;
4357 int (*fMeasureQubitNoCollapse)(
void *, int) =
nullptr;
4358 int (*fMeasureQubitsCollapse)(
void *,
int *,
int *, int) =
nullptr;
4359 int (*fMeasureQubitsNoCollapse)(
void *,
int *,
int *, int) =
nullptr;
4360 unsigned long long (*fMeasureAllQubitsCollapse)(
void *) =
nullptr;
4361 unsigned long long (*fMeasureAllQubitsNoCollapse)(
void *) =
nullptr;
4363 int (*fSaveState)(
void *) =
nullptr;
4364 int (*fSaveStateToHost)(
void *) =
nullptr;
4365 int (*fSaveStateDestructive)(
void *) =
nullptr;
4366 int (*fRestoreStateFreeSaved)(
void *) =
nullptr;
4367 int (*fRestoreStateNoFreeSaved)(
void *) =
nullptr;
4368 void (*fFreeSavedState)(
void *obj) =
nullptr;
4369 void *(*fClone)(
void *) =
nullptr;
4370 int (*fSetSeed)(
void *,
unsigned long long) =
nullptr;
4371 int (*fSample)(
void *,
unsigned int,
long int *,
unsigned int,
4373 int (*fSampleAll)(
void *,
unsigned int,
long int *) =
nullptr;
4374 int (*fAmplitude)(
void *,
long long int,
double *,
double *) =
nullptr;
4375 double (*fProbability)(
void *,
int *,
int *, int) =
nullptr;
4376 double (*fBasisStateProbability)(
void *,
long long int) =
nullptr;
4377 int (*fAllProbabilities)(
void *,
double *) =
nullptr;
4378 double (*fExpectationValue)(
void *,
const char *, int) =
nullptr;
4380 int (*fApplyX)(
void *, int) =
nullptr;
4381 int (*fApplyY)(
void *, int) =
nullptr;
4382 int (*fApplyZ)(
void *, int) =
nullptr;
4383 int (*fApplyH)(
void *, int) =
nullptr;
4384 int (*fApplyS)(
void *, int) =
nullptr;
4385 int (*fApplySDG)(
void *, int) =
nullptr;
4386 int (*fApplyT)(
void *, int) =
nullptr;
4387 int (*fApplyTDG)(
void *, int) =
nullptr;
4388 int (*fApplySX)(
void *, int) =
nullptr;
4389 int (*fApplySXDG)(
void *, int) =
nullptr;
4390 int (*fApplyK)(
void *, int) =
nullptr;
4391 int (*fApplyP)(
void *, int, double) =
nullptr;
4392 int (*fApplyRx)(
void *, int, double) =
nullptr;
4393 int (*fApplyRy)(
void *, int, double) =
nullptr;
4394 int (*fApplyRz)(
void *, int, double) =
nullptr;
4395 int (*fApplyU)(
void *, int, double, double, double, double) =
nullptr;
4396 int (*fApplyCX)(
void *, int, int) =
nullptr;
4397 int (*fApplyCY)(
void *, int, int) =
nullptr;
4398 int (*fApplyCZ)(
void *, int, int) =
nullptr;
4399 int (*fApplyCH)(
void *, int, int) =
nullptr;
4400 int (*fApplyCSX)(
void *, int, int) =
nullptr;
4401 int (*fApplyCSXDG)(
void *, int, int) =
nullptr;
4402 int (*fApplyCP)(
void *, int, int, double) =
nullptr;
4403 int (*fApplyCRx)(
void *, int, int, double) =
nullptr;
4404 int (*fApplyCRy)(
void *, int, int, double) =
nullptr;
4405 int (*fApplyCRz)(
void *, int, int, double) =
nullptr;
4406 int (*fApplyCCX)(
void *, int, int, int) =
nullptr;
4407 int (*fApplySwap)(
void *, int, int) =
nullptr;
4408 int (*fApplyCSwap)(
void *, int, int, int) =
nullptr;
4409 int (*fApplyCU)(
void *, int, int, double, double, double, double) =
nullptr;
4411 void *(*fCreateMPS)(
void *) =
nullptr;
4412 void (*fDestroyMPS)(
void *) =
nullptr;
4414 int (*fMPSCreate)(
void *,
unsigned int) =
nullptr;
4415 int (*fMPSCreateWithBasisState)(
void *,
unsigned int,
4416 unsigned long long) =
nullptr;
4417 int (*fMPSCreateWithBasisStateBits)(
void *,
unsigned int,
4418 const unsigned char *) =
nullptr;
4419 int (*fMPSReset)(
void *) =
nullptr;
4420 int (*fMPSSetInitialQubitsMap)(
void *,
const long long int *,
4422 int (*fMPSSetUseOptimalMeetingPosition)(
void *, int) =
nullptr;
4423 int (*fMPSGetUseOptimalMeetingPosition)(
void *) =
nullptr;
4425 int (*fMPSIsValid)(
void *) =
nullptr;
4426 int (*fMPSIsCreated)(
void *) =
nullptr;
4428 int (*fMPSSetDataType)(
void *, int) =
nullptr;
4429 int (*fMPSIsDoublePrecision)(
void *) =
nullptr;
4430 int (*fMPSSetCutoff)(
void *, double) =
nullptr;
4431 double (*fMPSGetCutoff)(
void *) =
nullptr;
4432 int (*fMPSSetTruncationMode)(
void *, int) =
nullptr;
4433 int (*fMPSGetTruncationMode)(
void *) =
nullptr;
4434 int (*fMPSSetGesvdJ)(
void *, int) =
nullptr;
4435 int (*fMPSGetGesvdJ)(
void *) =
nullptr;
4436 int (*fMPSSetGesvdP)(
void *, int) =
nullptr;
4437 int (*fMPSGetGesvdP)(
void *) =
nullptr;
4438 int (*fMPSSetGesvdR)(
void *, int) =
nullptr;
4439 int (*fMPSGetGesvdR)(
void *) =
nullptr;
4440 int (*fMPSGetLastSvdAlgo)(
void *) =
nullptr;
4441 int (*fMPSSetMaxExtent)(
void *,
long int) =
nullptr;
4442 long int (*fMPSGetMaxExtent)(
void *) =
nullptr;
4443 int (*fMPSGetNrQubits)(
void *) =
nullptr;
4444 int (*fMPSGetBondDimensions)(
void *,
long long int *) =
nullptr;
4445 int (*fMPSSetCallbackContext)(
void *,
void *) =
nullptr;
4446 int (*fMPSSetMeetingPositionCallback)(
void *, int64_t (*)(
void *,
const int64_t *)) =
nullptr;
4447 int (*fMPSSetBondDimensionsCallback)(
void *, void (*)(
void *,
const int64_t *)) =
nullptr;
4449 int (*fMPSAmplitude)(
void *,
long int,
long int *,
double *,
4450 double *) =
nullptr;
4451 double (*fMPSProbability0)(
void *,
unsigned int) =
nullptr;
4452 int (*fMPSMeasure)(
void *,
unsigned int) =
nullptr;
4453 int (*fMPSMeasureQubits)(
void *,
long int,
unsigned int *,
int *) =
nullptr;
4454 void *(*fMPSGetMapForSample)() =
nullptr;
4455 int (*fMPSFreeMapForSample)(
void *) =
nullptr;
4456 int (*fMPSSample)(
void *,
long int,
long int,
unsigned int *,
4458 int (*fMPSSampleRaw)(
void *,
unsigned int,
long int *,
unsigned int,
4459 const unsigned int *) =
nullptr;
4460 int (*fMPSSampleAll)(
void *,
unsigned int,
long int *) =
nullptr;
4462 int (*fMPSSaveState)(
void *) =
nullptr;
4463 int (*fMPSRestoreState)(
void *) =
nullptr;
4464 int (*fMPSCleanSavedState)(
void *) =
nullptr;
4465 void *(*fMPSClone)(
void *) =
nullptr;
4466 int (*fMPSSetSeed)(
void *,
unsigned long long) =
nullptr;
4468 double (*fMPSExpectationValue)(
void *,
const char *, int) =
nullptr;
4469 int (*fMPSProjectOnZero)(
void *,
double *,
double *) =
nullptr;
4471 int (*fMPSApplyX)(
void *,
unsigned int) =
nullptr;
4472 int (*fMPSApplyY)(
void *,
unsigned int) =
nullptr;
4473 int (*fMPSApplyZ)(
void *,
unsigned int) =
nullptr;
4474 int (*fMPSApplyH)(
void *,
unsigned int) =
nullptr;
4475 int (*fMPSApplyS)(
void *,
unsigned int) =
nullptr;
4476 int (*fMPSApplySDG)(
void *,
unsigned int) =
nullptr;
4477 int (*fMPSApplyT)(
void *,
unsigned int) =
nullptr;
4478 int (*fMPSApplyTDG)(
void *,
unsigned int) =
nullptr;
4479 int (*fMPSApplySX)(
void *,
unsigned int) =
nullptr;
4480 int (*fMPSApplySXDG)(
void *,
unsigned int) =
nullptr;
4481 int (*fMPSApplyK)(
void *,
unsigned int) =
nullptr;
4482 int (*fMPSApplyP)(
void *,
unsigned int, double) =
nullptr;
4483 int (*fMPSApplyRx)(
void *,
unsigned int, double) =
nullptr;
4484 int (*fMPSApplyRy)(
void *,
unsigned int, double) =
nullptr;
4485 int (*fMPSApplyRz)(
void *,
unsigned int, double) =
nullptr;
4486 int (*fMPSApplyU)(
void *,
unsigned int, double, double, double,
4488 int (*fMPSApplyOneQubitMatrix)(
void *,
unsigned int,
4489 const double *) =
nullptr;
4490 int (*fMPSApplyTwoQubitMatrix)(
void *,
unsigned int,
unsigned int,
4491 const double *) =
nullptr;
4492 int (*fMPSApplySwap)(
void *,
unsigned int,
unsigned int) =
nullptr;
4493 int (*fMPSApplyCX)(
void *,
unsigned int,
unsigned int) =
nullptr;
4494 int (*fMPSApplyCY)(
void *,
unsigned int,
unsigned int) =
nullptr;
4495 int (*fMPSApplyCZ)(
void *,
unsigned int,
unsigned int) =
nullptr;
4496 int (*fMPSApplyCH)(
void *,
unsigned int,
unsigned int) =
nullptr;
4497 int (*fMPSApplyCSX)(
void *,
unsigned int,
unsigned int) =
nullptr;
4498 int (*fMPSApplyCSXDG)(
void *,
unsigned int,
unsigned int) =
nullptr;
4499 int (*fMPSApplyCP)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
4500 int (*fMPSApplyCRx)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
4501 int (*fMPSApplyCRy)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
4502 int (*fMPSApplyCRz)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
4503 int (*fMPSApplyCU)(
void *,
unsigned int,
unsigned int, double, double, double,
4507 void *(*fCreateTensorNet)(
void *) =
nullptr;
4508 void (*fDestroyTensorNet)(
void *) =
nullptr;
4510 int (*fTNCreate)(
void *,
unsigned int) =
nullptr;
4511 int (*fTNReset)(
void *) =
nullptr;
4512 int (*fTNIsValid)(
void *) =
nullptr;
4513 int (*fTNIsCreated)(
void *) =
nullptr;
4515 int (*fTNSetDataType)(
void *, int) =
nullptr;
4516 int (*fTNIsDoublePrecision)(
void *) =
nullptr;
4517 int (*fTNSetCutoff)(
void *, double) =
nullptr;
4518 double (*fTNGetCutoff)(
void *) =
nullptr;
4519 int (*fTNSetTruncationMode)(
void *, int) =
nullptr;
4520 int (*fTNGetTruncationMode)(
void *) =
nullptr;
4521 int (*fTNSetGesvdJ)(
void *, int) =
nullptr;
4522 int (*fTNGetGesvdJ)(
void *) =
nullptr;
4523 int (*fTNSetGesvdP)(
void *, int) =
nullptr;
4524 int (*fTNGetGesvdP)(
void *) =
nullptr;
4525 int (*fTNSetGesvdR)(
void *, int) =
nullptr;
4526 int (*fTNGetGesvdR)(
void *) =
nullptr;
4527 int (*fTNSetMaxExtent)(
void *,
long int) =
nullptr;
4528 long int (*fTNGetMaxExtent)(
void *) =
nullptr;
4529 int (*fTNGetNrQubits)(
void *) =
nullptr;
4530 int (*fTNAmplitude)(
void *,
long int,
long int *,
double *,
4531 double *) =
nullptr;
4532 double (*fTNProbability0)(
void *,
unsigned int) =
nullptr;
4533 int (*fTNMeasure)(
void *,
unsigned int) =
nullptr;
4534 int (*fTNMeasureQubits)(
void *,
long int,
unsigned int *,
int *) =
nullptr;
4535 void *(*fTNGetMapForSample)() =
nullptr;
4536 int (*fTNFreeMapForSample)(
void *) =
nullptr;
4537 int (*fTNSample)(
void *,
long int,
long int,
unsigned int *,
4540 int (*fTNSaveState)(
void *) =
nullptr;
4541 int (*fTNRestoreState)(
void *) =
nullptr;
4542 int (*fTNCleanSavedState)(
void *) =
nullptr;
4543 void *(*fTNClone)(
void *) =
nullptr;
4544 int (*fTNSetSeed)(
void *,
unsigned long long) =
nullptr;
4546 double (*fTNExpectationValue)(
void *,
const char *, int) =
nullptr;
4548 int (*fTNApplyX)(
void *,
unsigned int) =
nullptr;
4549 int (*fTNApplyY)(
void *,
unsigned int) =
nullptr;
4550 int (*fTNApplyZ)(
void *,
unsigned int) =
nullptr;
4551 int (*fTNApplyH)(
void *,
unsigned int) =
nullptr;
4552 int (*fTNApplyS)(
void *,
unsigned int) =
nullptr;
4553 int (*fTNApplySDG)(
void *,
unsigned int) =
nullptr;
4554 int (*fTNApplyT)(
void *,
unsigned int) =
nullptr;
4555 int (*fTNApplyTDG)(
void *,
unsigned int) =
nullptr;
4556 int (*fTNApplySX)(
void *,
unsigned int) =
nullptr;
4557 int (*fTNApplySXDG)(
void *,
unsigned int) =
nullptr;
4558 int (*fTNApplyK)(
void *,
unsigned int) =
nullptr;
4559 int (*fTNApplyP)(
void *,
unsigned int, double) =
nullptr;
4560 int (*fTNApplyRx)(
void *,
unsigned int, double) =
nullptr;
4561 int (*fTNApplyRy)(
void *,
unsigned int, double) =
nullptr;
4562 int (*fTNApplyRz)(
void *,
unsigned int, double) =
nullptr;
4563 int (*fTNApplyU)(
void *,
unsigned int, double, double, double,
4565 int (*fTNApplySwap)(
void *,
unsigned int,
unsigned int) =
nullptr;
4566 int (*fTNApplyCX)(
void *,
unsigned int,
unsigned int) =
nullptr;
4567 int (*fTNApplyCY)(
void *,
unsigned int,
unsigned int) =
nullptr;
4568 int (*fTNApplyCZ)(
void *,
unsigned int,
unsigned int) =
nullptr;
4569 int (*fTNApplyCH)(
void *,
unsigned int,
unsigned int) =
nullptr;
4570 int (*fTNApplyCSX)(
void *,
unsigned int,
unsigned int) =
nullptr;
4571 int (*fTNApplyCSXDG)(
void *,
unsigned int,
unsigned int) =
nullptr;
4572 int (*fTNApplyCP)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
4573 int (*fTNApplyCRx)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
4574 int (*fTNApplyCRy)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
4575 int (*fTNApplyCRz)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
4576 int (*fTNApplyCU)(
void *,
unsigned int,
unsigned int, double, double, double,
4578 int (*fTNApplyCCX)(
void *,
unsigned int,
unsigned int,
4579 unsigned int) =
nullptr;
4580 int (*fTNApplyCSwap)(
void *,
unsigned int,
unsigned int,
4581 unsigned int) =
nullptr;
4583 void *(*fCreateStabilizerSimulator)(
long long int,
long long int,
4584 long long int,
long long int) =
nullptr;
4585 void (*fDestroyStabilizerSimulator)(
void *) =
nullptr;
4586 int (*fExecuteStabilizerCircuit)(
void *,
const char *, int,
4587 unsigned long long int) =
nullptr;
4588 long long (*fGetStabilizerXZTableSize)(
void *) =
nullptr;
4589 long long (*fGetStabilizerMTableSize)(
void *) =
nullptr;
4590 long long (*fGetStabilizerTableStrideMajor)(
void *) =
nullptr;
4591 long long (*fGetStabilizerNumQubits)(
void *) =
nullptr;
4592 long long (*fGetStabilizerNumShots)(
void *) =
nullptr;
4593 long long (*fGetStabilizerNumMeasurements)(
void *) =
nullptr;
4594 long long (*fGetStabilizerNumDetectors)(
void *) =
nullptr;
4595 int (*fCopyStabilizerXTable)(
void *,
unsigned int *) =
nullptr;
4596 int (*fCopyStabilizerZTable)(
void *,
unsigned int *) =
nullptr;
4597 int (*fCopyStabilizerMTable)(
void *,
unsigned int *) =
nullptr;
4598 int (*fInitStabilizerXTable)(
void *,
const unsigned int *) =
nullptr;
4599 int (*fInitStabilizerZTable)(
void *,
const unsigned int *) =
nullptr;
4601 void *(*fCreatePauliPropSimulator)(int) =
nullptr;
4602 void (*fDestroyPauliPropSimulator)(
void *) =
nullptr;
4604 int (*fPauliPropGetNrQubits)(
void *) =
nullptr;
4605 int (*fPauliPropSetWillUseSampling)(
void *, int) =
nullptr;
4606 int (*fPauliPropGetWillUseSampling)(
void *) =
nullptr;
4607 double (*fPauliPropGetCoefficientTruncationCutoff)(
void *) =
nullptr;
4608 void (*fPauliPropSetCoefficientTruncationCutoff)(
void *, double) =
nullptr;
4609 double (*fPauliPropGetWeightTruncationCutoff)(
void *) =
nullptr;
4610 void (*fPauliPropSetWeightTruncationCutoff)(
void *, double) =
nullptr;
4611 int (*fPauliPropGetNumGatesBetweenTruncations)(
void *) =
nullptr;
4612 void (*fPauliPropSetNumGatesBetweenTruncations)(
void *, int) =
nullptr;
4613 int (*fPauliPropGetNumGatesBetweenDeduplications)(
void *) =
nullptr;
4614 void (*fPauliPropSetNumGatesBetweenDeduplications)(
void *, int) =
nullptr;
4615 int (*fPauliPropClearOperators)(
void *) =
nullptr;
4616 int (*fPauliPropAllocateMemory)(
void *, double) =
nullptr;
4617 double (*fPauliPropGetExpectationValue)(
void *) =
nullptr;
4618 int (*fPauliPropExecute)(
void *) =
nullptr;
4619 int (*fPauliPropSetSeed)(
void *,
unsigned long long) =
nullptr;
4620 int (*fPauliPropSetInPauliExpansionUnique)(
void *,
const char *) =
nullptr;
4621 int (*fPauliPropSetInPauliExpansionMultiple)(
void *,
const char **,
4622 const double *, int) =
nullptr;
4624 int (*fPauliPropApplyX)(
void *, int) =
nullptr;
4625 int (*fPauliPropApplyY)(
void *, int) =
nullptr;
4626 int (*fPauliPropApplyZ)(
void *, int) =
nullptr;
4627 int (*fPauliPropApplyH)(
void *, int) =
nullptr;
4628 int (*fPauliPropApplyS)(
void *, int) =
nullptr;
4629 int (*fPauliPropApplySQRTX)(
void *, int) =
nullptr;
4630 int (*fPauliPropApplySQRTY)(
void *, int) =
nullptr;
4631 int (*fPauliPropApplySQRTZ)(
void *, int) =
nullptr;
4632 int (*fPauliPropApplyCX)(
void *, int, int) =
nullptr;
4633 int (*fPauliPropApplyCY)(
void *, int, int) =
nullptr;
4634 int (*fPauliPropApplyCZ)(
void *, int, int) =
nullptr;
4635 int (*fPauliPropApplySWAP)(
void *, int, int) =
nullptr;
4636 int (*fPauliPropApplyISWAP)(
void *, int, int) =
nullptr;
4637 int (*fPauliPropApplyRX)(
void *, int, double) =
nullptr;
4638 int (*fPauliPropApplyRY)(
void *, int, double) =
nullptr;
4639 int (*fPauliPropApplyRZ)(
void *, int, double) =
nullptr;
4640 int (*fPauliPropAddNoiseX)(
void *, int, double) =
nullptr;
4641 int (*fPauliPropAddNoiseY)(
void *, int, double) =
nullptr;
4642 int (*fPauliPropAddNoiseZ)(
void *, int, double) =
nullptr;
4643 int (*fPauliPropAddNoiseXYZ)(
void *, int, double, double, double) =
nullptr;
4644 int (*fPauliPropAddAmplitudeDamping)(
void *, int, double, double) =
nullptr;
4645 double (*fPauliPropQubitProbability0)(
void *, int) =
nullptr;
4646 double (*fPauliPropProbability)(
void *,
unsigned long long int) =
nullptr;
4648 int (*fPauliPropMeasureQubit)(
void *, int) =
nullptr;
4649 unsigned char *(*fPauliPropSampleQubits)(
void *,
const int *, int) =
nullptr;
4650 void (*fPauliPropFreeSampledQubits)(
unsigned char *) =
nullptr;
4651 void (*fPauliPropSaveState)(
void *) =
nullptr;
4652 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