54#include <unordered_map>
63 GpuLibrary()
noexcept =
default;
69 MATRIX_COLUMN_MAJOR = 1
72 static std::shared_ptr<GpuLibrary> GetInstance()
74 static const auto instance = std::shared_ptr<GpuLibrary>(
new GpuLibrary());
78 GpuLibrary(
const GpuLibrary &) =
delete;
79 GpuLibrary &operator=(
const GpuLibrary &) =
delete;
80 GpuLibrary(GpuLibrary &&) =
delete;
81 GpuLibrary &operator=(GpuLibrary &&) =
delete;
83 ~GpuLibrary()
override
85 if (LibraryHandle && FreeLib)
92 std::unique_lock<std::recursive_mutex> LockInitialization()
94 return std::unique_lock<std::recursive_mutex>(initializationMutex);
97 bool Load(
const char *libName)
noexcept
99 auto lock = LockInitialization();
102 if (loadedPath == libName)
103 return licenseValidated && !initializationFailed;
105 std::cerr <<
"GpuLibrary: singleton already loaded from " << loadedPath <<
"; cannot load " << libName << std::endl;
110 loadedPath = libName;
111 fGetLicenseError = (
const char *(*)())GetFunction(
"GetLicenseError");
112 fValidateLicense = (int (*)(
const char *))GetFunction(
"ValidateLicense");
113 if (!fValidateLicense)
115 std::cerr <<
"GpuLibrary: GPU backend unavailable: missing ValidateLicense" << std::endl;
118 if (fValidateLicense(std::getenv(
"MAESTRO_LICENSE_KEY")) != 1)
120 ReportUnavailable(
"license validation failed");
123 licenseValidated =
true;
124 fGetGpuDeviceCount = (int (*)())GetFunction(
"GetGpuDeviceCount");
125 fSetGpuDevice = (int (*)(int))GetFunction(
"SetGpuDevice");
126 fGetStateVectorGpuId = (int (*)(
void *))GetFunction(
"GetStateVectorGpuId");
127 fMPSGetGpuId = (int (*)(
void *))GetFunction(
"MPSGetGpuId");
128 fTNGetGpuId = (int (*)(
void *))GetFunction(
"TNGetGpuId");
129 fDMGetGpuId = (int (*)(
void *))GetFunction(
"DMGetGpuId");
130 fMPOGetGpuId = (int (*)(
void *))GetFunction(
"MPOGetGpuId");
131 fGetStabilizerGpuId = (int (*)(
void *))GetFunction(
"GetStabilizerGpuId");
132 fPauliPropGetGpuId = (int (*)(
void *))GetFunction(
"PauliPropGetGpuId");
134 fMPSSwapRelabels =
reinterpret_cast<int (*)()
>(GetFunction(
"MPSSwapRelabels"));
135 fMPOSwapRelabels =
reinterpret_cast<int (*)()
>(GetFunction(
"MPOSwapRelabels"));
136 fStateVectorSynchronize = (int (*)(
void *))GetFunction(
"StateVectorSynchronize");
137 fDMSynchronize = (int (*)(
void *))GetFunction(
"DMSynchronize");
138 fMPSTrim = (int (*)(
void *))GetFunction(
"MPSTrim");
139 fMPSReCanonicalize = (int (*)(
void *))GetFunction(
"MPSReCanonicalize");
141#define LOAD_TENSOR_QUERY(name) f##name = reinterpret_cast<decltype(f##name)>(GetFunction(#name))
142 LOAD_TENSOR_QUERY(MPSExpectationValues);
143 LOAD_TENSOR_QUERY(MPOExpectationValues);
144 LOAD_TENSOR_QUERY(MPOExpectationValuesComplex);
145 LOAD_TENSOR_QUERY(MPSGetStateVector);
146 LOAD_TENSOR_QUERY(MPSAllProbabilities);
147 LOAD_TENSOR_QUERY(MPSMoveAtBeginningOfChain);
148 LOAD_TENSOR_QUERY(MPSExpectationValueOperators);
149 LOAD_TENSOR_QUERY(MPSSetBondDimensionSummaryCallback);
150 LOAD_TENSOR_QUERY(MPOSetBondDimensionSummaryCallback);
151 LOAD_TENSOR_QUERY(MPSGetMaxBondDimension);
152 LOAD_TENSOR_QUERY(MPOGetMaxBondDimension);
153#undef LOAD_TENSOR_QUERY
158 bool MPSSwapRelabels()
const
160 return fMPSSwapRelabels && fMPSSwapRelabels() == 1;
163 bool MPOSwapRelabels()
const
165 return fMPOSwapRelabels && fMPOSwapRelabels() == 1;
168 int DiscoverDevices(
const char *path)
170 auto lock = LockInitialization();
172 return Init(path) ? GetGpuDeviceCount() : 0;
175 bool InitializeForDevice(
const char *path,
int device,
bool mute =
false)
177 auto lock = LockInitialization();
180 throw std::invalid_argument(
"gpu_device must be nonnegative");
183 const int count = GetGpuDeviceCount();
187 std::cerr <<
"GpuLibrary: GPU device " << device <<
" is unavailable (" << count <<
" visible devices)" << std::endl;
192 if (!SetGpuDevice(device))
195 std::cerr <<
"GpuLibrary: Unable to select GPU device " << device << std::endl;
201 bool Init(
const char *libName)
noexcept override
203 auto lock = LockInitialization();
209 FreeLib = (void (*)())GetFunction(
"FreeLib");
210 if (!fSetGpuDevice || !FreeLib)
213 std::cerr <<
"GpuLibrary: SetGpuDevice and FreeLib are required." << std::endl;
217 InitLib = (
void *(*)())GetFunction(
"InitLib");
218 CheckFunction((
void *)InitLib, __LINE__);
221 LibraryHandle = InitLib();
224 FreeLib = (void (*)())GetFunction(
"FreeLib");
225 CheckFunction((
void *)FreeLib, __LINE__);
229 fCreateStateVector = (
void *(*)(
void *))GetFunction(
"CreateStateVector");
230 CheckFunction((
void *)fCreateStateVector, __LINE__);
231 fDestroyStateVector = (void (*)(
void *))GetFunction(
"DestroyStateVector");
232 CheckFunction((
void *)fDestroyStateVector, __LINE__);
234 fCreate = (int (*)(
void *,
unsigned int))GetFunction(
"Create");
235 CheckFunction((
void *)fCreate, __LINE__);
236 fCreateWithState = (int (*)(
void *,
unsigned int,
const double *))GetFunction(
"CreateWithState");
237 CheckFunction((
void *)fCreateWithState, __LINE__);
238 fReset = (int (*)(
void *))GetFunction(
"Reset");
239 CheckFunction((
void *)fReset, __LINE__);
241 fSetDataType = (int (*)(
void *, int))GetFunction(
"SetDataType");
242 CheckFunction((
void *)fSetDataType, __LINE__);
243 fIsDoublePrecision = (int (*)(
void *))GetFunction(
"IsDoublePrecision");
244 CheckFunction((
void *)fIsDoublePrecision, __LINE__);
245 fGetNrQubits = (int (*)(
void *))GetFunction(
"GetNrQubits");
246 CheckFunction((
void *)fGetNrQubits, __LINE__);
248 fMeasureQubitCollapse = (int (*)(
void *, int))GetFunction(
"MeasureQubitCollapse");
249 CheckFunction((
void *)fMeasureQubitCollapse, __LINE__);
250 fMeasureQubitNoCollapse = (int (*)(
void *, int))GetFunction(
"MeasureQubitNoCollapse");
251 CheckFunction((
void *)fMeasureQubitNoCollapse, __LINE__);
252 fMeasureQubitsCollapse = (int (*)(
void *,
int *,
int *, int))GetFunction(
"MeasureQubitsCollapse");
253 CheckFunction((
void *)fMeasureQubitsCollapse, __LINE__);
254 fMeasureQubitsNoCollapse = (int (*)(
void *,
int *,
int *, int))GetFunction(
"MeasureQubitsNoCollapse");
255 CheckFunction((
void *)fMeasureQubitsNoCollapse, __LINE__);
256 fMeasureAllQubitsCollapse = (
unsigned long long (*)(
void *))GetFunction(
"MeasureAllQubitsCollapse");
257 CheckFunction((
void *)fMeasureAllQubitsCollapse, __LINE__);
258 fMeasureAllQubitsNoCollapse = (
unsigned long long (*)(
void *))GetFunction(
"MeasureAllQubitsNoCollapse");
259 CheckFunction((
void *)fMeasureAllQubitsNoCollapse, __LINE__);
261 fSaveState = (int (*)(
void *))GetFunction(
"SaveState");
262 CheckFunction((
void *)fSaveState, __LINE__);
263 fSaveStateToHost = (int (*)(
void *))GetFunction(
"SaveStateToHost");
264 CheckFunction((
void *)fSaveStateToHost, __LINE__);
265 fSaveStateDestructive = (int (*)(
void *))GetFunction(
"SaveStateDestructive");
266 CheckFunction((
void *)fSaveStateDestructive, __LINE__);
267 fRestoreStateFreeSaved = (int (*)(
void *))GetFunction(
"RestoreStateFreeSaved");
268 CheckFunction((
void *)fRestoreStateFreeSaved, __LINE__);
269 fRestoreStateNoFreeSaved = (int (*)(
void *))GetFunction(
"RestoreStateNoFreeSaved");
270 CheckFunction((
void *)fRestoreStateNoFreeSaved, __LINE__);
271 fFreeSavedState = (void (*)(
void *))GetFunction(
"FreeSavedState");
272 CheckFunction((
void *)fFreeSavedState, __LINE__);
273 fClone = (
void *(*)(
void *))GetFunction(
"Clone");
274 CheckFunction((
void *)fClone, __LINE__);
275 fSetSeed = (int (*)(
void *,
unsigned long long))GetFunction(
"SetSeed");
276 CheckFunction((
void *)fSetSeed, __LINE__);
278 fSample = (int (*)(
void *,
unsigned int,
long int *,
unsigned int,
int *))GetFunction(
"Sample");
279 CheckFunction((
void *)fSample, __LINE__);
280 fSampleAll = (int (*)(
void *,
unsigned int,
long int *))GetFunction(
"SampleAll");
281 CheckFunction((
void *)fSampleAll, __LINE__);
282 fAmplitude = (int (*)(
void *,
long long int,
double *,
double *))GetFunction(
"Amplitude");
283 CheckFunction((
void *)fAmplitude, __LINE__);
284 fProbability = (double (*)(
void *,
int *,
int *, int))GetFunction(
"Probability");
285 CheckFunction((
void *)fProbability, __LINE__);
286 fBasisStateProbability = (double (*)(
void *,
long long int))GetFunction(
"BasisStateProbability");
287 CheckFunction((
void *)fBasisStateProbability, __LINE__);
288 fAllProbabilities = (int (*)(
void *obj,
double *probabilities))GetFunction(
"AllProbabilities");
289 CheckFunction((
void *)fAllProbabilities, __LINE__);
290 fExpectationValue = (double (*)(
void *,
const char *, int))GetFunction(
"ExpectationValue");
291 CheckFunction((
void *)fExpectationValue, __LINE__);
293 fApplyX = (int (*)(
void *, int))GetFunction(
"ApplyX");
294 CheckFunction((
void *)fApplyX, __LINE__);
295 fApplyY = (int (*)(
void *, int))GetFunction(
"ApplyY");
296 CheckFunction((
void *)fApplyY, __LINE__);
297 fApplyZ = (int (*)(
void *, int))GetFunction(
"ApplyZ");
298 CheckFunction((
void *)fApplyZ, __LINE__);
299 fApplyH = (int (*)(
void *, int))GetFunction(
"ApplyH");
300 CheckFunction((
void *)fApplyH, __LINE__);
301 fApplyS = (int (*)(
void *, int))GetFunction(
"ApplyS");
302 CheckFunction((
void *)fApplyS, __LINE__);
303 fApplySDG = (int (*)(
void *, int))GetFunction(
"ApplySDG");
304 CheckFunction((
void *)fApplySDG, __LINE__);
305 fApplyT = (int (*)(
void *, int))GetFunction(
"ApplyT");
306 CheckFunction((
void *)fApplyT, __LINE__);
307 fApplyTDG = (int (*)(
void *, int))GetFunction(
"ApplyTDG");
308 CheckFunction((
void *)fApplyTDG, __LINE__);
309 fApplySX = (int (*)(
void *, int))GetFunction(
"ApplySX");
310 CheckFunction((
void *)fApplySX, __LINE__);
311 fApplySXDG = (int (*)(
void *, int))GetFunction(
"ApplySXDG");
312 CheckFunction((
void *)fApplySXDG, __LINE__);
313 fApplyK = (int (*)(
void *, int))GetFunction(
"ApplyK");
314 CheckFunction((
void *)fApplyK, __LINE__);
315 fApplyP = (int (*)(
void *, int, double))GetFunction(
"ApplyP");
316 CheckFunction((
void *)fApplyP, __LINE__);
317 fApplyRx = (int (*)(
void *, int, double))GetFunction(
"ApplyRx");
318 CheckFunction((
void *)fApplyRx, __LINE__);
319 fApplyRy = (int (*)(
void *, int, double))GetFunction(
"ApplyRy");
320 CheckFunction((
void *)fApplyRy, __LINE__);
321 fApplyRz = (int (*)(
void *, int, double))GetFunction(
"ApplyRz");
322 CheckFunction((
void *)fApplyRz, __LINE__);
323 fApplyU = (int (*)(
void *, int, double, double, double, double))GetFunction(
"ApplyU");
324 CheckFunction((
void *)fApplyU, __LINE__);
325 fApplyCX = (int (*)(
void *, int, int))GetFunction(
"ApplyCX");
326 CheckFunction((
void *)fApplyCX, __LINE__);
327 fApplyCY = (int (*)(
void *, int, int))GetFunction(
"ApplyCY");
328 CheckFunction((
void *)fApplyCY, __LINE__);
329 fApplyCZ = (int (*)(
void *, int, int))GetFunction(
"ApplyCZ");
330 CheckFunction((
void *)fApplyCZ, __LINE__);
331 fApplyCH = (int (*)(
void *, int, int))GetFunction(
"ApplyCH");
332 CheckFunction((
void *)fApplyCH, __LINE__);
333 fApplyCSX = (int (*)(
void *, int, int))GetFunction(
"ApplyCSX");
334 CheckFunction((
void *)fApplyCSX, __LINE__);
335 fApplyCSXDG = (int (*)(
void *, int, int))GetFunction(
"ApplyCSXDG");
336 CheckFunction((
void *)fApplyCSXDG, __LINE__);
337 fApplyCP = (int (*)(
void *, int, int, double))GetFunction(
"ApplyCP");
338 CheckFunction((
void *)fApplyCP, __LINE__);
339 fApplyCRx = (int (*)(
void *, int, int, double))GetFunction(
"ApplyCRx");
340 CheckFunction((
void *)fApplyCRx, __LINE__);
341 fApplyCRy = (int (*)(
void *, int, int, double))GetFunction(
"ApplyCRy");
342 CheckFunction((
void *)fApplyCRy, __LINE__);
343 fApplyCRz = (int (*)(
void *, int, int, double))GetFunction(
"ApplyCRz");
344 CheckFunction((
void *)fApplyCRz, __LINE__);
345 fApplyCCX = (int (*)(
void *, int, int, int))GetFunction(
"ApplyCCX");
346 CheckFunction((
void *)fApplyCCX, __LINE__);
347 fApplySwap = (int (*)(
void *, int, int))GetFunction(
"ApplySwap");
348 CheckFunction((
void *)fApplySwap, __LINE__);
349 fApplyCSwap = (int (*)(
void *, int, int, int))GetFunction(
"ApplyCSwap");
350 CheckFunction((
void *)fApplyCSwap, __LINE__);
351 fApplyCU = (int (*)(
void *, int, int, double, double, double, double))GetFunction(
"ApplyCU");
352 CheckFunction((
void *)fApplyCU, __LINE__);
355 fApplyOneQubitMatrix =
reinterpret_cast<int (*)(
void *,
int,
const double *)
>(GetFunction(
"ApplyOneQubitMatrix"));
356 fApplyOneQubitMatrixWithLayout =
reinterpret_cast<int (*)(
void *,
int,
const double *,
int)
>(GetFunction(
"ApplyOneQubitMatrixWithLayout"));
357 fApplyTwoQubitMatrix =
reinterpret_cast<int (*)(
void *,
int,
int,
const double *)
>(GetFunction(
"ApplyTwoQubitMatrix"));
358 fApplyTwoQubitMatrixWithLayout =
359 reinterpret_cast<int (*)(
void *,
int,
int,
const double *,
int)
>(GetFunction(
"ApplyTwoQubitMatrixWithLayout"));
360 fApplyThreeQubitMatrix =
reinterpret_cast<int (*)(
void *,
int,
int,
int,
const double *)
>(GetFunction(
"ApplyThreeQubitMatrix"));
361 fApplyThreeQubitMatrixWithLayout =
362 reinterpret_cast<int (*)(
void *,
int,
int,
int,
const double *,
int)
>(GetFunction(
"ApplyThreeQubitMatrixWithLayout"));
365#define LOAD_DM(name, type) \
366 f##name = reinterpret_cast<type>(GetFunction(#name)); \
367 CheckFunction(reinterpret_cast<void *>(f##name), __LINE__)
368 LOAD_DM(CreateDensityMatrix,
void *(*)(
void *));
369 LOAD_DM(DestroyDensityMatrix,
void (*)(
void *));
370 LOAD_DM(DMCreate,
int (*)(
void *,
unsigned int));
371 LOAD_DM(DMCreateWithState,
int (*)(
void *,
unsigned int,
const double *));
372 LOAD_DM(DMCreateWithBasisState,
int (*)(
void *,
unsigned int,
unsigned long long));
373 LOAD_DM(DMCreateWithMixtureOfBasisStates,
int (*)(
void *,
unsigned int,
const unsigned long long *,
const double *,
int));
374 LOAD_DM(DMReset,
int (*)(
void *));
375 LOAD_DM(DMIsValid,
int (*)(
void *));
376 LOAD_DM(DMIsCreated,
int (*)(
void *));
377 LOAD_DM(DMSetDataType,
int (*)(
void *,
int));
378 LOAD_DM(DMIsDoublePrecision,
int (*)(
void *));
379 LOAD_DM(DMGetNrQubits,
int (*)(
void *));
380 LOAD_DM(DMSaveState,
int (*)(
void *));
381 LOAD_DM(DMRestoreState,
int (*)(
void *));
382 LOAD_DM(DMCleanSavedState,
int (*)(
void *));
383 LOAD_DM(DMClone,
void *(*)(
void *));
384 LOAD_DM(DMSetSeed,
int (*)(
void *,
unsigned long long));
385 LOAD_DM(DMMeasureQubitCollapse,
int (*)(
void *,
int));
386 LOAD_DM(DMMeasureQubitNoCollapse,
int (*)(
void *,
int));
387 LOAD_DM(DMMeasureQubitsCollapse,
int (*)(
void *,
int *,
int *,
int));
388 LOAD_DM(DMMeasureQubitsNoCollapse,
int (*)(
void *,
int *,
int *,
int));
389 LOAD_DM(DMMeasureAllQubitsCollapse,
unsigned long long (*)(
void *));
390 LOAD_DM(DMMeasureAllQubitsNoCollapse,
unsigned long long (*)(
void *));
391 LOAD_DM(DMSample,
int (*)(
void *,
unsigned int,
long int *,
unsigned int,
int *));
392 LOAD_DM(DMSampleAll,
int (*)(
void *,
unsigned int,
long int *));
393 LOAD_DM(DMGetElement,
int (*)(
void *,
long long,
long long,
double *,
double *));
394 LOAD_DM(DMBasisStateProbability,
double (*)(
void *,
long long));
395 LOAD_DM(DMAllProbabilities,
int (*)(
void *,
double *));
396 LOAD_DM(DMExpectationValue,
double (*)(
void *,
const char *,
int));
397 LOAD_DM(DMQubitProbability0,
double (*)(
void *,
unsigned int));
398 LOAD_DM(DMTrace,
double (*)(
void *));
399 LOAD_DM(DMPurity,
double (*)(
void *));
400 LOAD_DM(DMIsHermitian,
int (*)(
void *,
double));
401 LOAD_DM(DMPartialTrace,
int (*)(
void *,
const int *,
int,
double *));
402 LOAD_DM(DMHilbertSchmidtOverlap,
int (*)(
void *,
void *,
double *,
double *));
403 LOAD_DM(DMFidelityWithStatevector,
int (*)(
void *,
const double *,
double *));
404 LOAD_DM(DMApplyKraus,
int (*)(
void *,
int,
const int *,
int,
const double *));
405#define LOAD_DM_GATE1(name) LOAD_DM(name, int (*)(void *, int))
406#define LOAD_DM_GATE2(name) LOAD_DM(name, int (*)(void *, int, int))
407#define LOAD_DM_ROT1(name) LOAD_DM(name, int (*)(void *, int, double))
408#define LOAD_DM_ROT2(name) LOAD_DM(name, int (*)(void *, int, int, double))
409 LOAD_DM_GATE1(DMApplyReset);
410 LOAD_DM_ROT1(DMApplyBitFlipNoise);
411 LOAD_DM_ROT1(DMApplyPhaseFlipNoise);
412 LOAD_DM_ROT1(DMApplyDepolarizingNoise);
413 LOAD_DM_ROT1(DMApplyAmplitudeDamping);
414 LOAD_DM_ROT1(DMApplyPhaseDamping);
415 LOAD_DM_GATE1(DMApplyNonSelectiveMeasurement);
416 LOAD_DM_GATE1(DMApplyX);
417 LOAD_DM_GATE1(DMApplyY);
418 LOAD_DM_GATE1(DMApplyZ);
419 LOAD_DM_GATE1(DMApplyH);
420 LOAD_DM_GATE1(DMApplyS);
421 LOAD_DM_GATE1(DMApplySDG);
422 LOAD_DM_GATE1(DMApplyT);
423 LOAD_DM_GATE1(DMApplyTDG);
424 LOAD_DM_GATE1(DMApplySX);
425 LOAD_DM_GATE1(DMApplySXDG);
426 LOAD_DM_GATE1(DMApplyK);
427 LOAD_DM_ROT1(DMApplyP);
428 LOAD_DM_ROT1(DMApplyRx);
429 LOAD_DM_ROT1(DMApplyRy);
430 LOAD_DM_ROT1(DMApplyRz);
431 LOAD_DM(DMApplyU,
int (*)(
void *,
int,
double,
double,
double,
double));
432 LOAD_DM_GATE2(DMApplyCX);
433 LOAD_DM_GATE2(DMApplyCY);
434 LOAD_DM_GATE2(DMApplyCZ);
435 LOAD_DM_GATE2(DMApplyCH);
436 LOAD_DM_GATE2(DMApplyCSX);
437 LOAD_DM_GATE2(DMApplyCSXDG);
438 LOAD_DM_ROT2(DMApplyCP);
439 LOAD_DM_ROT2(DMApplyCRx);
440 LOAD_DM_ROT2(DMApplyCRy);
441 LOAD_DM_ROT2(DMApplyCRz);
442 LOAD_DM(DMApplyCCX,
int (*)(
void *,
int,
int,
int));
443 LOAD_DM_GATE2(DMApplySwap);
444 LOAD_DM(DMApplyCSwap,
int (*)(
void *,
int,
int,
int));
445 LOAD_DM(DMApplyCU,
int (*)(
void *,
int,
int,
double,
double,
double,
double));
453#define LOAD_MPO(name, type) \
454 f##name = reinterpret_cast<type>(GetFunction(#name)); \
455 CheckFunction(reinterpret_cast<void *>(f##name), __LINE__)
456 LOAD_MPO(CreateMPO,
void *(*)(
void *));
457 LOAD_MPO(DestroyMPO,
void (*)(
void *));
458 LOAD_MPO(MPOCreate,
int (*)(
void *,
unsigned int));
459 LOAD_MPO(MPOCreateWithState,
int (*)(
void *,
unsigned int,
const double *));
460 LOAD_MPO(MPOCreateWithBasisState,
int (*)(
void *,
unsigned int,
unsigned long long));
461 LOAD_MPO(MPOCreateWithBasisStateBits,
int (*)(
void *,
unsigned int,
const unsigned char *));
462 LOAD_MPO(MPOCreateWithMixtureOfBasisStates,
int (*)(
void *,
unsigned int,
const unsigned long long *,
const double *,
int));
463 LOAD_MPO(MPOCreateWithMixtureOfBasisStatesBits,
int (*)(
void *,
unsigned int,
const unsigned char *,
const double *,
int));
464 LOAD_MPO(MPOReset,
int (*)(
void *));
465 LOAD_MPO(MPOSetInitialQubitsMap,
int (*)(
void *,
const long long int *,
int));
466 LOAD_MPO(MPOSetUseOptimalMeetingPosition,
int (*)(
void *,
int));
467 LOAD_MPO(MPOGetUseOptimalMeetingPosition,
int (*)(
void *));
468 LOAD_MPO(MPOIsValid,
int (*)(
void *));
469 LOAD_MPO(MPOIsCreated,
int (*)(
void *));
470 LOAD_MPO(MPOSetDataType,
int (*)(
void *,
int));
471 LOAD_MPO(MPOIsDoublePrecision,
int (*)(
void *));
472 LOAD_MPO(MPOGetNrQubits,
int (*)(
void *));
473 LOAD_MPO(MPOSetCutoff,
int (*)(
void *,
double));
474 LOAD_MPO(MPOGetCutoff,
double (*)(
void *));
475 LOAD_MPO(MPOSetTruncationMode,
int (*)(
void *,
int));
476 LOAD_MPO(MPOGetTruncationMode,
int (*)(
void *));
477 LOAD_MPO(MPOSetGesvdJ,
int (*)(
void *,
int));
478 LOAD_MPO(MPOGetGesvdJ,
int (*)(
void *));
480 fMPOSetGesvdP = (int (*)(
void *, int))GetFunction(
"MPOSetGesvdP");
481 fMPOGetGesvdP = (int (*)(
void *))GetFunction(
"MPOGetGesvdP");
482 fMPOSetGesvdR = (int (*)(
void *, int))GetFunction(
"MPOSetGesvdR");
483 fMPOGetGesvdR = (int (*)(
void *))GetFunction(
"MPOGetGesvdR");
484 fMPOGetLastSvdAlgo = (int (*)(
void *))GetFunction(
"MPOGetLastSvdAlgo");
486 LOAD_MPO(MPOSetMaxExtent,
int (*)(
void *,
long int));
487 LOAD_MPO(MPOGetMaxExtent,
long int (*)(
void *));
488 LOAD_MPO(MPOGetBondDimensions,
int (*)(
void *,
long long int *));
490 fMPOGetQubitsMap =
reinterpret_cast<int (*)(
void *,
long long *,
int)
>(GetFunction(
"MPOGetQubitsMap"));
491 LOAD_MPO(MPOSetCallbackContext,
int (*)(
void *,
void *));
492 LOAD_MPO(MPOSetMeetingPositionCallback,
int (*)(
void *, int64_t (*)(
void *,
const int64_t *)));
493 LOAD_MPO(MPOSetBondDimensionsCallback,
int (*)(
void *,
void (*)(
void *,
const int64_t *)));
494 LOAD_MPO(MPOSampleBits,
int (*)(
void *,
unsigned int,
unsigned int,
const int *,
unsigned char *));
495 LOAD_MPO(MPOGetMapForSample,
void *(*)());
496 LOAD_MPO(MPOFreeMapForSample,
int (*)(
void *));
497 LOAD_MPO(MPOSampleHistogram,
int (*)(
void *,
long int,
long int,
unsigned int *,
void *));
498 LOAD_MPO(MPOGetElementBits,
int (*)(
void *,
const unsigned char *,
const unsigned char *,
double *,
double *));
499 LOAD_MPO(MPOBasisStateProbabilityBits,
double (*)(
void *,
const unsigned char *));
500 LOAD_MPO(MPOExpectationValueComplex,
int (*)(
void *,
const char *,
int,
double *,
double *));
501 LOAD_MPO(MPOUnnormalizedExpectationValue,
int (*)(
void *,
const char *,
int,
double *,
double *));
502 LOAD_MPO(MPOGetDensityMatrix,
int (*)(
void *,
double *));
503 LOAD_MPO(MPOGetUnnormalizedDensityMatrix,
int (*)(
void *,
double *));
504 LOAD_MPO(MPOTraceComplex,
int (*)(
void *,
double *,
double *));
505 LOAD_MPO(MPOSetRestoreTraceAfterTruncation,
int (*)(
void *,
int));
506 LOAD_MPO(MPOGetRestoreTraceAfterTruncation,
int (*)(
void *));
507 LOAD_MPO(MPOSetHermitizeAfterTruncation,
int (*)(
void *,
int));
508 LOAD_MPO(MPOGetHermitizeAfterTruncation,
int (*)(
void *));
509 LOAD_MPO(MPOMoveAtBeginningOfChain,
int (*)(
void *,
const int *,
int));
510 LOAD_MPO(MPOApplyOperator,
int (*)(
void *,
int,
const int *,
const double *));
511 LOAD_MPO(MPOApplyOperatorAndNormalize,
int (*)(
void *,
int,
const int *,
const double *));
512 LOAD_MPO(MPOReCanonicalize,
int (*)(
void *));
513 LOAD_MPO(MPOTrim,
int (*)(
void *,
double,
long int));
514 LOAD_MPO(MPOSaveState,
int (*)(
void *));
515 LOAD_MPO(MPORestoreState,
int (*)(
void *));
516 LOAD_MPO(MPOCleanSavedState,
int (*)(
void *));
517 LOAD_MPO(MPOClone,
void *(*)(
void *));
518 LOAD_MPO(MPOSetSeed,
int (*)(
void *,
unsigned long long));
519 LOAD_MPO(MPOMeasureQubitCollapse,
int (*)(
void *,
int));
520 LOAD_MPO(MPOMeasureQubitNoCollapse,
int (*)(
void *,
int));
521 LOAD_MPO(MPOMeasureQubitsCollapse,
int (*)(
void *,
int *,
int *,
int));
522 LOAD_MPO(MPOMeasureQubitsNoCollapse,
int (*)(
void *,
int *,
int *,
int));
523 LOAD_MPO(MPOMeasureAllQubitsCollapse,
unsigned long long (*)(
void *));
524 LOAD_MPO(MPOMeasureAllQubitsNoCollapse,
unsigned long long (*)(
void *));
525 LOAD_MPO(MPOSample,
int (*)(
void *,
unsigned int,
long int *,
unsigned int,
int *));
526 LOAD_MPO(MPOSampleAll,
int (*)(
void *,
unsigned int,
long int *));
527 LOAD_MPO(MPOGetElement,
int (*)(
void *,
long long,
long long,
double *,
double *));
528 LOAD_MPO(MPOBasisStateProbability,
double (*)(
void *,
long long));
529 LOAD_MPO(MPOAllProbabilities,
int (*)(
void *,
double *));
530 LOAD_MPO(MPOExpectationValue,
double (*)(
void *,
const char *,
int));
531 LOAD_MPO(MPOQubitProbability0,
double (*)(
void *,
unsigned int));
532 LOAD_MPO(MPOPartialTrace,
int (*)(
void *,
const int *,
int,
double *));
533 LOAD_MPO(MPOHilbertSchmidtOverlap,
int (*)(
void *,
void *,
double *,
double *));
534 LOAD_MPO(MPOFidelityWithStatevector,
int (*)(
void *,
const double *,
double *));
535 LOAD_MPO(MPOTrace,
double (*)(
void *));
536 LOAD_MPO(MPOPurity,
double (*)(
void *));
537 LOAD_MPO(MPOHermiticityResidual,
double (*)(
void *));
538 LOAD_MPO(MPOIsHermitian,
int (*)(
void *,
double));
539 LOAD_MPO(MPOTraceOfSquare,
double (*)(
void *));
540 LOAD_MPO(MPORestoreTrace,
int (*)(
void *));
541 LOAD_MPO(MPOHermitize,
int (*)(
void *));
542 LOAD_MPO(MPOSetKrausCompletenessCheck,
int (*)(
void *,
int));
543 LOAD_MPO(MPOGetKrausCompletenessCheck,
int (*)(
void *));
544 LOAD_MPO(MPOApplyKraus,
int (*)(
void *,
int,
const int *,
int,
const double *));
545#define LOAD_MPO_GATE1(name) LOAD_MPO(name, int (*)(void *, int))
546#define LOAD_MPO_GATE2(name) LOAD_MPO(name, int (*)(void *, int, int))
547#define LOAD_MPO_ROT1(name) LOAD_MPO(name, int (*)(void *, int, double))
548#define LOAD_MPO_ROT2(name) LOAD_MPO(name, int (*)(void *, int, int, double))
549 LOAD_MPO_GATE1(MPOApplyReset);
550 LOAD_MPO_ROT1(MPOApplyBitFlipNoise);
551 LOAD_MPO_ROT1(MPOApplyPhaseFlipNoise);
552 LOAD_MPO_ROT1(MPOApplyDepolarizingNoise);
553 LOAD_MPO_ROT1(MPOApplyAmplitudeDamping);
554 LOAD_MPO_ROT1(MPOApplyPhaseDamping);
555 LOAD_MPO_GATE1(MPOApplyNonSelectiveMeasurement);
556 LOAD_MPO_GATE1(MPOApplyX);
557 LOAD_MPO_GATE1(MPOApplyY);
558 LOAD_MPO_GATE1(MPOApplyZ);
559 LOAD_MPO_GATE1(MPOApplyH);
560 LOAD_MPO_GATE1(MPOApplyS);
561 LOAD_MPO_GATE1(MPOApplySDG);
562 LOAD_MPO_GATE1(MPOApplyT);
563 LOAD_MPO_GATE1(MPOApplyTDG);
564 LOAD_MPO_GATE1(MPOApplySX);
565 LOAD_MPO_GATE1(MPOApplySXDG);
566 LOAD_MPO_GATE1(MPOApplyK);
567 LOAD_MPO_ROT1(MPOApplyP);
568 LOAD_MPO_ROT1(MPOApplyRx);
569 LOAD_MPO_ROT1(MPOApplyRy);
570 LOAD_MPO_ROT1(MPOApplyRz);
571 LOAD_MPO(MPOApplyU,
int (*)(
void *,
int,
double,
double,
double,
double));
572 LOAD_MPO(MPOApplyOneQubitMatrix,
int (*)(
void *,
int,
const double *));
573 LOAD_MPO(MPOApplyTwoQubitMatrix,
int (*)(
void *,
int,
int,
const double *));
574 LOAD_MPO_GATE2(MPOApplyCX);
575 LOAD_MPO_GATE2(MPOApplyCY);
576 LOAD_MPO_GATE2(MPOApplyCZ);
577 LOAD_MPO_GATE2(MPOApplyCH);
578 LOAD_MPO_GATE2(MPOApplyCSX);
579 LOAD_MPO_GATE2(MPOApplyCSXDG);
580 LOAD_MPO_ROT2(MPOApplyCP);
581 LOAD_MPO_ROT2(MPOApplyCRx);
582 LOAD_MPO_ROT2(MPOApplyCRy);
583 LOAD_MPO_ROT2(MPOApplyCRz);
584 LOAD_MPO_GATE2(MPOApplySwap);
585 LOAD_MPO(MPOApplyCU,
int (*)(
void *,
int,
int,
double,
double,
double,
double));
598 fCreateMPS = (
void *(*)(
void *))GetFunction(
"CreateMPS");
599 CheckFunction((
void *)fCreateMPS, __LINE__);
600 fDestroyMPS = (void (*)(
void *))GetFunction(
"DestroyMPS");
601 CheckFunction((
void *)fDestroyMPS, __LINE__);
603 fMPSCreate = (int (*)(
void *,
unsigned int))GetFunction(
"MPSCreate");
604 CheckFunction((
void *)fMPSCreate, __LINE__);
605 fMPSCreateWithBasisState = (int (*)(
void *,
unsigned int,
unsigned long long))GetFunction(
"MPSCreateWithBasisState");
606 CheckFunction((
void *)fMPSCreateWithBasisState, __LINE__);
607 fMPSCreateWithBasisStateBits = (int (*)(
void *,
unsigned int,
const unsigned char *))GetFunction(
"MPSCreateWithBasisStateBits");
608 CheckFunction((
void *)fMPSCreateWithBasisStateBits, __LINE__);
609 fMPSReset = (int (*)(
void *))GetFunction(
"MPSReset");
610 CheckFunction((
void *)fMPSReset, __LINE__);
611 fMPSSetInitialQubitsMap = (int (*)(
void *,
const long long int *, int))GetFunction(
"MPSSetInitialQubitsMap");
612 CheckFunction((
void *)fMPSSetInitialQubitsMap, __LINE__);
613 fMPSSetUseOptimalMeetingPosition = (int (*)(
void *, int))GetFunction(
"MPSSetUseOptimalMeetingPosition");
614 CheckFunction((
void *)fMPSSetUseOptimalMeetingPosition, __LINE__);
615 fMPSGetUseOptimalMeetingPosition = (int (*)(
void *))GetFunction(
"MPSGetUseOptimalMeetingPosition");
616 CheckFunction((
void *)fMPSGetUseOptimalMeetingPosition, __LINE__);
618 fMPSIsValid = (int (*)(
void *))GetFunction(
"MPSIsValid");
619 CheckFunction((
void *)fMPSIsValid, __LINE__);
620 fMPSIsCreated = (int (*)(
void *))GetFunction(
"MPSIsCreated");
621 CheckFunction((
void *)fMPSIsCreated, __LINE__);
623 fMPSSetDataType = (int (*)(
void *, int))GetFunction(
"MPSSetDataType");
624 CheckFunction((
void *)fMPSSetDataType, __LINE__);
625 fMPSIsDoublePrecision = (int (*)(
void *))GetFunction(
"MPSIsDoublePrecision");
626 CheckFunction((
void *)fMPSIsDoublePrecision, __LINE__);
627 fMPSSetCutoff = (int (*)(
void *, double))GetFunction(
"MPSSetCutoff");
628 CheckFunction((
void *)fMPSSetCutoff, __LINE__);
629 fMPSGetCutoff = (double (*)(
void *))GetFunction(
"MPSGetCutoff");
630 CheckFunction((
void *)fMPSGetCutoff, __LINE__);
631 fMPSSetTruncationMode = (int (*)(
void *, int))GetFunction(
"MPSSetTruncationMode");
632 CheckFunction((
void *)fMPSSetTruncationMode, __LINE__);
633 fMPSGetTruncationMode = (int (*)(
void *))GetFunction(
"MPSGetTruncationMode");
634 CheckFunction((
void *)fMPSGetTruncationMode, __LINE__);
635 fMPSSetGesvdJ = (int (*)(
void *, int))GetFunction(
"MPSSetGesvdJ");
636 CheckFunction((
void *)fMPSSetGesvdJ, __LINE__);
637 fMPSGetGesvdJ = (int (*)(
void *))GetFunction(
"MPSGetGesvdJ");
638 CheckFunction((
void *)fMPSGetGesvdJ, __LINE__);
640 fMPSSetGesvdP = (int (*)(
void *, int))GetFunction(
"MPSSetGesvdP");
641 fMPSGetGesvdP = (int (*)(
void *))GetFunction(
"MPSGetGesvdP");
642 fMPSSetGesvdR = (int (*)(
void *, int))GetFunction(
"MPSSetGesvdR");
643 fMPSGetGesvdR = (int (*)(
void *))GetFunction(
"MPSGetGesvdR");
644 fMPSGetLastSvdAlgo = (int (*)(
void *))GetFunction(
"MPSGetLastSvdAlgo");
646 fMPSSetMaxExtent = (int (*)(
void *,
long int))GetFunction(
"MPSSetMaxExtent");
647 CheckFunction((
void *)fMPSSetMaxExtent, __LINE__);
648 fMPSGetMaxExtent = (
long int (*)(
void *))GetFunction(
"MPSGetMaxExtent");
649 CheckFunction((
void *)fMPSGetMaxExtent, __LINE__);
650 fMPSGetNrQubits = (int (*)(
void *))GetFunction(
"MPSGetNrQubits");
651 CheckFunction((
void *)fMPSGetNrQubits, __LINE__);
652 fMPSGetBondDimensions = (int (*)(
void *,
long long int *))GetFunction(
"MPSGetBondDimensions");
653 CheckFunction((
void *)fMPSGetBondDimensions, __LINE__);
655 fMPSGetQubitsMap =
reinterpret_cast<int (*)(
void *,
long long *,
int)
>(GetFunction(
"MPSGetQubitsMap"));
656 fMPSSetCallbackContext = (int (*)(
void *,
void *))GetFunction(
"MPSSetCallbackContext");
657 CheckFunction((
void *)fMPSSetCallbackContext, __LINE__);
659 fMPSSetMeetingPositionCallback = (int (*)(
void *, int64_t (*)(
void *,
const int64_t *)))GetFunction(
"MPSSetMeetingPositionCallback");
660 CheckFunction((
void *)fMPSSetMeetingPositionCallback, __LINE__);
662 fMPSSetBondDimensionsCallback = (int (*)(
void *, void (*)(
void *,
const int64_t *)))GetFunction(
"MPSSetBondDimensionsCallback");
663 CheckFunction((
void *)fMPSSetBondDimensionsCallback, __LINE__);
665 fMPSAmplitude = (int (*)(
void *,
long int,
long int *,
double *,
double *))GetFunction(
"MPSAmplitude");
666 CheckFunction((
void *)fMPSAmplitude, __LINE__);
667 fMPSProbability0 = (double (*)(
void *,
unsigned int))GetFunction(
"MPSProbability0");
668 CheckFunction((
void *)fMPSProbability0, __LINE__);
669 fMPSMeasure = (int (*)(
void *,
unsigned int))GetFunction(
"MPSMeasure");
670 CheckFunction((
void *)fMPSMeasure, __LINE__);
671 fMPSMeasureQubits = (int (*)(
void *,
long int,
unsigned int *,
int *))GetFunction(
"MPSMeasureQubits");
672 CheckFunction((
void *)fMPSMeasureQubits, __LINE__);
674 fMPSGetMapForSample = (
void *(*)())GetFunction(
"MPSGetMapForSample");
675 CheckFunction((
void *)fMPSGetMapForSample, __LINE__);
676 fMPSFreeMapForSample = (int (*)(
void *))GetFunction(
"MPSFreeMapForSample");
677 CheckFunction((
void *)fMPSFreeMapForSample, __LINE__);
678 fMPSSample = (int (*)(
void *,
long int,
long int,
unsigned int *,
void *))GetFunction(
"MPSSample");
679 CheckFunction((
void *)fMPSSample, __LINE__);
680 fMPSSampleRaw = (int (*)(
void *,
unsigned int,
long int *,
unsigned int,
const unsigned int *))GetFunction(
"MPSSampleRaw");
681 CheckFunction((
void *)fMPSSampleRaw, __LINE__);
682 fMPSSampleAll = (int (*)(
void *,
unsigned int,
long int *))GetFunction(
"MPSSampleAll");
683 CheckFunction((
void *)fMPSSampleAll, __LINE__);
685 fMPSSaveState = (int (*)(
void *))GetFunction(
"MPSSaveState");
686 CheckFunction((
void *)fMPSSaveState, __LINE__);
687 fMPSRestoreState = (int (*)(
void *))GetFunction(
"MPSRestoreState");
688 CheckFunction((
void *)fMPSRestoreState, __LINE__);
689 fMPSCleanSavedState = (int (*)(
void *))GetFunction(
"MPSCleanSavedState");
690 CheckFunction((
void *)fMPSCleanSavedState, __LINE__);
691 fMPSClone = (
void *(*)(
void *))GetFunction(
"MPSClone");
692 CheckFunction((
void *)fMPSClone, __LINE__);
693 fMPSSetSeed = (int (*)(
void *,
unsigned long long))GetFunction(
"MPSSetSeed");
694 CheckFunction((
void *)fMPSSetSeed, __LINE__);
696 fMPSExpectationValue = (double (*)(
void *,
const char *, int))GetFunction(
"MPSExpectationValue");
697 CheckFunction((
void *)fMPSExpectationValue, __LINE__);
698 fMPSProjectOnZero = (int (*)(
void *,
double *,
double *))GetFunction(
"MPSProjectOnZero");
699 CheckFunction((
void *)fMPSProjectOnZero, __LINE__);
701 fMPSApplyX = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyX");
702 CheckFunction((
void *)fMPSApplyX, __LINE__);
703 fMPSApplyY = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyY");
704 CheckFunction((
void *)fMPSApplyY, __LINE__);
705 fMPSApplyZ = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyZ");
706 CheckFunction((
void *)fMPSApplyZ, __LINE__);
707 fMPSApplyH = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyH");
708 CheckFunction((
void *)fMPSApplyH, __LINE__);
709 fMPSApplyS = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyS");
710 CheckFunction((
void *)fMPSApplyS, __LINE__);
711 fMPSApplySDG = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySDG");
712 CheckFunction((
void *)fMPSApplySDG, __LINE__);
713 fMPSApplyT = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyT");
714 CheckFunction((
void *)fMPSApplyT, __LINE__);
715 fMPSApplyTDG = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyTDG");
716 CheckFunction((
void *)fMPSApplyTDG, __LINE__);
717 fMPSApplySX = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySX");
718 CheckFunction((
void *)fMPSApplySX, __LINE__);
719 fMPSApplySXDG = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySXDG");
720 CheckFunction((
void *)fMPSApplySXDG, __LINE__);
721 fMPSApplyK = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyK");
722 CheckFunction((
void *)fMPSApplyK, __LINE__);
723 fMPSApplyP = (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyP");
724 CheckFunction((
void *)fMPSApplyP, __LINE__);
725 fMPSApplyRx = (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRx");
726 CheckFunction((
void *)fMPSApplyRx, __LINE__);
727 fMPSApplyRy = (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRy");
728 CheckFunction((
void *)fMPSApplyRy, __LINE__);
729 fMPSApplyRz = (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRz");
730 CheckFunction((
void *)fMPSApplyRz, __LINE__);
731 fMPSApplyU = (int (*)(
void *,
unsigned int, double, double, double, double))GetFunction(
"MPSApplyU");
732 CheckFunction((
void *)fMPSApplyU, __LINE__);
733 fMPSApplyOneQubitMatrix = (int (*)(
void *,
unsigned int,
const double *))GetFunction(
"MPSApplyOneQubitMatrix");
734 CheckFunction((
void *)fMPSApplyOneQubitMatrix, __LINE__);
735 fMPSApplyTwoQubitMatrix = (int (*)(
void *,
unsigned int,
unsigned int,
const double *))GetFunction(
"MPSApplyTwoQubitMatrix");
736 CheckFunction((
void *)fMPSApplyTwoQubitMatrix, __LINE__);
737 fMPSApplySwap = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"MPSApplySwap");
738 CheckFunction((
void *)fMPSApplySwap, __LINE__);
739 fMPSApplyCX = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"MPSApplyCX");
740 CheckFunction((
void *)fMPSApplyCX, __LINE__);
741 fMPSApplyCY = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"MPSApplyCY");
742 CheckFunction((
void *)fMPSApplyCY, __LINE__);
743 fMPSApplyCZ = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"MPSApplyCZ");
744 CheckFunction((
void *)fMPSApplyCZ, __LINE__);
745 fMPSApplyCH = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"MPSApplyCH");
746 CheckFunction((
void *)fMPSApplyCH, __LINE__);
747 fMPSApplyCSX = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"MPSApplyCSX");
748 CheckFunction((
void *)fMPSApplyCSX, __LINE__);
749 fMPSApplyCSXDG = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"MPSApplyCSXDG");
750 CheckFunction((
void *)fMPSApplyCSXDG, __LINE__);
751 fMPSApplyCP = (int (*)(
void *,
unsigned int,
unsigned int, double))GetFunction(
"MPSApplyCP");
752 CheckFunction((
void *)fMPSApplyCP, __LINE__);
753 fMPSApplyCRx = (int (*)(
void *,
unsigned int,
unsigned int, double))GetFunction(
"MPSApplyCRx");
754 CheckFunction((
void *)fMPSApplyCRx, __LINE__);
755 fMPSApplyCRy = (int (*)(
void *,
unsigned int,
unsigned int, double))GetFunction(
"MPSApplyCRy");
756 CheckFunction((
void *)fMPSApplyCRy, __LINE__);
757 fMPSApplyCRz = (int (*)(
void *,
unsigned int,
unsigned int, double))GetFunction(
"MPSApplyCRz");
758 CheckFunction((
void *)fMPSApplyCRz, __LINE__);
759 fMPSApplyCU = (int (*)(
void *,
unsigned int,
unsigned int, double, double, double, double))GetFunction(
"MPSApplyCU");
760 CheckFunction((
void *)fMPSApplyCU, __LINE__);
764 fCreateTensorNet = (
void *(*)(
void *))GetFunction(
"CreateTensorNet");
765 CheckFunction((
void *)fCreateTensorNet, __LINE__);
766 fDestroyTensorNet = (void (*)(
void *))GetFunction(
"DestroyTensorNet");
767 CheckFunction((
void *)fDestroyTensorNet, __LINE__);
769 fTNCreate = (int (*)(
void *,
unsigned int))GetFunction(
"TNCreate");
770 CheckFunction((
void *)fTNCreate, __LINE__);
771 fTNReset = (int (*)(
void *))GetFunction(
"TNReset");
772 CheckFunction((
void *)fTNReset, __LINE__);
774 fTNIsValid = (int (*)(
void *))GetFunction(
"TNIsValid");
775 CheckFunction((
void *)fTNIsValid, __LINE__);
776 fTNIsCreated = (int (*)(
void *))GetFunction(
"TNIsCreated");
777 CheckFunction((
void *)fTNIsCreated, __LINE__);
779 fTNSetDataType = (int (*)(
void *, int))GetFunction(
"TNSetDataType");
780 CheckFunction((
void *)fTNSetDataType, __LINE__);
781 fTNIsDoublePrecision = (int (*)(
void *))GetFunction(
"TNIsDoublePrecision");
782 CheckFunction((
void *)fTNIsDoublePrecision, __LINE__);
783 fTNSetCutoff = (int (*)(
void *, double))GetFunction(
"TNSetCutoff");
784 CheckFunction((
void *)fTNSetCutoff, __LINE__);
785 fTNGetCutoff = (double (*)(
void *))GetFunction(
"TNGetCutoff");
786 CheckFunction((
void *)fTNGetCutoff, __LINE__);
787 fTNSetTruncationMode = (int (*)(
void *, int))GetFunction(
"TNSetTruncationMode");
788 CheckFunction((
void *)fTNSetTruncationMode, __LINE__);
789 fTNGetTruncationMode = (int (*)(
void *))GetFunction(
"TNGetTruncationMode");
790 CheckFunction((
void *)fTNGetTruncationMode, __LINE__);
791 fTNSetGesvdJ = (int (*)(
void *, int))GetFunction(
"TNSetGesvdJ");
792 CheckFunction((
void *)fTNSetGesvdJ, __LINE__);
793 fTNGetGesvdJ = (int (*)(
void *))GetFunction(
"TNGetGesvdJ");
794 CheckFunction((
void *)fTNGetGesvdJ, __LINE__);
796 fTNSetGesvdP = (int (*)(
void *, int))GetFunction(
"TNSetGesvdP");
797 fTNGetGesvdP = (int (*)(
void *))GetFunction(
"TNGetGesvdP");
798 fTNSetGesvdR = (int (*)(
void *, int))GetFunction(
"TNSetGesvdR");
799 fTNGetGesvdR = (int (*)(
void *))GetFunction(
"TNGetGesvdR");
801 fTNSetMaxExtent = (int (*)(
void *,
long int))GetFunction(
"TNSetMaxExtent");
802 CheckFunction((
void *)fTNSetMaxExtent, __LINE__);
803 fTNGetMaxExtent = (
long int (*)(
void *))GetFunction(
"TNGetMaxExtent");
804 CheckFunction((
void *)fTNGetMaxExtent, __LINE__);
805 fTNGetNrQubits = (int (*)(
void *))GetFunction(
"TNGetNrQubits");
806 CheckFunction((
void *)fTNGetNrQubits, __LINE__);
807 fTNAmplitude = (int (*)(
void *,
long int,
long int *,
double *,
double *))GetFunction(
"TNAmplitude");
808 CheckFunction((
void *)fTNAmplitude, __LINE__);
809 fTNProbability0 = (double (*)(
void *,
unsigned int))GetFunction(
"TNProbability0");
810 CheckFunction((
void *)fTNProbability0, __LINE__);
811 fTNMeasure = (int (*)(
void *,
unsigned int))GetFunction(
"TNMeasure");
812 CheckFunction((
void *)fTNMeasure, __LINE__);
813 fTNMeasureQubits = (int (*)(
void *,
long int,
unsigned int *,
int *))GetFunction(
"TNMeasureQubits");
814 CheckFunction((
void *)fTNMeasureQubits, __LINE__);
816 fTNGetMapForSample = (
void *(*)())GetFunction(
"TNGetMapForSample");
817 CheckFunction((
void *)fTNGetMapForSample, __LINE__);
818 fTNFreeMapForSample = (int (*)(
void *))GetFunction(
"TNFreeMapForSample");
819 CheckFunction((
void *)fTNFreeMapForSample, __LINE__);
820 fTNSample = (int (*)(
void *,
long int,
long int,
unsigned int *,
void *))GetFunction(
"TNSample");
821 CheckFunction((
void *)fTNSample, __LINE__);
823 fTNSaveState = (int (*)(
void *))GetFunction(
"TNSaveState");
824 CheckFunction((
void *)fTNSaveState, __LINE__);
825 fTNRestoreState = (int (*)(
void *))GetFunction(
"TNRestoreState");
826 CheckFunction((
void *)fTNRestoreState, __LINE__);
827 fTNCleanSavedState = (int (*)(
void *))GetFunction(
"TNCleanSavedState");
828 CheckFunction((
void *)fTNCleanSavedState, __LINE__);
829 fTNClone = (
void *(*)(
void *))GetFunction(
"TNClone");
830 CheckFunction((
void *)fTNClone, __LINE__);
831 fTNSetSeed = (int (*)(
void *,
unsigned long long))GetFunction(
"TNSetSeed");
832 CheckFunction((
void *)fTNSetSeed, __LINE__);
834 fTNExpectationValue = (double (*)(
void *,
const char *, int))GetFunction(
"TNExpectationValue");
835 CheckFunction((
void *)fTNExpectationValue, __LINE__);
837 fTNApplyX = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyX");
838 CheckFunction((
void *)fTNApplyX, __LINE__);
839 fTNApplyY = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyY");
840 CheckFunction((
void *)fTNApplyY, __LINE__);
841 fTNApplyZ = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyZ");
842 CheckFunction((
void *)fTNApplyZ, __LINE__);
843 fTNApplyH = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyH");
844 CheckFunction((
void *)fTNApplyH, __LINE__);
845 fTNApplyS = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyS");
846 CheckFunction((
void *)fTNApplyS, __LINE__);
847 fTNApplySDG = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplySDG");
848 CheckFunction((
void *)fTNApplySDG, __LINE__);
849 fTNApplyT = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyT");
850 CheckFunction((
void *)fTNApplyT, __LINE__);
851 fTNApplyTDG = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyTDG");
852 CheckFunction((
void *)fTNApplyTDG, __LINE__);
853 fTNApplySX = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplySX");
854 CheckFunction((
void *)fTNApplySX, __LINE__);
855 fTNApplySXDG = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplySXDG");
856 CheckFunction((
void *)fTNApplySXDG, __LINE__);
857 fTNApplyK = (int (*)(
void *,
unsigned int))GetFunction(
"TNApplyK");
858 CheckFunction((
void *)fTNApplyK, __LINE__);
859 fTNApplyP = (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyP");
860 CheckFunction((
void *)fTNApplyP, __LINE__);
861 fTNApplyRx = (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyRx");
862 CheckFunction((
void *)fTNApplyRx, __LINE__);
863 fTNApplyRy = (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyRy");
864 CheckFunction((
void *)fTNApplyRy, __LINE__);
865 fTNApplyRz = (int (*)(
void *,
unsigned int, double))GetFunction(
"TNApplyRz");
866 CheckFunction((
void *)fTNApplyRz, __LINE__);
867 fTNApplyU = (int (*)(
void *,
unsigned int, double, double, double, double))GetFunction(
"TNApplyU");
868 CheckFunction((
void *)fTNApplyU, __LINE__);
869 fTNApplySwap = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"TNApplySwap");
870 CheckFunction((
void *)fTNApplySwap, __LINE__);
871 fTNApplyCX = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"TNApplyCX");
872 CheckFunction((
void *)fTNApplyCX, __LINE__);
873 fTNApplyCY = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"TNApplyCY");
874 CheckFunction((
void *)fTNApplyCY, __LINE__);
875 fTNApplyCZ = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"TNApplyCZ");
876 CheckFunction((
void *)fTNApplyCZ, __LINE__);
877 fTNApplyCH = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"TNApplyCH");
878 CheckFunction((
void *)fTNApplyCH, __LINE__);
879 fTNApplyCSX = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"TNApplyCSX");
880 CheckFunction((
void *)fTNApplyCSX, __LINE__);
881 fTNApplyCSXDG = (int (*)(
void *,
unsigned int,
unsigned int))GetFunction(
"TNApplyCSXDG");
882 CheckFunction((
void *)fTNApplyCSXDG, __LINE__);
883 fTNApplyCP = (int (*)(
void *,
unsigned int,
unsigned int, double))GetFunction(
"TNApplyCP");
884 CheckFunction((
void *)fTNApplyCP, __LINE__);
885 fTNApplyCRx = (int (*)(
void *,
unsigned int,
unsigned int, double))GetFunction(
"TNApplyCRx");
886 CheckFunction((
void *)fTNApplyCRx, __LINE__);
887 fTNApplyCRy = (int (*)(
void *,
unsigned int,
unsigned int, double))GetFunction(
"TNApplyCRy");
888 CheckFunction((
void *)fTNApplyCRy, __LINE__);
889 fTNApplyCRz = (int (*)(
void *,
unsigned int,
unsigned int, double))GetFunction(
"TNApplyCRz");
890 CheckFunction((
void *)fTNApplyCRz, __LINE__);
891 fTNApplyCU = (int (*)(
void *,
unsigned int,
unsigned int, double, double, double, double))GetFunction(
"TNApplyCU");
892 CheckFunction((
void *)fTNApplyCU, __LINE__);
894 fTNApplyCCX = (int (*)(
void *,
unsigned int,
unsigned int,
unsigned int))GetFunction(
"TNApplyCCX");
895 CheckFunction((
void *)fTNApplyCCX, __LINE__);
896 fTNApplyCSwap = (int (*)(
void *,
unsigned int,
unsigned int,
unsigned int))GetFunction(
"TNApplyCSwap");
897 CheckFunction((
void *)fTNApplyCSwap, __LINE__);
900 fCreateStabilizerSimulator =
901 (
void *(*)(
long long int,
long long int,
long long int,
long long int))GetFunction(
"CreateStabilizerSimulator");
902 CheckFunction((
void *)fCreateStabilizerSimulator, __LINE__);
903 fDestroyStabilizerSimulator = (void (*)(
void *))GetFunction(
"DestroyStabilizerSimulator");
904 CheckFunction((
void *)fDestroyStabilizerSimulator, __LINE__);
905 fExecuteStabilizerCircuit = (int (*)(
void *,
const char *, int,
unsigned long long int))GetFunction(
"ExecuteStabilizerCircuit");
906 CheckFunction((
void *)fExecuteStabilizerCircuit, __LINE__);
907 fGetStabilizerXZTableSize = (
long long (*)(
void *))GetFunction(
"GetStabilizerXZTableSize");
908 CheckFunction((
void *)fGetStabilizerXZTableSize, __LINE__);
909 fGetStabilizerMTableSize = (
long long (*)(
void *))GetFunction(
"GetStabilizerMTableSize");
910 CheckFunction((
void *)fGetStabilizerMTableSize, __LINE__);
912 fGetStabilizerTableStrideMajor = (
long long (*)(
void *))GetFunction(
"GetStabilizerTableStrideMajor");
913 CheckFunction((
void *)fGetStabilizerTableStrideMajor, __LINE__);
915 fGetStabilizerNumQubits = (
long long (*)(
void *))GetFunction(
"GetStabilizerNumQubits");
916 CheckFunction((
void *)fGetStabilizerNumQubits, __LINE__);
917 fGetStabilizerNumShots = (
long long (*)(
void *))GetFunction(
"GetStabilizerNumShots");
918 CheckFunction((
void *)fGetStabilizerNumShots, __LINE__);
919 fGetStabilizerNumMeasurements = (
long long (*)(
void *))GetFunction(
"GetStabilizerNumMeasurements");
920 CheckFunction((
void *)fGetStabilizerNumMeasurements, __LINE__);
921 fGetStabilizerNumDetectors = (
long long (*)(
void *))GetFunction(
"GetStabilizerNumDetectors");
922 CheckFunction((
void *)fGetStabilizerNumDetectors, __LINE__);
923 fCopyStabilizerXTable = (int (*)(
void *,
unsigned int *))GetFunction(
"CopyStabilizerXTable");
924 CheckFunction((
void *)fCopyStabilizerXTable, __LINE__);
925 fCopyStabilizerZTable = (int (*)(
void *,
unsigned int *))GetFunction(
"CopyStabilizerZTable");
926 CheckFunction((
void *)fCopyStabilizerZTable, __LINE__);
927 fCopyStabilizerMTable = (int (*)(
void *,
unsigned int *))GetFunction(
"CopyStabilizerMTable");
928 CheckFunction((
void *)fCopyStabilizerMTable, __LINE__);
930 fInitStabilizerXTable = (int (*)(
void *,
const unsigned int *))GetFunction(
"InitXTable");
931 CheckFunction((
void *)fInitStabilizerXTable, __LINE__);
932 fInitStabilizerZTable = (int (*)(
void *,
const unsigned int *))GetFunction(
"InitZTable");
933 CheckFunction((
void *)fInitStabilizerZTable, __LINE__);
936 fCreatePauliPropSimulator = (
void *(*)(
int))GetFunction(
"CreatePauliPropSimulator");
937 CheckFunction((
void *)fCreatePauliPropSimulator, __LINE__);
938 fDestroyPauliPropSimulator = (void (*)(
void *))GetFunction(
"DestroyPauliPropSimulator");
939 CheckFunction((
void *)fDestroyPauliPropSimulator, __LINE__);
941 fPauliPropGetNrQubits = (int (*)(
void *))GetFunction(
"PauliPropGetNrQubits");
942 CheckFunction((
void *)fPauliPropGetNrQubits, __LINE__);
943 fPauliPropSetWillUseSampling = (int (*)(
void *, int))GetFunction(
"PauliPropSetWillUseSampling");
944 CheckFunction((
void *)fPauliPropSetWillUseSampling, __LINE__);
945 fPauliPropGetWillUseSampling = (int (*)(
void *))GetFunction(
"PauliPropGetWillUseSampling");
946 CheckFunction((
void *)fPauliPropGetWillUseSampling, __LINE__);
948 fPauliPropGetCoefficientTruncationCutoff = (double (*)(
void *))GetFunction(
"PauliPropGetCoefficientTruncationCutoff");
949 CheckFunction((
void *)fPauliPropGetCoefficientTruncationCutoff, __LINE__);
950 fPauliPropSetCoefficientTruncationCutoff = (void (*)(
void *, double))GetFunction(
"PauliPropSetCoefficientTruncationCutoff");
951 CheckFunction((
void *)fPauliPropSetCoefficientTruncationCutoff, __LINE__);
952 fPauliPropGetWeightTruncationCutoff = (double (*)(
void *))GetFunction(
"PauliPropGetWeightTruncationCutoff");
953 CheckFunction((
void *)fPauliPropGetWeightTruncationCutoff, __LINE__);
954 fPauliPropSetWeightTruncationCutoff = (void (*)(
void *, double))GetFunction(
"PauliPropSetWeightTruncationCutoff");
955 CheckFunction((
void *)fPauliPropSetWeightTruncationCutoff, __LINE__);
956 fPauliPropGetNumGatesBetweenTruncations = (int (*)(
void *))GetFunction(
"PauliPropGetNumGatesBetweenTruncations");
957 CheckFunction((
void *)fPauliPropGetNumGatesBetweenTruncations, __LINE__);
958 fPauliPropSetNumGatesBetweenTruncations = (void (*)(
void *, int))GetFunction(
"PauliPropSetNumGatesBetweenTruncations");
959 CheckFunction((
void *)fPauliPropSetNumGatesBetweenTruncations, __LINE__);
960 fPauliPropGetNumGatesBetweenDeduplications = (int (*)(
void *))GetFunction(
"PauliPropGetNumGatesBetweenDeduplications");
961 CheckFunction((
void *)fPauliPropGetNumGatesBetweenDeduplications, __LINE__);
962 fPauliPropSetNumGatesBetweenDeduplications = (void (*)(
void *, int))GetFunction(
"PauliPropSetNumGatesBetweenDeduplications");
963 CheckFunction((
void *)fPauliPropSetNumGatesBetweenDeduplications, __LINE__);
965 fPauliPropClearOperators = (int (*)(
void *))GetFunction(
"PauliPropClearOperators");
966 CheckFunction((
void *)fPauliPropClearOperators, __LINE__);
967 fPauliPropAllocateMemory = (int (*)(
void *, double))GetFunction(
"PauliPropAllocateMemory");
968 CheckFunction((
void *)fPauliPropAllocateMemory, __LINE__);
970 fPauliPropGetExpectationValue = (double (*)(
void *))GetFunction(
"PauliPropGetExpectationValue");
971 CheckFunction((
void *)fPauliPropGetExpectationValue, __LINE__);
972 fPauliPropExecute = (int (*)(
void *))GetFunction(
"PauliPropExecute");
973 CheckFunction((
void *)fPauliPropExecute, __LINE__);
974 fPauliPropSetSeed = (int (*)(
void *,
unsigned long long))GetFunction(
"PauliPropSetSeed");
975 CheckFunction((
void *)fPauliPropSetSeed, __LINE__);
976 fPauliPropSetInPauliExpansionUnique = (int (*)(
void *,
const char *))GetFunction(
"PauliPropSetInPauliExpansionUnique");
977 CheckFunction((
void *)fPauliPropSetInPauliExpansionUnique, __LINE__);
978 fPauliPropSetInPauliExpansionMultiple =
979 (int (*)(
void *,
const char **,
const double *, int))GetFunction(
"PauliPropSetInPauliExpansionMultiple");
980 CheckFunction((
void *)fPauliPropSetInPauliExpansionMultiple, __LINE__);
982 fPauliPropApplyX = (int (*)(
void *, int))GetFunction(
"PauliPropApplyX");
983 CheckFunction((
void *)fPauliPropApplyX, __LINE__);
984 fPauliPropApplyY = (int (*)(
void *, int))GetFunction(
"PauliPropApplyY");
985 CheckFunction((
void *)fPauliPropApplyY, __LINE__);
986 fPauliPropApplyZ = (int (*)(
void *, int))GetFunction(
"PauliPropApplyZ");
987 CheckFunction((
void *)fPauliPropApplyZ, __LINE__);
988 fPauliPropApplyH = (int (*)(
void *, int))GetFunction(
"PauliPropApplyH");
989 CheckFunction((
void *)fPauliPropApplyH, __LINE__);
990 fPauliPropApplyS = (int (*)(
void *, int))GetFunction(
"PauliPropApplyS");
991 CheckFunction((
void *)fPauliPropApplyS, __LINE__);
993 fPauliPropApplySQRTX = (int (*)(
void *, int))GetFunction(
"PauliPropApplySQRTX");
994 CheckFunction((
void *)fPauliPropApplySQRTX, __LINE__);
995 fPauliPropApplySQRTY = (int (*)(
void *, int))GetFunction(
"PauliPropApplySQRTY");
996 CheckFunction((
void *)fPauliPropApplySQRTY, __LINE__);
997 fPauliPropApplySQRTZ = (int (*)(
void *, int))GetFunction(
"PauliPropApplySQRTZ");
998 CheckFunction((
void *)fPauliPropApplySQRTZ, __LINE__);
999 fPauliPropApplyCX = (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyCX");
1000 CheckFunction((
void *)fPauliPropApplyCX, __LINE__);
1001 fPauliPropApplyCY = (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyCY");
1002 CheckFunction((
void *)fPauliPropApplyCY, __LINE__);
1003 fPauliPropApplyCZ = (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyCZ");
1004 CheckFunction((
void *)fPauliPropApplyCZ, __LINE__);
1005 fPauliPropApplySWAP = (int (*)(
void *, int, int))GetFunction(
"PauliPropApplySWAP");
1006 CheckFunction((
void *)fPauliPropApplySWAP, __LINE__);
1007 fPauliPropApplyISWAP = (int (*)(
void *, int, int))GetFunction(
"PauliPropApplyISWAP");
1008 CheckFunction((
void *)fPauliPropApplyISWAP, __LINE__);
1009 fPauliPropApplyRX = (int (*)(
void *, int, double))GetFunction(
"PauliPropApplyRX");
1010 CheckFunction((
void *)fPauliPropApplyRX, __LINE__);
1011 fPauliPropApplyRY = (int (*)(
void *, int, double))GetFunction(
"PauliPropApplyRY");
1012 CheckFunction((
void *)fPauliPropApplyRY, __LINE__);
1013 fPauliPropApplyRZ = (int (*)(
void *, int, double))GetFunction(
"PauliPropApplyRZ");
1014 CheckFunction((
void *)fPauliPropApplyRZ, __LINE__);
1016 fPauliPropAddNoiseX = (int (*)(
void *, int, double))GetFunction(
"PauliPropAddNoiseX");
1017 CheckFunction((
void *)fPauliPropAddNoiseX, __LINE__);
1018 fPauliPropAddNoiseY = (int (*)(
void *, int, double))GetFunction(
"PauliPropAddNoiseY");
1019 CheckFunction((
void *)fPauliPropAddNoiseY, __LINE__);
1020 fPauliPropAddNoiseZ = (int (*)(
void *, int, double))GetFunction(
"PauliPropAddNoiseZ");
1021 CheckFunction((
void *)fPauliPropAddNoiseZ, __LINE__);
1022 fPauliPropAddNoiseXYZ = (int (*)(
void *, int, double, double, double))GetFunction(
"PauliPropAddNoiseXYZ");
1023 CheckFunction((
void *)fPauliPropAddNoiseXYZ, __LINE__);
1024 fPauliPropAddAmplitudeDamping = (int (*)(
void *, int, double, double))GetFunction(
"PauliPropAddAmplitudeDamping");
1025 CheckFunction((
void *)fPauliPropAddAmplitudeDamping, __LINE__);
1026 fPauliPropQubitProbability0 = (double (*)(
void *, int))GetFunction(
"PauliPropQubitProbability0");
1027 CheckFunction((
void *)fPauliPropQubitProbability0, __LINE__);
1028 fPauliPropProbability = (double (*)(
void *,
unsigned long long int))GetFunction(
"PauliPropProbability");
1029 CheckFunction((
void *)fPauliPropProbability, __LINE__);
1031 fPauliPropMeasureQubit = (int (*)(
void *, int))GetFunction(
"PauliPropMeasureQubit");
1032 CheckFunction((
void *)fPauliPropMeasureQubit, __LINE__);
1034 fPauliPropSampleQubits = (
unsigned char *(*)(
void *,
const int *,
int))GetFunction(
"PauliPropSampleQubits");
1035 CheckFunction((
void *)fPauliPropSampleQubits, __LINE__);
1036 fPauliPropFreeSampledQubits = (void (*)(
unsigned char *))GetFunction(
"PauliPropFreeSampledQubits");
1037 CheckFunction((
void *)fPauliPropFreeSampledQubits, __LINE__);
1038 fPauliPropSaveState = (void (*)(
void *))GetFunction(
"PauliPropSaveState");
1039 CheckFunction((
void *)fPauliPropSaveState, __LINE__);
1040 fPauliPropRestoreState = (void (*)(
void *))GetFunction(
"PauliPropRestoreState");
1041 CheckFunction((
void *)fPauliPropRestoreState, __LINE__);
1047 initializationFailed =
true;
1048 ReportUnavailable(
"initialization failed");
1051 else if (!IsMuted())
1052 std::cerr <<
"GpuLibrary: Unable to get initialization function for "
1060 void CheckFunction(
void *func,
int line)
const
1062 if (!func && !IsMuted())
1064 std::cerr <<
"GpuLibrary: Unable to load function, line #: " << line;
1065 const char *dlsym_error = dlerror();
1067 std::cerr <<
", error: " << dlsym_error;
1069 std::cerr << std::endl;
1073 bool IsValid()
const
1075 return LibraryHandle !=
nullptr;
1078 void ReportUnavailable(
const char *operation)
const
1080 const char *detail = fGetLicenseError ? fGetLicenseError() :
nullptr;
1081 std::cerr <<
"GpuLibrary: GPU backend unavailable: " << operation;
1082 if (detail && *detail)
1083 std::cerr <<
": " << detail;
1084 std::cerr << std::endl;
1090 int GetGpuDeviceCount()
const
1092 return fGetGpuDeviceCount ? fGetGpuDeviceCount() : 0;
1097 bool SetGpuDevice(
int device)
1099 auto lock = LockInitialization();
1100 if (device < 0 || !fSetGpuDevice || !fSetGpuDevice(device))
1102 creationDevice = device;
1106 int GetCreationDevice()
const
1108 return creationDevice;
1111 int GetStateVectorGpuId(
void *obj)
const
1113 return obj && fGetStateVectorGpuId ? fGetStateVectorGpuId(obj) : -1;
1118 bool StateVectorSynchronize(
void *obj)
const
1120 return !obj || !fStateVectorSynchronize || fStateVectorSynchronize(obj) == 1;
1123 bool DMSynchronize(
void *obj)
const
1125 return !obj || !fDMSynchronize || fDMSynchronize(obj) == 1;
1128 int MPSGetGpuId(
void *obj)
const
1130 return obj && fMPSGetGpuId ? fMPSGetGpuId(obj) : -1;
1133 int TNGetGpuId(
void *obj)
const
1135 return obj && fTNGetGpuId ? fTNGetGpuId(obj) : -1;
1138 int DMGetGpuId(
void *obj)
const
1140 return obj && fDMGetGpuId ? fDMGetGpuId(obj) : -1;
1143 int MPOGetGpuId(
void *obj)
const
1145 return obj && fMPOGetGpuId ? fMPOGetGpuId(obj) : -1;
1148 int GetStabilizerGpuId(
void *obj)
const
1150 return obj && fGetStabilizerGpuId ? fGetStabilizerGpuId(obj) : -1;
1153 int PauliPropGetGpuId(
void *obj)
const
1155 return obj && fPauliPropGetGpuId ? fPauliPropGetGpuId(obj) : -1;
1158 bool HasStatevectorMatrixAPI()
const
1160 return IsValid() && fApplyOneQubitMatrix && fApplyOneQubitMatrixWithLayout && fApplyTwoQubitMatrix && fApplyTwoQubitMatrixWithLayout &&
1161 fApplyThreeQubitMatrix && fApplyThreeQubitMatrixWithLayout;
1164 bool HasDensityMatrixAPI()
const
1166 return IsValid() && fCreateDensityMatrix && fDestroyDensityMatrix && fDMCreate && fDMCreateWithState && fDMReset && fDMIsCreated && fDMSetDataType &&
1167 fDMSaveState && fDMRestoreState && fDMCleanSavedState && fDMClone && fDMSetSeed && fDMMeasureQubitCollapse && fDMSampleAll &&
1168 fDMBasisStateProbability && fDMAllProbabilities && fDMExpectationValue && fDMTrace && fDMPurity && fDMIsHermitian && fDMPartialTrace &&
1169 fDMHilbertSchmidtOverlap && fDMFidelityWithStatevector && fDMApplyKraus && fDMApplyReset && fDMApplyX && fDMApplyY && fDMApplyZ && fDMApplyH &&
1170 fDMApplyS && fDMApplySDG && fDMApplyT && fDMApplyTDG && fDMApplySX && fDMApplySXDG && fDMApplyK && fDMApplyP && fDMApplyRx && fDMApplyRy &&
1171 fDMApplyRz && fDMApplyU && fDMApplyCX && fDMApplyCY && fDMApplyCZ && fDMApplyCH && fDMApplyCSX && fDMApplyCSXDG && fDMApplyCP && fDMApplyCRx &&
1172 fDMApplyCRy && fDMApplyCRz && fDMApplyCCX && fDMApplySwap && fDMApplyCSwap && fDMApplyCU;
1175 bool HasMPOAPI()
const
1177 return IsValid() && fCreateMPO && fDestroyMPO && fMPOSampleBits && fMPOGetMapForSample && fMPOFreeMapForSample && fMPOSampleHistogram &&
1178 fMPOGetElementBits && fMPOBasisStateProbabilityBits && fMPOExpectationValueComplex && fMPOUnnormalizedExpectationValue && fMPOGetDensityMatrix &&
1179 fMPOGetUnnormalizedDensityMatrix && fMPOTraceComplex && fMPOSetRestoreTraceAfterTruncation && fMPOGetRestoreTraceAfterTruncation &&
1180 fMPOSetHermitizeAfterTruncation && fMPOGetHermitizeAfterTruncation && fMPOMoveAtBeginningOfChain && fMPOApplyOperator &&
1181 fMPOApplyOperatorAndNormalize && fMPOCreate && fMPOCreateWithState && fMPOReset && fMPOIsCreated && fMPOSetDataType && fMPOSaveState &&
1182 fMPORestoreState && fMPOCleanSavedState && fMPOClone && fMPOSetSeed && fMPOMeasureQubitCollapse && fMPOSampleAll && fMPOBasisStateProbability &&
1183 fMPOAllProbabilities && fMPOExpectationValue && fMPOPartialTrace && fMPOHilbertSchmidtOverlap && fMPOFidelityWithStatevector && fMPOTrace &&
1184 fMPOPurity && fMPOHermiticityResidual && fMPOIsHermitian && fMPOTraceOfSquare && fMPORestoreTrace && fMPOHermitize && fMPOReCanonicalize &&
1185 fMPOTrim && fMPOApplyKraus && fMPOApplyReset && fMPOApplyX && fMPOApplyY && fMPOApplyZ && fMPOApplyH && fMPOApplyS && fMPOApplySDG &&
1186 fMPOApplyT && fMPOApplyTDG && fMPOApplySX && fMPOApplySXDG && fMPOApplyK && fMPOApplyP && fMPOApplyRx && fMPOApplyRy && fMPOApplyRz &&
1187 fMPOApplyU && fMPOApplyCX && fMPOApplyCY && fMPOApplyCZ && fMPOApplyCH && fMPOApplyCSX && fMPOApplyCSXDG && fMPOApplyCP && fMPOApplyCRx &&
1188 fMPOApplyCRy && fMPOApplyCRz && fMPOApplySwap && fMPOApplyCU;
1191 bool HasMPSExpectationValues()
const
1193 return fMPSExpectationValues;
1196 bool HasMPOExpectationValues()
const
1198 return fMPOExpectationValues;
1201 bool HasMPOExpectationValuesComplex()
const
1203 return fMPOExpectationValuesComplex;
1206 bool HasMPSGetStateVector()
const
1208 return fMPSGetStateVector;
1211 bool HasMPSAllProbabilities()
const
1213 return fMPSAllProbabilities;
1216 bool HasMPSMoveAtBeginningOfChain()
const
1218 return fMPSMoveAtBeginningOfChain;
1221 bool HasMPSExpectationValueOperators()
const
1223 return fMPSExpectationValueOperators;
1226 bool HasMPSBondSummary()
const
1228 return fMPSSetBondDimensionSummaryCallback;
1231 bool HasMPOBondSummary()
const
1233 return fMPOSetBondDimensionSummaryCallback;
1236 bool HasMPSMaxBondDimension()
const
1238 return fMPSGetMaxBondDimension;
1241 bool HasMPOMaxBondDimension()
const
1243 return fMPOGetMaxBondDimension;
1246 bool MPSExpectationValues(
void *obj,
int count,
const char *
const *paulis,
const int *lengths,
double *values)
const
1248 return obj && fMPSExpectationValues && fMPSExpectationValues(obj, count, paulis, lengths, values) == 1;
1251 bool MPOExpectationValues(
void *obj,
int count,
const char *
const *paulis,
const int *lengths,
double *values)
const
1253 return obj && fMPOExpectationValues && fMPOExpectationValues(obj, count, paulis, lengths, values) == 1;
1256 bool MPOExpectationValuesComplex(
void *obj,
int count,
const char *
const *paulis,
const int *lengths,
bool normalized,
double *real,
double *imag)
const
1258 return obj && fMPOExpectationValuesComplex && fMPOExpectationValuesComplex(obj, count, paulis, lengths, normalized ? 1 : 0, real, imag) == 1;
1261 bool MPSGetStateVector(
void *obj,
double *values)
const
1263 return obj && fMPSGetStateVector && fMPSGetStateVector(obj, values) == 1;
1266 bool MPSAllProbabilities(
void *obj,
double *values)
const
1268 return obj && fMPSAllProbabilities && fMPSAllProbabilities(obj, values) == 1;
1271 bool MPSMoveAtBeginningOfChain(
void *obj,
const int *qubits,
int count)
const
1273 return obj && fMPSMoveAtBeginningOfChain && fMPSMoveAtBeginningOfChain(obj, qubits, count) == 1;
1276 bool MPSExpectationValueOperators(
void *obj,
int count,
const int *qubits,
const double *matrices,
double *real,
double *imag)
const
1278 return obj && fMPSExpectationValueOperators && fMPSExpectationValueOperators(obj, count, qubits, matrices, real, imag) == 1;
1281 bool MPSSetBondDimensionSummaryCallback(
void *obj,
void (*callback)(
void *, int64_t))
const
1283 return obj && fMPSSetBondDimensionSummaryCallback && fMPSSetBondDimensionSummaryCallback(obj, callback) == 1;
1286 bool MPOSetBondDimensionSummaryCallback(
void *obj,
void (*callback)(
void *, int64_t))
const
1288 return obj && fMPOSetBondDimensionSummaryCallback && fMPOSetBondDimensionSummaryCallback(obj, callback) == 1;
1291 long long MPSGetMaxBondDimension(
void *obj)
const
1293 return obj && fMPSGetMaxBondDimension ? fMPSGetMaxBondDimension(obj) : 0;
1296 long long MPOGetMaxBondDimension(
void *obj)
const
1298 return obj && fMPOGetMaxBondDimension ? fMPOGetMaxBondDimension(obj) : 0;
1303 void *CreateStateVector()
1306 return fCreateStateVector(LibraryHandle);
1308 throw std::runtime_error(
"GpuLibrary: Unable to create state vector");
1311 void DestroyStateVector(
void *obj)
1314 fDestroyStateVector(obj);
1316 throw std::runtime_error(
"GpuLibrary: Unable to destroy state vector");
1319 bool Create(
void *obj,
unsigned int nrQubits)
1322 return fCreate(obj, nrQubits) == 1;
1324 throw std::runtime_error(
"GpuLibrary: Unable to create state vector state");
1329 bool CreateWithState(
void *obj,
unsigned int nrQubits,
const double *state)
1332 return fCreateWithState(obj, nrQubits, state) == 1;
1334 throw std::runtime_error(
"GpuLibrary: Unable to create state vector state with a state");
1339 bool Reset(
void *obj)
1342 return fReset(obj) == 1;
1344 throw std::runtime_error(
"GpuLibrary: Unable to reset state vector");
1349 bool SetDataType(
void *obj,
int dataType)
1352 return fSetDataType(obj, dataType) == 1;
1354 throw std::runtime_error(
"GpuLibrary: Unable to set data type");
1359 bool IsDoublePrecision(
void *obj)
const
1362 return fIsDoublePrecision(obj) == 1;
1364 throw std::runtime_error(
"GpuLibrary: Unable to check if double precision");
1369 int GetNrQubits(
void *obj)
const
1372 return fGetNrQubits(obj);
1374 throw std::runtime_error(
"GpuLibrary: Unable to get number of qubits");
1378 bool MeasureQubitCollapse(
void *obj,
int qubitIndex)
1381 return fMeasureQubitCollapse(obj, qubitIndex) == 1;
1383 throw std::runtime_error(
"GpuLibrary: Unable to measure qubit with collapse");
1388 bool MeasureQubitNoCollapse(
void *obj,
int qubitIndex)
1391 return fMeasureQubitNoCollapse(obj, qubitIndex) == 1;
1393 throw std::runtime_error(
"GpuLibrary: Unable to measure qubit no collapse");
1398 bool MeasureQubitsCollapse(
void *obj,
int *qubits,
int *bitstring,
int bitstringLen)
1401 return fMeasureQubitsCollapse(obj, qubits, bitstring, bitstringLen) == 1;
1403 throw std::runtime_error(
"GpuLibrary: Unable to measure qubits with collapse");
1408 bool MeasureQubitsNoCollapse(
void *obj,
int *qubits,
int *bitstring,
int bitstringLen)
1411 return fMeasureQubitsNoCollapse(obj, qubits, bitstring, bitstringLen) == 1;
1413 throw std::runtime_error(
"GpuLibrary: Unable to measure qubits with no collapse");
1418 unsigned long long MeasureAllQubitsCollapse(
void *obj)
1421 return fMeasureAllQubitsCollapse(obj);
1423 throw std::runtime_error(
"GpuLibrary: Unable to measure all qubits with collapse");
1428 unsigned long long MeasureAllQubitsNoCollapse(
void *obj)
1431 return fMeasureAllQubitsNoCollapse(obj);
1433 throw std::runtime_error(
"GpuLibrary: Unable to measure all qubits with no collapse");
1441 return fSaveState(obj) == 1;
1443 throw std::runtime_error(
"GpuLibrary: Unable to save state");
1448 bool SaveStateToHost(
void *obj)
1451 return fSaveStateToHost(obj) == 1;
1453 throw std::runtime_error(
"GpuLibrary: Unable to save state to host");
1458 bool SaveStateDestructive(
void *obj)
1461 return fSaveStateDestructive(obj) == 1;
1463 throw std::runtime_error(
"GpuLibrary: Unable to save state destructively");
1468 bool RestoreStateFreeSaved(
void *obj)
1471 return fRestoreStateFreeSaved(obj) == 1;
1473 throw std::runtime_error(
"GpuLibrary: Unable to restore state free saved");
1478 bool RestoreStateNoFreeSaved(
void *obj)
1481 return fRestoreStateNoFreeSaved(obj) == 1;
1483 throw std::runtime_error(
"GpuLibrary: Unable to restore state no free saved");
1488 void FreeSavedState(
void *obj)
1491 fFreeSavedState(obj);
1493 throw std::runtime_error(
"GpuLibrary: Unable to free saved state");
1496 void *Clone(
void *obj)
const
1501 throw std::runtime_error(
"GpuLibrary: Unable to clone state vector");
1506 bool SetSeed(
void *obj,
unsigned long long seed)
const
1508 return obj && fSetSeed && fSetSeed(obj, seed) == 1;
1511 bool Sample(
void *obj,
unsigned int nSamples,
long int *samples,
unsigned int nBits,
int *bits)
1514 return fSample(obj, nSamples, samples, nBits, bits) == 1;
1516 throw std::runtime_error(
"GpuLibrary: Unable to sample state vector");
1521 bool SampleAll(
void *obj,
unsigned int nSamples,
long int *samples)
1524 return fSampleAll(obj, nSamples, samples) == 1;
1526 throw std::runtime_error(
"GpuLibrary: Unable to sample state vector");
1531 bool Amplitude(
void *obj,
long long int state,
double *real,
double *imaginary)
const
1534 return fAmplitude(obj, state, real, imaginary) == 1;
1536 throw std::runtime_error(
"GpuLibrary: Unable to get amplitude");
1541 double Probability(
void *obj,
int *qubits,
int *mask,
int len)
const
1544 return fProbability(obj, qubits, mask, len);
1546 throw std::runtime_error(
"GpuLibrary: Unable to get probability");
1551 double BasisStateProbability(
void *obj,
long long int state)
const
1554 return fBasisStateProbability(obj, state);
1556 throw std::runtime_error(
"GpuLibrary: Unable to get basis state probability");
1564 return fAllProbabilities(obj, probabilities) == 1;
1566 throw std::runtime_error(
"GpuLibrary: Unable to get all probabilities");
1571 double ExpectationValue(
void *obj,
const char *pauliString,
int len)
const
1574 return fExpectationValue(obj, pauliString, len);
1576 throw std::runtime_error(
"GpuLibrary: Unable to get expectation value");
1581 bool ApplyX(
void *obj,
int qubit)
1584 return fApplyX(obj, qubit) == 1;
1586 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate");
1591 bool ApplyY(
void *obj,
int qubit)
1594 return fApplyY(obj, qubit) == 1;
1596 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate");
1601 bool ApplyZ(
void *obj,
int qubit)
1604 return fApplyZ(obj, qubit) == 1;
1606 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate");
1611 bool ApplyH(
void *obj,
int qubit)
1614 return fApplyH(obj, qubit) == 1;
1616 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate");
1621 bool ApplyS(
void *obj,
int qubit)
1624 return fApplyS(obj, qubit) == 1;
1626 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate");
1631 bool ApplySDG(
void *obj,
int qubit)
1634 return fApplySDG(obj, qubit) == 1;
1636 throw std::runtime_error(
"GpuLibrary: Unable to apply SDG gate");
1641 bool ApplyT(
void *obj,
int qubit)
1644 return fApplyT(obj, qubit) == 1;
1646 throw std::runtime_error(
"GpuLibrary: Unable to apply T gate");
1651 bool ApplyTDG(
void *obj,
int qubit)
1654 return fApplyTDG(obj, qubit) == 1;
1656 throw std::runtime_error(
"GpuLibrary: Unable to apply TDG gate");
1661 bool ApplySX(
void *obj,
int qubit)
1664 return fApplySX(obj, qubit) == 1;
1666 throw std::runtime_error(
"GpuLibrary: Unable to apply SX gate");
1674 return fApplySXDG(obj, qubit) == 1;
1676 throw std::runtime_error(
"GpuLibrary: Unable to apply SXDG gate");
1681 bool ApplyK(
void *obj,
int qubit)
1684 return fApplyK(obj, qubit) == 1;
1686 throw std::runtime_error(
"GpuLibrary: Unable to apply K gate");
1691 bool ApplyP(
void *obj,
int qubit,
double theta)
1694 return fApplyP(obj, qubit, theta) == 1;
1696 throw std::runtime_error(
"GpuLibrary: Unable to apply P gate");
1701 bool ApplyRx(
void *obj,
int qubit,
double theta)
1704 return fApplyRx(obj, qubit, theta) == 1;
1706 throw std::runtime_error(
"GpuLibrary: Unable to apply Rx gate");
1711 bool ApplyRy(
void *obj,
int qubit,
double theta)
1714 return fApplyRy(obj, qubit, theta) == 1;
1716 throw std::runtime_error(
"GpuLibrary: Unable to apply Ry gate");
1721 bool ApplyRz(
void *obj,
int qubit,
double theta)
1724 return fApplyRz(obj, qubit, theta) == 1;
1726 throw std::runtime_error(
"GpuLibrary: Unable to apply Rz gate");
1731 bool ApplyU(
void *obj,
int qubit,
double theta,
double phi,
double lambda,
double gamma)
1734 return fApplyU(obj, qubit, theta, phi, lambda, gamma) == 1;
1736 throw std::runtime_error(
"GpuLibrary: Unable to apply U gate");
1741 bool ApplyCX(
void *obj,
int controlQubit,
int targetQubit)
1744 return fApplyCX(obj, controlQubit, targetQubit) == 1;
1746 throw std::runtime_error(
"GpuLibrary: Unable to apply CX gate");
1751 bool ApplyCY(
void *obj,
int controlQubit,
int targetQubit)
1754 return fApplyCY(obj, controlQubit, targetQubit) == 1;
1756 throw std::runtime_error(
"GpuLibrary: Unable to apply CY gate");
1761 bool ApplyCZ(
void *obj,
int controlQubit,
int targetQubit)
1764 return fApplyCZ(obj, controlQubit, targetQubit) == 1;
1766 throw std::runtime_error(
"GpuLibrary: Unable to apply CZ gate");
1771 bool ApplyCH(
void *obj,
int controlQubit,
int targetQubit)
1774 return fApplyCH(obj, controlQubit, targetQubit) == 1;
1776 throw std::runtime_error(
"GpuLibrary: Unable to apply CH gate");
1781 bool ApplyCSX(
void *obj,
int controlQubit,
int targetQubit)
1784 return fApplyCSX(obj, controlQubit, targetQubit) == 1;
1786 throw std::runtime_error(
"GpuLibrary: Unable to apply CSX gate");
1791 bool ApplyCSXDG(
void *obj,
int controlQubit,
int targetQubit)
1794 return fApplyCSXDG(obj, controlQubit, targetQubit) == 1;
1796 throw std::runtime_error(
"GpuLibrary: Unable to apply CSXDG gate");
1801 bool ApplyCP(
void *obj,
int controlQubit,
int targetQubit,
double theta)
1804 return fApplyCP(obj, controlQubit, targetQubit, theta) == 1;
1806 throw std::runtime_error(
"GpuLibrary: Unable to apply CP gate");
1811 bool ApplyCRx(
void *obj,
int controlQubit,
int targetQubit,
double theta)
1814 return fApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
1816 throw std::runtime_error(
"GpuLibrary: Unable to apply CRx gate");
1821 bool ApplyCRy(
void *obj,
int controlQubit,
int targetQubit,
double theta)
1824 return fApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
1826 throw std::runtime_error(
"GpuLibrary: Unable to apply CRy gate");
1831 bool ApplyCRz(
void *obj,
int controlQubit,
int targetQubit,
double theta)
1834 return fApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
1836 throw std::runtime_error(
"GpuLibrary: Unable to apply CRz gate");
1841 bool ApplyCCX(
void *obj,
int controlQubit1,
int controlQubit2,
int targetQubit)
1844 return fApplyCCX(obj, controlQubit1, controlQubit2, targetQubit) == 1;
1846 throw std::runtime_error(
"GpuLibrary: Unable to apply CCX gate");
1851 bool ApplySwap(
void *obj,
int qubit1,
int qubit2)
1854 return fApplySwap(obj, qubit1, qubit2) == 1;
1856 throw std::runtime_error(
"GpuLibrary: Unable to apply Swap gate");
1861 bool ApplyCSwap(
void *obj,
int controlQubit,
int qubit1,
int qubit2)
1864 return fApplyCSwap(obj, controlQubit, qubit1, qubit2) == 1;
1866 throw std::runtime_error(
"GpuLibrary: Unable to apply CSwap gate");
1871 bool ApplyCU(
void *obj,
int controlQubit,
int targetQubit,
double theta,
double phi,
double lambda,
double gamma)
1874 return fApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda, gamma) == 1;
1876 throw std::runtime_error(
"GpuLibrary: Unable to apply CU gate");
1882 bool ApplyOneQubitMatrix(
void *obj,
int q0,
const double *matrix)
1884 return obj && fApplyOneQubitMatrix && fApplyOneQubitMatrix(obj, q0, matrix) == 1;
1887 bool ApplyOneQubitMatrixWithLayout(
void *obj,
int q0,
const double *matrix,
int layout)
1889 return obj && fApplyOneQubitMatrixWithLayout && fApplyOneQubitMatrixWithLayout(obj, q0, matrix, layout) == 1;
1892 bool ApplyTwoQubitMatrix(
void *obj,
int q0,
int q1,
const double *matrix)
1894 return obj && fApplyTwoQubitMatrix && fApplyTwoQubitMatrix(obj, q0, q1, matrix) == 1;
1897 bool ApplyTwoQubitMatrixWithLayout(
void *obj,
int q0,
int q1,
const double *matrix,
int layout)
1899 return obj && fApplyTwoQubitMatrixWithLayout && fApplyTwoQubitMatrixWithLayout(obj, q0, q1, matrix, layout) == 1;
1902 bool ApplyThreeQubitMatrix(
void *obj,
int q0,
int q1,
int q2,
const double *matrix)
1904 return obj && fApplyThreeQubitMatrix && fApplyThreeQubitMatrix(obj, q0, q1, q2, matrix) == 1;
1907 bool ApplyThreeQubitMatrixWithLayout(
void *obj,
int q0,
int q1,
int q2,
const double *matrix,
int layout)
1909 return obj && fApplyThreeQubitMatrixWithLayout && fApplyThreeQubitMatrixWithLayout(obj, q0, q1, q2, matrix, layout) == 1;
1914 void *CreateDensityMatrix()
1916 if (!LibraryHandle || !fCreateDensityMatrix)
1918 return fCreateDensityMatrix(LibraryHandle);
1921 void DestroyDensityMatrix(
void *obj)
1923 if (obj && fDestroyDensityMatrix)
1924 fDestroyDensityMatrix(obj);
1927#define DM_BOOL0(name) \
1928 bool name(void *obj) \
1930 return obj && f##name && f##name(obj) == 1; \
1932#define DM_BOOL1(name, type) \
1933 bool name(void *obj, type a) \
1935 return obj && f##name && f##name(obj, a) == 1; \
1937#define DM_BOOL2(name, type1, type2) \
1938 bool name(void *obj, type1 a, type2 b) \
1940 return obj && f##name && f##name(obj, a, b) == 1; \
1942#define DM_BOOL3(name, type1, type2, type3) \
1943 bool name(void *obj, type1 a, type2 b, type3 c) \
1945 return obj && f##name && f##name(obj, a, b, c) == 1; \
1947 DM_BOOL1(DMCreate,
unsigned int)
1949 bool DMCreateWithState(
void *obj,
unsigned int n,
const double *data)
1951 return obj && fDMCreateWithState && fDMCreateWithState(obj, n, data) == 1;
1954 bool DMCreateWithBasisState(
void *obj,
unsigned int n,
unsigned long long state)
1956 return obj && fDMCreateWithBasisState && fDMCreateWithBasisState(obj, n, state) == 1;
1959 bool DMCreateWithMixtureOfBasisStates(
void *obj,
unsigned int n,
const unsigned long long *states,
const double *weights,
int nTerms)
1961 return obj && fDMCreateWithMixtureOfBasisStates && fDMCreateWithMixtureOfBasisStates(obj, n, states, weights, nTerms) == 1;
1964 DM_BOOL0(DMReset) DM_BOOL0(DMIsValid) DM_BOOL0(DMIsCreated) DM_BOOL1(DMSetDataType,
int) DM_BOOL0(DMIsDoublePrecision)
int DMGetNrQubits(
void *obj)
const
1966 return obj && fDMGetNrQubits ? fDMGetNrQubits(obj) : 0;
1969 DM_BOOL0(DMSaveState) DM_BOOL0(DMRestoreState) DM_BOOL0(DMCleanSavedState)
void *DMClone(
void *obj)
1971 return obj && fDMClone ? fDMClone(obj) :
nullptr;
1974 bool DMSetSeed(
void *obj,
unsigned long long seed)
const
1976 return obj && fDMSetSeed && fDMSetSeed(obj, seed) == 1;
1979 bool DMMeasureQubitCollapse(
void *obj,
int q)
1981 return obj && fDMMeasureQubitCollapse && fDMMeasureQubitCollapse(obj, q);
1983 DM_BOOL1(DMMeasureQubitNoCollapse,
int)
1985 bool DMMeasureQubitsCollapse(
void *obj,
int *q,
int *bits,
int n)
1987 return obj && fDMMeasureQubitsCollapse && fDMMeasureQubitsCollapse(obj, q, bits, n) == 1;
1990 bool DMMeasureQubitsNoCollapse(
void *obj,
int *q,
int *bits,
int n)
1992 return obj && fDMMeasureQubitsNoCollapse && fDMMeasureQubitsNoCollapse(obj, q, bits, n) == 1;
1995 unsigned long long DMMeasureAllQubitsCollapse(
void *obj)
1997 return obj && fDMMeasureAllQubitsCollapse ? fDMMeasureAllQubitsCollapse(obj) : 0;
2000 unsigned long long DMMeasureAllQubitsNoCollapse(
void *obj)
2002 return obj && fDMMeasureAllQubitsNoCollapse ? fDMMeasureAllQubitsNoCollapse(obj) : 0;
2005 bool DMGetElement(
void *obj,
long long row,
long long col,
double *re,
double *im)
const
2007 return obj && fDMGetElement && fDMGetElement(obj, row, col, re, im) == 1;
2010 bool DMSample(
void *obj,
unsigned int n,
long int *samples,
unsigned int nBits,
int *order)
2012 return obj && fDMSample && fDMSample(obj, n, samples, nBits, order) == 1;
2015 bool DMSampleAll(
void *obj,
unsigned int shots,
long int *samples)
2017 return obj && fDMSampleAll && fDMSampleAll(obj, shots, samples) == 1;
2020 double DMBasisStateProbability(
void *obj,
long long state)
const
2022 return obj && fDMBasisStateProbability ? fDMBasisStateProbability(obj, state) : 0.0;
2025 bool DMAllProbabilities(
void *obj,
double *values)
2027 return obj && fDMAllProbabilities && fDMAllProbabilities(obj, values) == 1;
2030 double DMExpectationValue(
void *obj,
const char *pauli,
int len)
const
2032 return obj && fDMExpectationValue ? fDMExpectationValue(obj, pauli, len) : 0.0;
2035 double DMQubitProbability0(
void *obj,
unsigned int q)
const
2037 return obj && fDMQubitProbability0 ? fDMQubitProbability0(obj, q) : 0.;
2040 double DMTrace(
void *obj)
const
2042 return obj && fDMTrace ? fDMTrace(obj) : 0.;
2045 double DMPurity(
void *obj)
const
2047 return obj && fDMPurity ? fDMPurity(obj) : 0.;
2050 bool DMIsHermitian(
void *obj,
double eps)
const
2052 return obj && fDMIsHermitian && fDMIsHermitian(obj, eps) == 1;
2055 bool DMPartialTrace(
void *obj,
const int *q,
int n,
double *out)
2057 return obj && fDMPartialTrace && fDMPartialTrace(obj, q, n, out) == 1;
2060 bool DMHilbertSchmidtOverlap(
void *obj,
void *other,
double *re,
double *im)
2062 return obj && other && fDMHilbertSchmidtOverlap && fDMHilbertSchmidtOverlap(obj, other, re, im) == 1;
2065 bool DMFidelityWithStatevector(
void *obj,
const double *state,
double *out)
2067 return obj && fDMFidelityWithStatevector && fDMFidelityWithStatevector(obj, state, out) == 1;
2070 bool DMApplyKraus(
void *obj,
int n,
const int *qubits,
int count,
const double *operators)
2072 return obj && fDMApplyKraus && fDMApplyKraus(obj, n, qubits, count, operators) == 1;
2074 DM_BOOL1(DMApplyReset,
int)
2076 DM_BOOL2(DMApplyBitFlipNoise,
int,
double)
2078 DM_BOOL2(DMApplyPhaseFlipNoise,
int,
double)
2080 DM_BOOL2(DMApplyDepolarizingNoise,
int,
double)
2082 DM_BOOL2(DMApplyAmplitudeDamping,
int,
double)
2084 DM_BOOL2(DMApplyPhaseDamping,
int,
double)
2086 DM_BOOL1(DMApplyNonSelectiveMeasurement,
int)
2088 DM_BOOL1(DMApplyX,
int)
2090 DM_BOOL1(DMApplyY,
int)
2092 DM_BOOL1(DMApplyZ,
int)
2094 DM_BOOL1(DMApplyH,
int)
2096 DM_BOOL1(DMApplyS,
int)
2098 DM_BOOL1(DMApplySDG,
int)
2100 DM_BOOL1(DMApplyT,
int)
2102 DM_BOOL1(DMApplyTDG,
int)
2104 DM_BOOL1(DMApplySX,
int)
2106 DM_BOOL1(DMApplySXDG,
int)
2108 DM_BOOL1(DMApplyK,
int)
2110 DM_BOOL2(DMApplyP,
int,
double)
2112 DM_BOOL2(DMApplyRx,
int,
double)
2114 DM_BOOL2(DMApplyRy,
int,
double) DM_BOOL2(DMApplyRz,
int,
double)
bool DMApplyU(
void *o,
int q,
double a,
double b,
double c,
double d)
2116 return o && fDMApplyU && fDMApplyU(o, q, a, b, c, d) == 1;
2119 DM_BOOL2(DMApplyCX,
int,
int)
2121 DM_BOOL2(DMApplyCY,
int,
int)
2123 DM_BOOL2(DMApplyCZ,
int,
int)
2125 DM_BOOL2(DMApplyCH,
int,
int)
2127 DM_BOOL2(DMApplyCSX,
int,
int)
2129 DM_BOOL2(DMApplyCSXDG,
int,
int)
2131 DM_BOOL3(DMApplyCP,
int,
int,
double)
2133 DM_BOOL3(DMApplyCRx,
int,
int,
double)
2135 DM_BOOL3(DMApplyCRy,
int,
int,
double)
2137 DM_BOOL3(DMApplyCRz,
int,
int,
double)
2139 DM_BOOL3(DMApplyCCX,
int,
int,
int)
2141 DM_BOOL2(DMApplySwap,
int,
int) DM_BOOL3(DMApplyCSwap,
int,
int,
int)
bool DMApplyCU(
void *o,
int c,
int t,
double a,
double b,
double d,
double g)
2143 return o && fDMApplyCU && fDMApplyCU(o, c, t, a, b, d, g) == 1;
2155 if (!LibraryHandle || !fCreateMPO)
2157 return fCreateMPO(LibraryHandle);
2160 void DestroyMPO(
void *obj)
2162 if (obj && fDestroyMPO)
2166#define MPO_BOOL0(name) \
2167 bool name(void *obj) \
2169 return obj && f##name && f##name(obj) == 1; \
2171#define MPO_BOOL1(name, type) \
2172 bool name(void *obj, type a) \
2174 return obj && f##name && f##name(obj, a) == 1; \
2176#define MPO_BOOL2(name, type1, type2) \
2177 bool name(void *obj, type1 a, type2 b) \
2179 return obj && f##name && f##name(obj, a, b) == 1; \
2181#define MPO_BOOL3(name, type1, type2, type3) \
2182 bool name(void *obj, type1 a, type2 b, type3 c) \
2184 return obj && f##name && f##name(obj, a, b, c) == 1; \
2186 MPO_BOOL1(MPOCreate,
unsigned int)
2188 bool MPOCreateWithState(
void *obj,
unsigned int n,
const double *data)
2190 return obj && fMPOCreateWithState && fMPOCreateWithState(obj, n, data) == 1;
2193 bool MPOCreateWithBasisState(
void *obj,
unsigned int n,
unsigned long long state)
2195 return obj && fMPOCreateWithBasisState && fMPOCreateWithBasisState(obj, n, state) == 1;
2198 bool MPOCreateWithBasisStateBits(
void *obj,
unsigned int n,
const unsigned char *stateBits)
2200 return obj && fMPOCreateWithBasisStateBits && fMPOCreateWithBasisStateBits(obj, n, stateBits) == 1;
2203 bool MPOCreateWithMixtureOfBasisStates(
void *obj,
unsigned int n,
const unsigned long long *states,
const double *weights,
int nTerms)
2205 return obj && fMPOCreateWithMixtureOfBasisStates && fMPOCreateWithMixtureOfBasisStates(obj, n, states, weights, nTerms) == 1;
2208 bool MPOCreateWithMixtureOfBasisStatesBits(
void *obj,
unsigned int n,
const unsigned char *stateBitsFlat,
const double *weights,
int nTerms)
2210 return obj && fMPOCreateWithMixtureOfBasisStatesBits && fMPOCreateWithMixtureOfBasisStatesBits(obj, n, stateBitsFlat, weights, nTerms) == 1;
2214 bool MPOSetInitialQubitsMap(
void *obj,
const std::vector<long long int> &initialMap)
2216 return obj && fMPOSetInitialQubitsMap && fMPOSetInitialQubitsMap(obj, initialMap.data(),
static_cast<int>(initialMap.size())) == 1;
2218 MPO_BOOL1(MPOSetUseOptimalMeetingPosition,
int)
2220 bool MPOGetUseOptimalMeetingPosition(
void *obj)
const
2222 return obj && fMPOGetUseOptimalMeetingPosition && fMPOGetUseOptimalMeetingPosition(obj) == 1;
2225 MPO_BOOL0(MPOIsValid) MPO_BOOL0(MPOIsCreated) MPO_BOOL1(MPOSetDataType,
int) MPO_BOOL0(MPOIsDoublePrecision)
int MPOGetNrQubits(
void *obj)
const
2227 return obj && fMPOGetNrQubits ? fMPOGetNrQubits(obj) : 0;
2229 MPO_BOOL1(MPOSetCutoff,
double)
2231 double MPOGetCutoff(
void *obj)
const
2233 return obj && fMPOGetCutoff ? fMPOGetCutoff(obj) : 0.0;
2235 MPO_BOOL1(MPOSetTruncationMode,
int)
2237 int MPOGetTruncationMode(
void *obj)
const
2239 return obj && fMPOGetTruncationMode ? fMPOGetTruncationMode(obj) : 0;
2241 MPO_BOOL1(MPOSetGesvdJ,
int)
2243 bool MPOGetGesvdJ(
void *obj)
const
2245 return obj && fMPOGetGesvdJ && fMPOGetGesvdJ(obj) == 1;
2248 bool MPOSetGesvdP(
void *obj,
int val)
2250 return LibraryHandle && obj && fMPOSetGesvdP && fMPOSetGesvdP(obj, val) == 1;
2253 bool MPOGetGesvdP(
void *obj)
const
2255 if (!LibraryHandle || !obj || !fMPOGetGesvdP)
2256 throw std::runtime_error(
"GpuLibrary: MPOGetGesvdP is unavailable");
2257 return fMPOGetGesvdP(obj) == 1;
2260 bool MPOSetGesvdR(
void *obj,
int val)
2262 return LibraryHandle && obj && fMPOSetGesvdR && fMPOSetGesvdR(obj, val) == 1;
2265 bool MPOGetGesvdR(
void *obj)
const
2267 if (!LibraryHandle || !obj || !fMPOGetGesvdR)
2268 throw std::runtime_error(
"GpuLibrary: MPOGetGesvdR is unavailable");
2269 return fMPOGetGesvdR(obj) == 1;
2273 int MPOGetLastSvdAlgo(
void *obj)
const
2275 if (!LibraryHandle || !obj || !fMPOGetLastSvdAlgo)
2276 throw std::runtime_error(
"GpuLibrary: MPOGetLastSvdAlgo is unavailable");
2277 return fMPOGetLastSvdAlgo(obj);
2280 MPO_BOOL1(MPOSetMaxExtent,
long int)
2282 long int MPOGetMaxExtent(
void *obj)
const
2284 return obj && fMPOGetMaxExtent ? fMPOGetMaxExtent(obj) : 0;
2287 bool MPOGetBondDimensions(
void *obj,
long long int *bondDims)
2289 return obj && fMPOGetBondDimensions && fMPOGetBondDimensions(obj, bondDims) == 1;
2292 bool MPOGetQubitsMap(
void *obj,
long long *map,
int size)
const
2294 return obj && fMPOGetQubitsMap && fMPOGetQubitsMap(obj, map, size) == 1;
2297 bool MPOSetCallbackContext(
void *obj,
void *context)
2299 return obj && fMPOSetCallbackContext && fMPOSetCallbackContext(obj, context) == 1;
2302 bool MPOSetMeetingPositionCallback(
void *obj, int64_t (*callback)(
void *,
const int64_t *))
2304 return obj && fMPOSetMeetingPositionCallback && fMPOSetMeetingPositionCallback(obj, callback) == 1;
2307 bool MPOSetBondDimensionsCallback(
void *obj,
void (*callback)(
void *,
const int64_t *))
2309 return obj && fMPOSetBondDimensionsCallback && fMPOSetBondDimensionsCallback(obj, callback) == 1;
2312 int MPOSampleBits(
void *obj,
unsigned int shots,
unsigned int n,
const int *qubits,
unsigned char *out)
const
2314 if (!fMPOSampleBits)
2315 throw std::runtime_error(
"GpuLibrary: MPOSampleBits is unavailable");
2316 return fMPOSampleBits(obj, shots, n, qubits, out);
2319 void *MPOGetMapForSample()
const
2321 if (!fMPOGetMapForSample)
2322 throw std::runtime_error(
"GpuLibrary: MPOGetMapForSample is unavailable");
2323 return fMPOGetMapForSample();
2326 int MPOFreeMapForSample(
void *map)
const
2328 if (!fMPOFreeMapForSample)
2329 throw std::runtime_error(
"GpuLibrary: MPOFreeMapForSample is unavailable");
2330 return fMPOFreeMapForSample(map);
2333 int MPOSampleHistogram(
void *obj,
long int shots,
long int n,
unsigned int *qubits,
void *map)
const
2335 if (!fMPOSampleHistogram)
2336 throw std::runtime_error(
"GpuLibrary: MPOSampleHistogram is unavailable");
2337 return fMPOSampleHistogram(obj, shots, n, qubits, map);
2340 int MPOGetElementBits(
void *obj,
const unsigned char *row,
const unsigned char *col,
double *re,
double *im)
const
2342 if (!fMPOGetElementBits)
2343 throw std::runtime_error(
"GpuLibrary: MPOGetElementBits is unavailable");
2344 return fMPOGetElementBits(obj, row, col, re, im);
2347 double MPOBasisStateProbabilityBits(
void *obj,
const unsigned char *bits)
const
2349 if (!fMPOBasisStateProbabilityBits)
2350 throw std::runtime_error(
"GpuLibrary: MPOBasisStateProbabilityBits is unavailable");
2351 return fMPOBasisStateProbabilityBits(obj, bits);
2354 int MPOExpectationValueComplex(
void *obj,
const char *pauli,
int n,
double *re,
double *im)
const
2356 if (!fMPOExpectationValueComplex)
2357 throw std::runtime_error(
"GpuLibrary: MPOExpectationValueComplex is unavailable");
2358 return fMPOExpectationValueComplex(obj, pauli, n, re, im);
2361 int MPOUnnormalizedExpectationValue(
void *obj,
const char *pauli,
int n,
double *re,
double *im)
const
2363 if (!fMPOUnnormalizedExpectationValue)
2364 throw std::runtime_error(
"GpuLibrary: MPOUnnormalizedExpectationValue is unavailable");
2365 return fMPOUnnormalizedExpectationValue(obj, pauli, n, re, im);
2368 int MPOGetDensityMatrix(
void *obj,
double *out)
const
2370 if (!fMPOGetDensityMatrix)
2371 throw std::runtime_error(
"GpuLibrary: MPOGetDensityMatrix is unavailable");
2372 return fMPOGetDensityMatrix(obj, out);
2375 int MPOGetUnnormalizedDensityMatrix(
void *obj,
double *out)
const
2377 if (!fMPOGetUnnormalizedDensityMatrix)
2378 throw std::runtime_error(
"GpuLibrary: MPOGetUnnormalizedDensityMatrix is unavailable");
2379 return fMPOGetUnnormalizedDensityMatrix(obj, out);
2382 int MPOTraceComplex(
void *obj,
double *re,
double *im)
const
2384 if (!fMPOTraceComplex)
2385 throw std::runtime_error(
"GpuLibrary: MPOTraceComplex is unavailable");
2386 return fMPOTraceComplex(obj, re, im);
2389 int MPOSetRestoreTraceAfterTruncation(
void *obj,
int enable)
const
2391 if (!fMPOSetRestoreTraceAfterTruncation)
2392 throw std::runtime_error(
"GpuLibrary: MPOSetRestoreTraceAfterTruncation is unavailable");
2393 return fMPOSetRestoreTraceAfterTruncation(obj, enable);
2396 int MPOGetRestoreTraceAfterTruncation(
void *obj)
const
2398 if (!fMPOGetRestoreTraceAfterTruncation)
2399 throw std::runtime_error(
"GpuLibrary: MPOGetRestoreTraceAfterTruncation is unavailable");
2400 return fMPOGetRestoreTraceAfterTruncation(obj);
2403 int MPOSetHermitizeAfterTruncation(
void *obj,
int enable)
const
2405 if (!fMPOSetHermitizeAfterTruncation)
2406 throw std::runtime_error(
"GpuLibrary: MPOSetHermitizeAfterTruncation is unavailable");
2407 return fMPOSetHermitizeAfterTruncation(obj, enable);
2410 int MPOGetHermitizeAfterTruncation(
void *obj)
const
2412 if (!fMPOGetHermitizeAfterTruncation)
2413 throw std::runtime_error(
"GpuLibrary: MPOGetHermitizeAfterTruncation is unavailable");
2414 return fMPOGetHermitizeAfterTruncation(obj);
2417 int MPOMoveAtBeginningOfChain(
void *obj,
const int *qubits,
int n)
const
2419 if (!fMPOMoveAtBeginningOfChain)
2420 throw std::runtime_error(
"GpuLibrary: MPOMoveAtBeginningOfChain is unavailable");
2421 return fMPOMoveAtBeginningOfChain(obj, qubits, n);
2424 int MPOApplyOperator(
void *obj,
int n,
const int *qubits,
const double *matrix)
const
2426 if (!fMPOApplyOperator)
2427 throw std::runtime_error(
"GpuLibrary: MPOApplyOperator is unavailable");
2428 return fMPOApplyOperator(obj, n, qubits, matrix);
2431 int MPOApplyOperatorAndNormalize(
void *obj,
int n,
const int *qubits,
const double *matrix)
const
2433 if (!fMPOApplyOperatorAndNormalize)
2434 throw std::runtime_error(
"GpuLibrary: MPOApplyOperatorAndNormalize is unavailable");
2435 return fMPOApplyOperatorAndNormalize(obj, n, qubits, matrix);
2437 MPO_BOOL0(MPOReCanonicalize)
2439 bool MPOTrim(
void *obj,
double cutoff,
long int maxExtent)
2441 return obj && fMPOTrim && fMPOTrim(obj, cutoff, maxExtent) == 1;
2444 MPO_BOOL0(MPOSaveState) MPO_BOOL0(MPORestoreState) MPO_BOOL0(MPOCleanSavedState)
void *MPOClone(
void *obj)
2446 return obj && fMPOClone ? fMPOClone(obj) :
nullptr;
2449 bool MPOSetSeed(
void *obj,
unsigned long long seed)
const
2451 return obj && fMPOSetSeed && fMPOSetSeed(obj, seed) == 1;
2454 bool MPOMeasureQubitCollapse(
void *obj,
int q)
2456 return obj && fMPOMeasureQubitCollapse && fMPOMeasureQubitCollapse(obj, q);
2458 MPO_BOOL1(MPOMeasureQubitNoCollapse,
int)
2460 bool MPOMeasureQubitsCollapse(
void *obj,
int *q,
int *bits,
int n)
2462 return obj && fMPOMeasureQubitsCollapse && fMPOMeasureQubitsCollapse(obj, q, bits, n) == 1;
2465 bool MPOMeasureQubitsNoCollapse(
void *obj,
int *q,
int *bits,
int n)
2467 return obj && fMPOMeasureQubitsNoCollapse && fMPOMeasureQubitsNoCollapse(obj, q, bits, n) == 1;
2470 unsigned long long MPOMeasureAllQubitsCollapse(
void *obj)
2472 return obj && fMPOMeasureAllQubitsCollapse ? fMPOMeasureAllQubitsCollapse(obj) : 0;
2475 unsigned long long MPOMeasureAllQubitsNoCollapse(
void *obj)
2477 return obj && fMPOMeasureAllQubitsNoCollapse ? fMPOMeasureAllQubitsNoCollapse(obj) : 0;
2480 bool MPOGetElement(
void *obj,
long long row,
long long col,
double *re,
double *im)
const
2482 return obj && fMPOGetElement && fMPOGetElement(obj, row, col, re, im) == 1;
2485 bool MPOSample(
void *obj,
unsigned int nSamples,
long int *samples,
unsigned int nBits,
int *bitOrdering)
2487 return obj && fMPOSample && fMPOSample(obj, nSamples, samples, nBits, bitOrdering) == 1;
2490 bool MPOSampleAll(
void *obj,
unsigned int shots,
long int *samples)
2492 return obj && fMPOSampleAll && fMPOSampleAll(obj, shots, samples) == 1;
2495 double MPOBasisStateProbability(
void *obj,
long long state)
const
2497 return obj && fMPOBasisStateProbability ? fMPOBasisStateProbability(obj, state) : 0.0;
2500 bool MPOAllProbabilities(
void *obj,
double *values)
2502 return obj && fMPOAllProbabilities && fMPOAllProbabilities(obj, values) == 1;
2505 double MPOExpectationValue(
void *obj,
const char *pauli,
int len)
const
2507 return obj && fMPOExpectationValue ? fMPOExpectationValue(obj, pauli, len) : 0.0;
2510 double MPOQubitProbability0(
void *obj,
unsigned int q)
const
2512 return obj && fMPOQubitProbability0 ? fMPOQubitProbability0(obj, q) : 0.;
2515 bool MPOPartialTrace(
void *obj,
const int *q,
int n,
double *out)
2517 return obj && fMPOPartialTrace && fMPOPartialTrace(obj, q, n, out) == 1;
2520 bool MPOHilbertSchmidtOverlap(
void *obj,
void *other,
double *re,
double *im)
2522 return obj && other && fMPOHilbertSchmidtOverlap && fMPOHilbertSchmidtOverlap(obj, other, re, im) == 1;
2525 bool MPOFidelityWithStatevector(
void *obj,
const double *state,
double *out)
2527 return obj && fMPOFidelityWithStatevector && fMPOFidelityWithStatevector(obj, state, out) == 1;
2530 double MPOTrace(
void *obj)
const
2532 return obj && fMPOTrace ? fMPOTrace(obj) : 0.;
2535 double MPOPurity(
void *obj)
const
2537 return obj && fMPOPurity ? fMPOPurity(obj) : 0.;
2540 double MPOHermiticityResidual(
void *obj)
const
2542 return obj && fMPOHermiticityResidual ? fMPOHermiticityResidual(obj) : 0.;
2545 bool MPOIsHermitian(
void *obj,
double eps)
const
2547 return obj && fMPOIsHermitian && fMPOIsHermitian(obj, eps) == 1;
2550 double MPOTraceOfSquare(
void *obj)
const
2552 return obj && fMPOTraceOfSquare ? fMPOTraceOfSquare(obj) : 0.;
2555 MPO_BOOL0(MPORestoreTrace) MPO_BOOL0(MPOHermitize) MPO_BOOL1(MPOSetKrausCompletenessCheck,
int)
int MPOGetKrausCompletenessCheck(
void *obj)
const
2557 return obj && fMPOGetKrausCompletenessCheck ? fMPOGetKrausCompletenessCheck(obj) : -1;
2560 bool MPOApplyKraus(
void *obj,
int n,
const int *qubits,
int count,
const double *operators)
2562 return obj && fMPOApplyKraus && fMPOApplyKraus(obj, n, qubits, count, operators) == 1;
2564 MPO_BOOL1(MPOApplyReset,
int)
2566 MPO_BOOL2(MPOApplyBitFlipNoise,
int,
double)
2568 MPO_BOOL2(MPOApplyPhaseFlipNoise,
int,
double)
2570 MPO_BOOL2(MPOApplyDepolarizingNoise,
int,
double)
2572 MPO_BOOL2(MPOApplyAmplitudeDamping,
int,
double)
2574 MPO_BOOL2(MPOApplyPhaseDamping,
int,
double)
2576 MPO_BOOL1(MPOApplyNonSelectiveMeasurement,
int)
2578 MPO_BOOL1(MPOApplyX,
int)
2580 MPO_BOOL1(MPOApplyY,
int)
2582 MPO_BOOL1(MPOApplyZ,
int)
2584 MPO_BOOL1(MPOApplyH,
int)
2586 MPO_BOOL1(MPOApplyS,
int)
2588 MPO_BOOL1(MPOApplySDG,
int)
2590 MPO_BOOL1(MPOApplyT,
int)
2592 MPO_BOOL1(MPOApplyTDG,
int)
2594 MPO_BOOL1(MPOApplySX,
int)
2596 MPO_BOOL1(MPOApplySXDG,
int)
2598 MPO_BOOL1(MPOApplyK,
int)
2600 MPO_BOOL2(MPOApplyP,
int,
double)
2602 MPO_BOOL2(MPOApplyRx,
int,
double)
2604 MPO_BOOL2(MPOApplyRy,
int,
double) MPO_BOOL2(MPOApplyRz,
int,
double)
bool MPOApplyU(
void *o,
int q,
double a,
double b,
double c,
double d)
2606 return o && fMPOApplyU && fMPOApplyU(o, q, a, b, c, d) == 1;
2609 bool MPOApplyOneQubitMatrix(
void *obj,
int qubit,
const double *matrixInterleaved)
2611 return obj && fMPOApplyOneQubitMatrix && fMPOApplyOneQubitMatrix(obj, qubit, matrixInterleaved) == 1;
2614 bool MPOApplyTwoQubitMatrix(
void *obj,
int qubit1,
int qubit2,
const double *matrixInterleaved)
2616 return obj && fMPOApplyTwoQubitMatrix && fMPOApplyTwoQubitMatrix(obj, qubit1, qubit2, matrixInterleaved) == 1;
2619 MPO_BOOL2(MPOApplyCX,
int,
int)
2621 MPO_BOOL2(MPOApplyCY,
int,
int)
2623 MPO_BOOL2(MPOApplyCZ,
int,
int)
2625 MPO_BOOL2(MPOApplyCH,
int,
int)
2627 MPO_BOOL2(MPOApplyCSX,
int,
int)
2629 MPO_BOOL2(MPOApplyCSXDG,
int,
int)
2631 MPO_BOOL3(MPOApplyCP,
int,
int,
double)
2633 MPO_BOOL3(MPOApplyCRx,
int,
int,
double)
2635 MPO_BOOL3(MPOApplyCRy,
int,
int,
double)
2637 MPO_BOOL3(MPOApplyCRz,
int,
int,
double) MPO_BOOL2(MPOApplySwap,
int,
int)
bool MPOApplyCU(
void *o,
int c,
int t,
double a,
double b,
double d,
double g)
2639 return o && fMPOApplyCU && fMPOApplyCU(o, c, t, a, b, d, g) == 1;
2649 void *(*fCreateDensityMatrix)(
void *) =
nullptr;
2650 void (*fDestroyDensityMatrix)(
void *) =
nullptr;
2651 int (*fDMCreate)(
void *,
unsigned int) =
nullptr;
2652 int (*fDMCreateWithState)(
void *,
unsigned int,
const double *) =
nullptr;
2653 int (*fDMCreateWithBasisState)(
void *,
unsigned int,
unsigned long long) =
nullptr;
2654 int (*fDMCreateWithMixtureOfBasisStates)(
void *,
unsigned int,
const unsigned long long *,
const double *, int) =
nullptr;
2655 int (*fDMReset)(
void *) =
nullptr;
2656 int (*fDMIsValid)(
void *) =
nullptr;
2657 int (*fDMIsCreated)(
void *) =
nullptr;
2658 int (*fDMSetDataType)(
void *, int) =
nullptr;
2659 int (*fDMIsDoublePrecision)(
void *) =
nullptr;
2660 int (*fDMGetNrQubits)(
void *) =
nullptr;
2661 int (*fDMSaveState)(
void *) =
nullptr;
2662 int (*fDMRestoreState)(
void *) =
nullptr;
2663 int (*fDMCleanSavedState)(
void *) =
nullptr;
2664 void *(*fDMClone)(
void *) =
nullptr;
2665 int (*fDMSetSeed)(
void *,
unsigned long long) =
nullptr;
2666 int (*fDMMeasureQubitCollapse)(
void *, int) =
nullptr;
2667 int (*fDMMeasureQubitNoCollapse)(
void *, int) =
nullptr;
2668 int (*fDMMeasureQubitsCollapse)(
void *,
int *,
int *, int) =
nullptr;
2669 int (*fDMMeasureQubitsNoCollapse)(
void *,
int *,
int *, int) =
nullptr;
2670 unsigned long long (*fDMMeasureAllQubitsCollapse)(
void *) =
nullptr;
2671 unsigned long long (*fDMMeasureAllQubitsNoCollapse)(
void *) =
nullptr;
2672 int (*fDMSample)(
void *,
unsigned int,
long int *,
unsigned int,
int *) =
nullptr;
2673 int (*fDMSampleAll)(
void *,
unsigned int,
long int *) =
nullptr;
2674 int (*fDMGetElement)(
void *,
long long,
long long,
double *,
double *) =
nullptr;
2675 double (*fDMBasisStateProbability)(
void *,
long long) =
nullptr;
2676 int (*fDMAllProbabilities)(
void *,
double *) =
nullptr;
2677 double (*fDMExpectationValue)(
void *,
const char *, int) =
nullptr;
2678 double (*fDMQubitProbability0)(
void *,
unsigned int) =
nullptr;
2679 double (*fDMTrace)(
void *) =
nullptr;
2680 double (*fDMPurity)(
void *) =
nullptr;
2681 int (*fDMIsHermitian)(
void *, double) =
nullptr;
2682 int (*fDMPartialTrace)(
void *,
const int *, int,
double *) =
nullptr;
2683 int (*fDMHilbertSchmidtOverlap)(
void *,
void *,
double *,
double *) =
nullptr;
2684 int (*fDMFidelityWithStatevector)(
void *,
const double *,
double *) =
nullptr;
2685 int (*fDMApplyKraus)(
void *, int,
const int *, int,
const double *) =
nullptr;
2686 int (*fDMApplyReset)(
void *, int) =
nullptr;
2687#define DECL_DM1(name) int (*f##name)(void *, int) = nullptr
2688#define DECL_DM2(name) int (*f##name)(void *, int, int) = nullptr
2689#define DECL_DMR1(name) int (*f##name)(void *, int, double) = nullptr
2690#define DECL_DMR2(name) int (*f##name)(void *, int, int, double) = nullptr
2691 DECL_DMR1(DMApplyBitFlipNoise);
2692 DECL_DMR1(DMApplyPhaseFlipNoise);
2693 DECL_DMR1(DMApplyDepolarizingNoise);
2694 DECL_DMR1(DMApplyAmplitudeDamping);
2695 DECL_DMR1(DMApplyPhaseDamping);
2696 DECL_DM1(DMApplyNonSelectiveMeasurement);
2702 DECL_DM1(DMApplySDG);
2704 DECL_DM1(DMApplyTDG);
2705 DECL_DM1(DMApplySX);
2706 DECL_DM1(DMApplySXDG);
2708 DECL_DMR1(DMApplyP);
2709 DECL_DMR1(DMApplyRx);
2710 DECL_DMR1(DMApplyRy);
2711 DECL_DMR1(DMApplyRz);
2712 int (*fDMApplyU)(
void *, int, double, double, double, double) =
nullptr;
2713 DECL_DM2(DMApplyCX);
2714 DECL_DM2(DMApplyCY);
2715 DECL_DM2(DMApplyCZ);
2716 DECL_DM2(DMApplyCH);
2717 DECL_DM2(DMApplyCSX);
2718 DECL_DM2(DMApplyCSXDG);
2719 DECL_DMR2(DMApplyCP);
2720 DECL_DMR2(DMApplyCRx);
2721 DECL_DMR2(DMApplyCRy);
2722 DECL_DMR2(DMApplyCRz);
2723 int (*fDMApplyCCX)(
void *, int, int, int) =
nullptr;
2724 DECL_DM2(DMApplySwap);
2725 int (*fDMApplyCSwap)(
void *, int, int, int) =
nullptr;
2726 int (*fDMApplyCU)(
void *, int, int, double, double, double, double) =
nullptr;
2734 void *(*fCreateMPO)(
void *) =
nullptr;
2735 void (*fDestroyMPO)(
void *) =
nullptr;
2736 int (*fMPOCreate)(
void *,
unsigned int) =
nullptr;
2737 int (*fMPOCreateWithState)(
void *,
unsigned int,
const double *) =
nullptr;
2738 int (*fMPOCreateWithBasisState)(
void *,
unsigned int,
unsigned long long) =
nullptr;
2739 int (*fMPOCreateWithBasisStateBits)(
void *,
unsigned int,
const unsigned char *) =
nullptr;
2740 int (*fMPOCreateWithMixtureOfBasisStates)(
void *,
unsigned int,
const unsigned long long *,
const double *, int) =
nullptr;
2741 int (*fMPOCreateWithMixtureOfBasisStatesBits)(
void *,
unsigned int,
const unsigned char *,
const double *, int) =
nullptr;
2742 int (*fMPOReset)(
void *) =
nullptr;
2743 int (*fMPOSetInitialQubitsMap)(
void *,
const long long int *, int) =
nullptr;
2744 int (*fMPOSetUseOptimalMeetingPosition)(
void *, int) =
nullptr;
2745 int (*fMPOGetUseOptimalMeetingPosition)(
void *) =
nullptr;
2746 int (*fMPOIsValid)(
void *) =
nullptr;
2747 int (*fMPOIsCreated)(
void *) =
nullptr;
2748 int (*fMPOSetDataType)(
void *, int) =
nullptr;
2749 int (*fMPOIsDoublePrecision)(
void *) =
nullptr;
2750 int (*fMPOGetNrQubits)(
void *) =
nullptr;
2751 int (*fMPOSetCutoff)(
void *, double) =
nullptr;
2752 double (*fMPOGetCutoff)(
void *) =
nullptr;
2753 int (*fMPOSetTruncationMode)(
void *, int) =
nullptr;
2754 int (*fMPOGetTruncationMode)(
void *) =
nullptr;
2755 int (*fMPOSetGesvdJ)(
void *, int) =
nullptr;
2756 int (*fMPOGetGesvdJ)(
void *) =
nullptr;
2757 int (*fMPOSetGesvdP)(
void *, int) =
nullptr;
2758 int (*fMPOGetGesvdP)(
void *) =
nullptr;
2759 int (*fMPOSetGesvdR)(
void *, int) =
nullptr;
2760 int (*fMPOGetGesvdR)(
void *) =
nullptr;
2761 int (*fMPOGetLastSvdAlgo)(
void *) =
nullptr;
2762 int (*fMPOSetMaxExtent)(
void *,
long int) =
nullptr;
2763 long int (*fMPOGetMaxExtent)(
void *) =
nullptr;
2764 int (*fMPOGetBondDimensions)(
void *,
long long int *) =
nullptr;
2765 int (*fMPOGetQubitsMap)(
void *,
long long *, int) =
nullptr;
2766 int (*fMPOSetCallbackContext)(
void *,
void *) =
nullptr;
2767 int (*fMPOSetMeetingPositionCallback)(
void *, int64_t (*)(
void *,
const int64_t *)) =
nullptr;
2768 int (*fMPOSetBondDimensionsCallback)(
void *, void (*)(
void *,
const int64_t *)) =
nullptr;
2769 int (*fMPOSampleBits)(
void *,
unsigned int,
unsigned int,
const int *,
unsigned char *) =
nullptr;
2770 void *(*fMPOGetMapForSample)() =
nullptr;
2771 int (*fMPOFreeMapForSample)(
void *) =
nullptr;
2772 int (*fMPOSampleHistogram)(
void *,
long int,
long int,
unsigned int *,
void *) =
nullptr;
2773 int (*fMPOGetElementBits)(
void *,
const unsigned char *,
const unsigned char *,
double *,
double *) =
nullptr;
2774 double (*fMPOBasisStateProbabilityBits)(
void *,
const unsigned char *) =
nullptr;
2775 int (*fMPOExpectationValueComplex)(
void *,
const char *, int,
double *,
double *) =
nullptr;
2776 int (*fMPOUnnormalizedExpectationValue)(
void *,
const char *, int,
double *,
double *) =
nullptr;
2777 int (*fMPOGetDensityMatrix)(
void *,
double *) =
nullptr;
2778 int (*fMPOGetUnnormalizedDensityMatrix)(
void *,
double *) =
nullptr;
2779 int (*fMPOTraceComplex)(
void *,
double *,
double *) =
nullptr;
2780 int (*fMPOSetRestoreTraceAfterTruncation)(
void *, int) =
nullptr;
2781 int (*fMPOGetRestoreTraceAfterTruncation)(
void *) =
nullptr;
2782 int (*fMPOSetHermitizeAfterTruncation)(
void *, int) =
nullptr;
2783 int (*fMPOGetHermitizeAfterTruncation)(
void *) =
nullptr;
2784 int (*fMPOMoveAtBeginningOfChain)(
void *,
const int *, int) =
nullptr;
2785 int (*fMPOApplyOperator)(
void *, int,
const int *,
const double *) =
nullptr;
2786 int (*fMPOApplyOperatorAndNormalize)(
void *, int,
const int *,
const double *) =
nullptr;
2787 int (*fMPOReCanonicalize)(
void *) =
nullptr;
2788 int (*fMPOTrim)(
void *, double,
long int) =
nullptr;
2789 int (*fMPOSaveState)(
void *) =
nullptr;
2790 int (*fMPORestoreState)(
void *) =
nullptr;
2791 int (*fMPOCleanSavedState)(
void *) =
nullptr;
2792 void *(*fMPOClone)(
void *) =
nullptr;
2793 int (*fMPOSetSeed)(
void *,
unsigned long long) =
nullptr;
2794 int (*fMPOMeasureQubitCollapse)(
void *, int) =
nullptr;
2795 int (*fMPOMeasureQubitNoCollapse)(
void *, int) =
nullptr;
2796 int (*fMPOMeasureQubitsCollapse)(
void *,
int *,
int *, int) =
nullptr;
2797 int (*fMPOMeasureQubitsNoCollapse)(
void *,
int *,
int *, int) =
nullptr;
2798 unsigned long long (*fMPOMeasureAllQubitsCollapse)(
void *) =
nullptr;
2799 unsigned long long (*fMPOMeasureAllQubitsNoCollapse)(
void *) =
nullptr;
2800 int (*fMPOSample)(
void *,
unsigned int,
long int *,
unsigned int,
int *) =
nullptr;
2801 int (*fMPOSampleAll)(
void *,
unsigned int,
long int *) =
nullptr;
2802 int (*fMPOGetElement)(
void *,
long long,
long long,
double *,
double *) =
nullptr;
2803 double (*fMPOBasisStateProbability)(
void *,
long long) =
nullptr;
2804 int (*fMPOAllProbabilities)(
void *,
double *) =
nullptr;
2805 double (*fMPOExpectationValue)(
void *,
const char *, int) =
nullptr;
2806 double (*fMPOQubitProbability0)(
void *,
unsigned int) =
nullptr;
2807 int (*fMPOPartialTrace)(
void *,
const int *, int,
double *) =
nullptr;
2808 int (*fMPOHilbertSchmidtOverlap)(
void *,
void *,
double *,
double *) =
nullptr;
2809 int (*fMPOFidelityWithStatevector)(
void *,
const double *,
double *) =
nullptr;
2810 double (*fMPOTrace)(
void *) =
nullptr;
2811 double (*fMPOPurity)(
void *) =
nullptr;
2812 double (*fMPOHermiticityResidual)(
void *) =
nullptr;
2813 int (*fMPOIsHermitian)(
void *, double) =
nullptr;
2814 double (*fMPOTraceOfSquare)(
void *) =
nullptr;
2815 int (*fMPORestoreTrace)(
void *) =
nullptr;
2816 int (*fMPOHermitize)(
void *) =
nullptr;
2817 int (*fMPOSetKrausCompletenessCheck)(
void *, int) =
nullptr;
2818 int (*fMPOGetKrausCompletenessCheck)(
void *) =
nullptr;
2819 int (*fMPOApplyKraus)(
void *, int,
const int *, int,
const double *) =
nullptr;
2820 int (*fMPOApplyReset)(
void *, int) =
nullptr;
2821#define DECL_MPO1(name) int (*f##name)(void *, int) = nullptr
2822#define DECL_MPO2(name) int (*f##name)(void *, int, int) = nullptr
2823#define DECL_MPOR1(name) int (*f##name)(void *, int, double) = nullptr
2824#define DECL_MPOR2(name) int (*f##name)(void *, int, int, double) = nullptr
2825 DECL_MPOR1(MPOApplyBitFlipNoise);
2826 DECL_MPOR1(MPOApplyPhaseFlipNoise);
2827 DECL_MPOR1(MPOApplyDepolarizingNoise);
2828 DECL_MPOR1(MPOApplyAmplitudeDamping);
2829 DECL_MPOR1(MPOApplyPhaseDamping);
2830 DECL_MPO1(MPOApplyNonSelectiveMeasurement);
2831 DECL_MPO1(MPOApplyX);
2832 DECL_MPO1(MPOApplyY);
2833 DECL_MPO1(MPOApplyZ);
2834 DECL_MPO1(MPOApplyH);
2835 DECL_MPO1(MPOApplyS);
2836 DECL_MPO1(MPOApplySDG);
2837 DECL_MPO1(MPOApplyT);
2838 DECL_MPO1(MPOApplyTDG);
2839 DECL_MPO1(MPOApplySX);
2840 DECL_MPO1(MPOApplySXDG);
2841 DECL_MPO1(MPOApplyK);
2842 DECL_MPOR1(MPOApplyP);
2843 DECL_MPOR1(MPOApplyRx);
2844 DECL_MPOR1(MPOApplyRy);
2845 DECL_MPOR1(MPOApplyRz);
2846 int (*fMPOApplyU)(
void *, int, double, double, double, double) =
nullptr;
2847 int (*fMPOApplyOneQubitMatrix)(
void *, int,
const double *) =
nullptr;
2848 int (*fMPOApplyTwoQubitMatrix)(
void *, int, int,
const double *) =
nullptr;
2849 DECL_MPO2(MPOApplyCX);
2850 DECL_MPO2(MPOApplyCY);
2851 DECL_MPO2(MPOApplyCZ);
2852 DECL_MPO2(MPOApplyCH);
2853 DECL_MPO2(MPOApplyCSX);
2854 DECL_MPO2(MPOApplyCSXDG);
2855 DECL_MPOR2(MPOApplyCP);
2856 DECL_MPOR2(MPOApplyCRx);
2857 DECL_MPOR2(MPOApplyCRy);
2858 DECL_MPOR2(MPOApplyCRz);
2859 DECL_MPO2(MPOApplySwap);
2860 int (*fMPOApplyCU)(
void *, int, int, double, double, double, double) =
nullptr;
2872 return fCreateMPS(LibraryHandle);
2874 throw std::runtime_error(
"GpuLibrary: Unable to create mps");
2877 void DestroyMPS(
void *obj)
2882 throw std::runtime_error(
"GpuLibrary: Unable to destroy mps");
2885 bool MPSCreate(
void *obj,
unsigned int nrQubits)
2888 return fMPSCreate(obj, nrQubits) == 1;
2890 throw std::runtime_error(
"GpuLibrary: Unable to create mps with the "
2891 "specified number of qubits");
2896 bool MPSCreateWithBasisState(
void *obj,
unsigned int nrQubits,
unsigned long long state)
2899 return fMPSCreateWithBasisState(obj, nrQubits, state) == 1;
2901 throw std::runtime_error(
"GpuLibrary: Unable to create mps with a basis state");
2906 bool MPSCreateWithBasisStateBits(
void *obj,
unsigned int nrQubits,
const unsigned char *stateBits)
2909 return fMPSCreateWithBasisStateBits(obj, nrQubits, stateBits) == 1;
2911 throw std::runtime_error(
"GpuLibrary: Unable to create mps with a basis state (bits)");
2916 bool MPSReset(
void *obj)
2919 return fMPSReset(obj) == 1;
2921 throw std::runtime_error(
"GpuLibrary: Unable to reset mps");
2927 bool HasMPSCompressionAPI()
const
2929 return IsValid() && fMPSTrim && fMPSReCanonicalize;
2932 bool MPSTrim(
void *obj)
2935 throw std::runtime_error(
"GpuLibrary: this library cannot trim an mps");
2936 return obj && fMPSTrim(obj) == 1;
2939 bool MPSReCanonicalize(
void *obj)
2941 if (!fMPSReCanonicalize)
2942 throw std::runtime_error(
"GpuLibrary: this library cannot recanonicalize an mps");
2943 return obj && fMPSReCanonicalize(obj) == 1;
2946 bool MPSSetInitialQubitsMap(
void *obj,
const std::vector<long long int> &initialMap)
2949 return fMPSSetInitialQubitsMap(obj, initialMap.data(), initialMap.size()) == 1;
2951 throw std::runtime_error(
"GpuLibrary: Unable to set initial qubits map for mps");
2956 bool MPSSetUseOptimalMeetingPosition(
void *obj,
int val)
2959 return fMPSSetUseOptimalMeetingPosition(obj, val) == 1;
2961 throw std::runtime_error(
"GpuLibrary: Unable to set use optimal meeting position for mps");
2965 bool MPSGetUseOptimalMeetingPosition(
void *obj)
const
2968 return fMPSGetUseOptimalMeetingPosition(obj) == 1;
2970 throw std::runtime_error(
"GpuLibrary: Unable to get use optimal meeting position for mps");
2974 bool MPSIsValid(
void *obj)
const
2977 return fMPSIsValid(obj) == 1;
2979 throw std::runtime_error(
"GpuLibrary: Unable to check if mps is valid");
2984 bool MPSIsCreated(
void *obj)
const
2987 return fMPSIsCreated(obj) == 1;
2989 throw std::runtime_error(
"GpuLibrary: Unable to check if mps is created");
2994 bool MPSSetDataType(
void *obj,
int useDoublePrecision)
2997 return fMPSSetDataType(obj, useDoublePrecision) == 1;
2999 throw std::runtime_error(
"GpuLibrary: Unable to set precision for mps");
3004 bool MPSIsDoublePrecision(
void *obj)
const
3007 return fMPSIsDoublePrecision(obj) == 1;
3009 throw std::runtime_error(
"GpuLibrary: Unable to get precision for mps");
3014 bool MPSSetCutoff(
void *obj,
double val)
3017 return fMPSSetCutoff(obj, val) == 1;
3019 throw std::runtime_error(
"GpuLibrary: Unable to set cutoff for mps");
3024 double MPSGetCutoff(
void *obj)
const
3027 return fMPSGetCutoff(obj);
3029 throw std::runtime_error(
"GpuLibrary: Unable to get cutoff for mps");
3032 bool MPSSetTruncationMode(
void *obj,
int mode)
3035 return fMPSSetTruncationMode(obj, mode) == 1;
3037 throw std::runtime_error(
"GpuLibrary: Unable to set truncation mode for mps");
3042 int MPSGetTruncationMode(
void *obj)
const
3045 return fMPSGetTruncationMode(obj);
3047 throw std::runtime_error(
"GpuLibrary: Unable to get truncation mode for mps");
3050 bool MPSSetGesvdJ(
void *obj,
int val)
3052 if (LibraryHandle && obj && fMPSSetGesvdJ)
3053 return fMPSSetGesvdJ(obj, val) == 1;
3055 throw std::runtime_error(
"GpuLibrary: Unable to set GesvdJ for mps");
3060 bool MPSGetGesvdJ(
void *obj)
const
3062 if (LibraryHandle && obj && fMPSGetGesvdJ)
3063 return fMPSGetGesvdJ(obj) == 1;
3065 throw std::runtime_error(
"GpuLibrary: Unable to get GesvdJ for mps");
3070 bool MPSSetGesvdP(
void *obj,
int val)
3072 return LibraryHandle && obj && fMPSSetGesvdP && fMPSSetGesvdP(obj, val) == 1;
3075 bool MPSGetGesvdP(
void *obj)
const
3077 if (!LibraryHandle || !obj || !fMPSGetGesvdP)
3078 throw std::runtime_error(
"GpuLibrary: MPSGetGesvdP is unavailable");
3079 return fMPSGetGesvdP(obj) == 1;
3082 bool MPSSetGesvdR(
void *obj,
int val)
3084 return LibraryHandle && obj && fMPSSetGesvdR && fMPSSetGesvdR(obj, val) == 1;
3087 bool MPSGetGesvdR(
void *obj)
const
3089 if (!LibraryHandle || !obj || !fMPSGetGesvdR)
3090 throw std::runtime_error(
"GpuLibrary: MPSGetGesvdR is unavailable");
3091 return fMPSGetGesvdR(obj) == 1;
3095 int MPSGetLastSvdAlgo(
void *obj)
const
3097 if (!LibraryHandle || !obj || !fMPSGetLastSvdAlgo)
3098 throw std::runtime_error(
"GpuLibrary: MPSGetLastSvdAlgo is unavailable");
3099 return fMPSGetLastSvdAlgo(obj);
3102 bool MPSSetMaxExtent(
void *obj,
long int val)
3105 return fMPSSetMaxExtent(obj, val) == 1;
3107 throw std::runtime_error(
"GpuLibrary: Unable to set max extent for mps");
3112 long int MPSGetMaxExtent(
void *obj)
3115 return fMPSGetMaxExtent(obj);
3117 throw std::runtime_error(
"GpuLibrary: Unable to get max extent for mps");
3122 int MPSGetNrQubits(
void *obj)
3125 return fMPSGetNrQubits(obj);
3127 throw std::runtime_error(
"GpuLibrary: Unable to get nr qubits for mps");
3132 bool MPSGetBondDimensions(
void *obj,
long long int *bondDims)
3135 return fMPSGetBondDimensions(obj, bondDims) == 1;
3137 throw std::runtime_error(
"GpuLibrary: Unable to get bond dimensions for mps");
3142 bool MPSGetQubitsMap(
void *obj,
long long *map,
int size)
const
3144 return obj && fMPSGetQubitsMap && fMPSGetQubitsMap(obj, map, size) == 1;
3147 bool MPSSetCallbackContext(
void *obj,
void *context)
3150 return fMPSSetCallbackContext(obj, context) == 1;
3152 throw std::runtime_error(
"GpuLibrary: Unable to set callback context for mps");
3156 bool MPSSetMeetingPositionCallback(
void *obj, int64_t (*callback)(
void *,
const int64_t *))
3159 return fMPSSetMeetingPositionCallback(obj, callback) == 1;
3161 throw std::runtime_error(
"GpuLibrary: Unable to set meeting position callback for mps");
3165 bool MPSSetBondDimensionsCallback(
void *obj,
void (*callback)(
void *,
const int64_t *))
3168 return fMPSSetBondDimensionsCallback(obj, callback) == 1;
3170 throw std::runtime_error(
"GpuLibrary: Unable to set bond dimensions callback for mps");
3174 bool MPSAmplitude(
void *obj,
long int numFixedValues,
long int *fixedValues,
double *real,
double *imaginary)
3177 return fMPSAmplitude(obj, numFixedValues, fixedValues, real, imaginary) == 1;
3179 throw std::runtime_error(
"GpuLibrary: Unable to get mps amplitude");
3184 double MPSProbability0(
void *obj,
unsigned int qubit)
3187 return fMPSProbability0(obj, qubit);
3189 throw std::runtime_error(
"GpuLibrary: Unable to get probability for 0 for mps");
3194 bool MPSMeasure(
void *obj,
unsigned int qubit)
3197 return fMPSMeasure(obj, qubit) == 1;
3199 throw std::runtime_error(
"GpuLibrary: Unable to measure qubit on mps");
3204 bool MPSMeasureQubits(
void *obj,
long int numQubits,
unsigned int *qubits,
int *result)
3207 return fMPSMeasureQubits(obj, numQubits, qubits, result) == 1;
3209 throw std::runtime_error(
"GpuLibrary: Unable to measure qubits on mps");
3214 std::unordered_map<std::vector<bool>, int64_t> *MPSGetMapForSample()
3217 return (std::unordered_map<std::vector<bool>, int64_t> *)fMPSGetMapForSample();
3219 throw std::runtime_error(
"GpuLibrary: Unable to get map for sample for mps");
3224 bool MPSFreeMapForSample(std::unordered_map<std::vector<bool>, int64_t> *map)
3227 return fMPSFreeMapForSample((
void *)map) == 1;
3229 throw std::runtime_error(
"GpuLibrary: Unable to free map for sample for mps");
3234 bool MPSSample(
void *obj,
long int numShots,
long int numQubits,
unsigned int *qubits,
void *resultMap)
3237 return fMPSSample(obj, numShots, numQubits, qubits, resultMap) == 1;
3239 throw std::runtime_error(
"GpuLibrary: Unable to sample mps");
3244 bool MPSSampleRaw(
void *obj,
unsigned int nSamples,
long int *samples,
unsigned int nBits,
const unsigned int *bitOrdering)
3247 return fMPSSampleRaw(obj, nSamples, samples, nBits, bitOrdering) == 1;
3249 throw std::runtime_error(
"GpuLibrary: Unable to raw-sample mps");
3254 bool MPSSampleAll(
void *obj,
unsigned int nSamples,
long int *samples)
3257 return fMPSSampleAll(obj, nSamples, samples) == 1;
3259 throw std::runtime_error(
"GpuLibrary: Unable to sample all for mps");
3264 bool MPSSaveState(
void *obj)
3267 return fMPSSaveState(obj) == 1;
3269 throw std::runtime_error(
"GpuLibrary: Unable to save mps state");
3274 bool MPSRestoreState(
void *obj)
3277 return fMPSRestoreState(obj) == 1;
3279 throw std::runtime_error(
"GpuLibrary: Unable to restore mps state");
3284 bool MPSCleanSavedState(
void *obj)
3287 return fMPSCleanSavedState(obj) == 1;
3289 throw std::runtime_error(
"GpuLibrary: Unable to clean mps saved state");
3294 void *MPSClone(
void *obj)
3297 return fMPSClone(obj);
3299 throw std::runtime_error(
"GpuLibrary: Unable to clone mps");
3304 bool MPSSetSeed(
void *obj,
unsigned long long seed)
const
3306 return obj && fMPSSetSeed && fMPSSetSeed(obj, seed) == 1;
3309 double MPSExpectationValue(
void *obj,
const char *pauliString,
int len)
const
3312 return fMPSExpectationValue(obj, pauliString, len);
3314 throw std::runtime_error(
"GpuLibrary: Unable to get mps expectation value");
3319 std::complex<double> MPSProjectOnZero(
void *obj)
3324 if (fMPSProjectOnZero(obj, &real, &imag) == 1)
3325 return std::complex<double>(real, imag);
3327 throw std::runtime_error(
"GpuLibrary: Unable to project on zero for mps");
3330 throw std::runtime_error(
"GpuLibrary: Unable to project on zero for mps, library handle is null");
3332 return std::complex<double>(0, 0);
3335 bool MPSApplyX(
void *obj,
unsigned int siteA)
3338 return fMPSApplyX(obj, siteA) == 1;
3340 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate on mps");
3345 bool MPSApplyY(
void *obj,
unsigned int siteA)
3348 return fMPSApplyY(obj, siteA) == 1;
3350 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate on mps");
3355 bool MPSApplyZ(
void *obj,
unsigned int siteA)
3358 return fMPSApplyZ(obj, siteA) == 1;
3360 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate on mps");
3365 bool MPSApplyH(
void *obj,
unsigned int siteA)
3368 return fMPSApplyH(obj, siteA) == 1;
3370 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate on mps");
3375 bool MPSApplyS(
void *obj,
unsigned int siteA)
3378 return fMPSApplyS(obj, siteA) == 1;
3380 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate on mps");
3385 bool MPSApplySDG(
void *obj,
unsigned int siteA)
3388 return fMPSApplySDG(obj, siteA) == 1;
3390 throw std::runtime_error(
"GpuLibrary: Unable to apply sdg gate on mps");
3395 bool MPSApplyT(
void *obj,
unsigned int siteA)
3398 return fMPSApplyT(obj, siteA) == 1;
3400 throw std::runtime_error(
"GpuLibrary: Unable to apply t gate on mps");
3405 bool MPSApplyTDG(
void *obj,
unsigned int siteA)
3408 return fMPSApplyTDG(obj, siteA) == 1;
3410 throw std::runtime_error(
"GpuLibrary: Unable to appl tdg gate on mps");
3415 bool MPSApplySX(
void *obj,
unsigned int siteA)
3418 return fMPSApplySX(obj, siteA) == 1;
3420 throw std::runtime_error(
"GpuLibrary: Unable to apply sx gate on mps");
3425 bool MPSApplySXDG(
void *obj,
unsigned int siteA)
3428 return fMPSApplySXDG(obj, siteA) == 1;
3430 throw std::runtime_error(
"GpuLibrary: Unable to apply sxdg gate on mps");
3435 bool MPSApplyK(
void *obj,
unsigned int siteA)
3438 return fMPSApplyK(obj, siteA) == 1;
3440 throw std::runtime_error(
"GpuLibrary: Unable to apply k gate on mps");
3445 bool MPSApplyP(
void *obj,
unsigned int siteA,
double theta)
3448 return fMPSApplyP(obj, siteA, theta) == 1;
3450 throw std::runtime_error(
"GpuLibrary: Unable to apply p gate on mps");
3454 bool MPSApplyRx(
void *obj,
unsigned int siteA,
double theta)
3457 return fMPSApplyRx(obj, siteA, theta) == 1;
3459 throw std::runtime_error(
"GpuLibrary: Unable to apply rx gate on mps");
3464 bool MPSApplyRy(
void *obj,
unsigned int siteA,
double theta)
3467 return fMPSApplyRy(obj, siteA, theta) == 1;
3469 throw std::runtime_error(
"GpuLibrary: Unable to apply ry gate on mps");
3474 bool MPSApplyRz(
void *obj,
unsigned int siteA,
double theta)
3477 return fMPSApplyRz(obj, siteA, theta) == 1;
3479 throw std::runtime_error(
"GpuLibrary: Unable to apply rz gate on mps");
3484 bool MPSApplyU(
void *obj,
unsigned int siteA,
double theta,
double phi,
double lambda,
double gamma)
3487 return fMPSApplyU(obj, siteA, theta, phi, lambda, gamma) == 1;
3489 throw std::runtime_error(
"GpuLibrary: Unable to apply u gate on mps");
3494 bool MPSApplyOneQubitMatrix(
void *obj,
unsigned int qubit,
const double *matrixInterleaved)
3497 return fMPSApplyOneQubitMatrix(obj, qubit, matrixInterleaved) == 1;
3499 throw std::runtime_error(
"GpuLibrary: Unable to apply one-qubit matrix on mps");
3504 bool MPSApplyTwoQubitMatrix(
void *obj,
unsigned int qubit1,
unsigned int qubit2,
const double *matrixInterleaved)
3507 return fMPSApplyTwoQubitMatrix(obj, qubit1, qubit2, matrixInterleaved) == 1;
3509 throw std::runtime_error(
"GpuLibrary: Unable to apply two-qubit matrix on mps");
3514 bool MPSApplySwap(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
3517 return fMPSApplySwap(obj, controlQubit, targetQubit) == 1;
3519 throw std::runtime_error(
"GpuLibrary: Unable to apply swap gate on mps");
3524 bool MPSApplyCX(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
3527 return fMPSApplyCX(obj, controlQubit, targetQubit) == 1;
3529 throw std::runtime_error(
"GpuLibrary: Unable to apply cx gate on mps");
3534 bool MPSApplyCY(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
3537 return fMPSApplyCY(obj, controlQubit, targetQubit) == 1;
3539 throw std::runtime_error(
"GpuLibrary: Unable to apply cy gate on mps");
3544 bool MPSApplyCZ(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
3547 return fMPSApplyCZ(obj, controlQubit, targetQubit) == 1;
3549 throw std::runtime_error(
"GpuLibrary: Unable to apply cz gate on mps");
3554 bool MPSApplyCH(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
3557 return fMPSApplyCH(obj, controlQubit, targetQubit) == 1;
3559 throw std::runtime_error(
"GpuLibrary: Unable to apply ch gate on mps");
3564 bool MPSApplyCSX(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
3567 return fMPSApplyCSX(obj, controlQubit, targetQubit) == 1;
3569 throw std::runtime_error(
"GpuLibrary: Unable to apply csx gate on mps");
3572 bool MPSApplyCSXDG(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
3575 return fMPSApplyCSXDG(obj, controlQubit, targetQubit) == 1;
3577 throw std::runtime_error(
"GpuLibrary: Unable to apply csxdg gate on mps");
3582 bool MPSApplyCP(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
double theta)
3585 return fMPSApplyCP(obj, controlQubit, targetQubit, theta) == 1;
3587 throw std::runtime_error(
"GpuLibrary: Unable to apply cp gate on mps");
3592 bool MPSApplyCRx(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
double theta)
3595 return fMPSApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
3597 throw std::runtime_error(
"GpuLibrary: Unable to apply crx gate on mps");
3602 bool MPSApplyCRy(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
double theta)
3605 return fMPSApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
3607 throw std::runtime_error(
"GpuLibrary: Unable to apply cry gate on mps");
3612 bool MPSApplyCRz(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
double theta)
3615 return fMPSApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
3617 throw std::runtime_error(
"GpuLibrary: Unable to apply crz gate on mps");
3622 bool MPSApplyCU(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
double theta,
double phi,
double lambda,
double gamma)
3625 return fMPSApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda, gamma) == 1;
3627 throw std::runtime_error(
"GpuLibrary: Unable to apply cu gate on mps");
3634 void *CreateTensorNet()
3637 return fCreateTensorNet(LibraryHandle);
3639 throw std::runtime_error(
"GpuLibrary: Unable to create tensor network");
3642 void DestroyTensorNet(
void *obj)
3645 fDestroyTensorNet(obj);
3647 throw std::runtime_error(
"GpuLibrary: Unable to destroy tensor network");
3650 bool TNCreate(
void *obj,
unsigned int nrQubits)
3653 return fTNCreate(obj, nrQubits) == 1;
3655 throw std::runtime_error(
"GpuLibrary: Unable to create tensor network with the "
3656 "specified number of qubits");
3661 bool TNReset(
void *obj)
3664 return fTNReset(obj) == 1;
3666 throw std::runtime_error(
"GpuLibrary: Unable to reset tensor network");
3671 bool TNIsValid(
void *obj)
const
3674 return fTNIsValid(obj) == 1;
3676 throw std::runtime_error(
"GpuLibrary: Unable to check if tensor network is valid");
3681 bool TNIsCreated(
void *obj)
const
3684 return fTNIsCreated(obj) == 1;
3686 throw std::runtime_error(
"GpuLibrary: Unable to check if tensor network is created");
3691 bool TNSetDataType(
void *obj,
int useDoublePrecision)
3694 return fTNSetDataType(obj, useDoublePrecision) == 1;
3696 throw std::runtime_error(
"GpuLibrary: Unable to set precision for tensor network");
3701 bool TNIsDoublePrecision(
void *obj)
const
3704 return fTNIsDoublePrecision(obj) == 1;
3706 throw std::runtime_error(
"GpuLibrary: Unable to get precision for tensor network");
3711 bool TNSetCutoff(
void *obj,
double val)
3714 return fTNSetCutoff(obj, val) == 1;
3716 throw std::runtime_error(
"GpuLibrary: Unable to set cutoff for tensor network");
3721 double TNGetCutoff(
void *obj)
const
3724 return fTNGetCutoff(obj);
3726 throw std::runtime_error(
"GpuLibrary: Unable to get cutoff for tensor network");
3729 bool TNSetTruncationMode(
void *obj,
int mode)
3732 return fTNSetTruncationMode(obj, mode) == 1;
3734 throw std::runtime_error(
"GpuLibrary: Unable to set truncation mode for tensor network");
3739 int TNGetTruncationMode(
void *obj)
const
3742 return fTNGetTruncationMode(obj);
3744 throw std::runtime_error(
"GpuLibrary: Unable to get truncation mode for tensor network");
3747 bool TNSetGesvdJ(
void *obj,
int val)
3749 if (LibraryHandle && obj && fTNSetGesvdJ)
3750 return fTNSetGesvdJ(obj, val) == 1;
3752 throw std::runtime_error(
"GpuLibrary: Unable to set GesvdJ for tensor network");
3757 bool TNGetGesvdJ(
void *obj)
const
3759 if (LibraryHandle && obj && fTNGetGesvdJ)
3760 return fTNGetGesvdJ(obj) == 1;
3762 throw std::runtime_error(
"GpuLibrary: Unable to get GesvdJ for tensor network");
3767 bool TNSetGesvdP(
void *obj,
int val)
3769 return LibraryHandle && obj && fTNSetGesvdP && fTNSetGesvdP(obj, val) == 1;
3772 bool TNGetGesvdP(
void *obj)
const
3774 if (!LibraryHandle || !obj || !fTNGetGesvdP)
3775 throw std::runtime_error(
"GpuLibrary: TNGetGesvdP is unavailable");
3776 return fTNGetGesvdP(obj) == 1;
3779 bool TNSetGesvdR(
void *obj,
int val)
3781 return LibraryHandle && obj && fTNSetGesvdR && fTNSetGesvdR(obj, val) == 1;
3784 bool TNGetGesvdR(
void *obj)
const
3786 if (!LibraryHandle || !obj || !fTNGetGesvdR)
3787 throw std::runtime_error(
"GpuLibrary: TNGetGesvdR is unavailable");
3788 return fTNGetGesvdR(obj) == 1;
3791 bool TNSetMaxExtent(
void *obj,
long int val)
3794 return fTNSetMaxExtent(obj, val) == 1;
3796 throw std::runtime_error(
"GpuLibrary: Unable to set max extent for tensor network");
3801 long int TNGetMaxExtent(
void *obj)
3804 return fTNGetMaxExtent(obj);
3806 throw std::runtime_error(
"GpuLibrary: Unable to get max extent for tensor network");
3811 int TNGetNrQubits(
void *obj)
3814 return fTNGetNrQubits(obj);
3816 throw std::runtime_error(
"GpuLibrary: Unable to get nr qubits for tensor network");
3821 bool TNAmplitude(
void *obj,
long int numFixedValues,
long int *fixedValues,
double *real,
double *imaginary)
3824 return fTNAmplitude(obj, numFixedValues, fixedValues, real, imaginary) == 1;
3826 throw std::runtime_error(
"GpuLibrary: Unable to get tensor network amplitude");
3831 double TNProbability0(
void *obj,
unsigned int qubit)
3834 return fTNProbability0(obj, qubit);
3836 throw std::runtime_error(
"GpuLibrary: Unable to get probability for 0 for tensor network");
3841 bool TNMeasure(
void *obj,
unsigned int qubit)
3844 return fTNMeasure(obj, qubit) == 1;
3846 throw std::runtime_error(
"GpuLibrary: Unable to measure qubit on tensor network");
3851 bool TNMeasureQubits(
void *obj,
long int numQubits,
unsigned int *qubits,
int *result)
3854 return fTNMeasureQubits(obj, numQubits, qubits, result) == 1;
3856 throw std::runtime_error(
"GpuLibrary: Unable to measure qubits on tensor network");
3861 std::unordered_map<std::vector<bool>, int64_t> *TNGetMapForSample()
3864 return (std::unordered_map<std::vector<bool>, int64_t> *)fTNGetMapForSample();
3866 throw std::runtime_error(
"GpuLibrary: Unable to get map for sample for tensor network");
3871 bool TNFreeMapForSample(std::unordered_map<std::vector<bool>, int64_t> *map)
3874 return fTNFreeMapForSample((
void *)map) == 1;
3876 throw std::runtime_error(
"GpuLibrary: Unable to free map for sample for tensor network");
3881 bool TNSample(
void *obj,
long int numShots,
long int numQubits,
unsigned int *qubits,
void *resultMap)
3884 return fTNSample(obj, numShots, numQubits, qubits, resultMap) == 1;
3886 throw std::runtime_error(
"GpuLibrary: Unable to sample tensor network");
3891 bool TNSaveState(
void *obj)
3894 return fTNSaveState(obj) == 1;
3896 throw std::runtime_error(
"GpuLibrary: Unable to save tensor network state");
3901 bool TNRestoreState(
void *obj)
3904 return fTNRestoreState(obj) == 1;
3906 throw std::runtime_error(
"GpuLibrary: Unable to restore tensor network state");
3911 bool TNCleanSavedState(
void *obj)
3914 return fTNCleanSavedState(obj) == 1;
3916 throw std::runtime_error(
"GpuLibrary: Unable to clean tensor network saved state");
3921 void *TNClone(
void *obj)
3924 return fTNClone(obj);
3926 throw std::runtime_error(
"GpuLibrary: Unable to clone tensor network");
3931 bool TNSetSeed(
void *obj,
unsigned long long seed)
const
3933 return obj && fTNSetSeed && fTNSetSeed(obj, seed) == 1;
3936 double TNExpectationValue(
void *obj,
const char *pauliString,
int len)
const
3939 return fTNExpectationValue(obj, pauliString, len);
3941 throw std::runtime_error(
"GpuLibrary: Unable to get tensor network expectation value");
3946 bool TNApplyX(
void *obj,
unsigned int siteA)
3949 return fTNApplyX(obj, siteA) == 1;
3951 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate on tensor network");
3956 bool TNApplyY(
void *obj,
unsigned int siteA)
3959 return fTNApplyY(obj, siteA) == 1;
3961 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate on tensor network");
3966 bool TNApplyZ(
void *obj,
unsigned int siteA)
3969 return fTNApplyZ(obj, siteA) == 1;
3971 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate on tensor network");
3976 bool TNApplyH(
void *obj,
unsigned int siteA)
3979 return fTNApplyH(obj, siteA) == 1;
3981 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate on tensor network");
3986 bool TNApplyS(
void *obj,
unsigned int siteA)
3989 return fTNApplyS(obj, siteA) == 1;
3991 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate on tensor network");
3996 bool TNApplySDG(
void *obj,
unsigned int siteA)
3999 return fTNApplySDG(obj, siteA) == 1;
4001 throw std::runtime_error(
"GpuLibrary: Unable to apply sdg gate on tensor network");
4006 bool TNApplyT(
void *obj,
unsigned int siteA)
4009 return fTNApplyT(obj, siteA) == 1;
4011 throw std::runtime_error(
"GpuLibrary: Unable to apply t gate on tensor network");
4016 bool TNApplyTDG(
void *obj,
unsigned int siteA)
4019 return fTNApplyTDG(obj, siteA) == 1;
4021 throw std::runtime_error(
"GpuLibrary: Unable to apply tdg gate on tensor network");
4026 bool TNApplySX(
void *obj,
unsigned int siteA)
4029 return fTNApplySX(obj, siteA) == 1;
4031 throw std::runtime_error(
"GpuLibrary: Unable to apply sx gate on tensor network");
4036 bool TNApplySXDG(
void *obj,
unsigned int siteA)
4039 return fTNApplySXDG(obj, siteA) == 1;
4041 throw std::runtime_error(
"GpuLibrary: Unable to apply sxdg gate on tensor network");
4046 bool TNApplyK(
void *obj,
unsigned int siteA)
4049 return fTNApplyK(obj, siteA) == 1;
4051 throw std::runtime_error(
"GpuLibrary: Unable to apply k gate on tensor network");
4056 bool TNApplyP(
void *obj,
unsigned int siteA,
double theta)
4059 return fTNApplyP(obj, siteA, theta) == 1;
4061 throw std::runtime_error(
"GpuLibrary: Unable to apply p gate on tensor network");
4065 bool TNApplyRx(
void *obj,
unsigned int siteA,
double theta)
4068 return fTNApplyRx(obj, siteA, theta) == 1;
4070 throw std::runtime_error(
"GpuLibrary: Unable to apply rx gate on tensor network");
4075 bool TNApplyRy(
void *obj,
unsigned int siteA,
double theta)
4078 return fTNApplyRy(obj, siteA, theta) == 1;
4080 throw std::runtime_error(
"GpuLibrary: Unable to apply ry gate on tensor network");
4085 bool TNApplyRz(
void *obj,
unsigned int siteA,
double theta)
4088 return fTNApplyRz(obj, siteA, theta) == 1;
4090 throw std::runtime_error(
"GpuLibrary: Unable to apply rz gate on tensor network");
4095 bool TNApplyU(
void *obj,
unsigned int siteA,
double theta,
double phi,
double lambda,
double gamma)
4098 return fTNApplyU(obj, siteA, theta, phi, lambda, gamma) == 1;
4100 throw std::runtime_error(
"GpuLibrary: Unable to apply u gate on tensor network");
4105 bool TNApplySwap(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
4108 return fTNApplySwap(obj, controlQubit, targetQubit) == 1;
4110 throw std::runtime_error(
"GpuLibrary: Unable to apply swap gate on tensor network");
4115 bool TNApplyCX(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
4118 return fTNApplyCX(obj, controlQubit, targetQubit) == 1;
4120 throw std::runtime_error(
"GpuLibrary: Unable to apply cx gate on tensor network");
4125 bool TNApplyCY(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
4128 return fTNApplyCY(obj, controlQubit, targetQubit) == 1;
4130 throw std::runtime_error(
"GpuLibrary: Unable to apply cy gate on tensor network");
4135 bool TNApplyCZ(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
4138 return fTNApplyCZ(obj, controlQubit, targetQubit) == 1;
4140 throw std::runtime_error(
"GpuLibrary: Unable to apply cz gate on tensor network");
4145 bool TNApplyCH(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
4148 return fTNApplyCH(obj, controlQubit, targetQubit) == 1;
4150 throw std::runtime_error(
"GpuLibrary: Unable to apply ch gate on tensor network");
4155 bool TNApplyCSX(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
4158 return fTNApplyCSX(obj, controlQubit, targetQubit) == 1;
4160 throw std::runtime_error(
"GpuLibrary: Unable to apply csx gate on tensor network");
4163 bool TNApplyCSXDG(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit)
4166 return fTNApplyCSXDG(obj, controlQubit, targetQubit) == 1;
4168 throw std::runtime_error(
"GpuLibrary: Unable to apply csxdg gate on tensor network");
4173 bool TNApplyCP(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
double theta)
4176 return fTNApplyCP(obj, controlQubit, targetQubit, theta) == 1;
4178 throw std::runtime_error(
"GpuLibrary: Unable to apply cp gate on tensor network");
4183 bool TNApplyCRx(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
double theta)
4186 return fTNApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
4188 throw std::runtime_error(
"GpuLibrary: Unable to apply crx gate on tensor network");
4193 bool TNApplyCRy(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
double theta)
4196 return fTNApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
4198 throw std::runtime_error(
"GpuLibrary: Unable to apply cry gate on tensor network");
4203 bool TNApplyCRz(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
double theta)
4206 return fTNApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
4208 throw std::runtime_error(
"GpuLibrary: Unable to apply crz gate on tensor network");
4213 bool TNApplyCU(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit,
double theta,
double phi,
double lambda,
double gamma)
4216 return fTNApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda, gamma) == 1;
4218 throw std::runtime_error(
"GpuLibrary: Unable to apply cu gate on tensor network");
4223 bool TNApplyCCX(
void *obj,
unsigned int controlQubit1,
unsigned int controlQubit2,
unsigned int targetQubit)
4226 return fTNApplyCCX(obj, controlQubit1, controlQubit2, targetQubit) == 1;
4228 throw std::runtime_error(
"GpuLibrary: Unable to apply ccx gate on tensor network");
4232 bool TNApplyCSwap(
void *obj,
unsigned int controlQubit,
unsigned int targetQubit1,
unsigned int targetQubit2)
4235 return fTNApplyCSwap(obj, controlQubit, targetQubit1, targetQubit2) == 1;
4237 throw std::runtime_error(
"GpuLibrary: Unable to apply cswap gate on tensor network");
4242 void *CreateStabilizerSimulator(
long long int numQubits,
long long int numShots,
long long int numMeasurements,
long long int numDetectors)
4245 return fCreateStabilizerSimulator(numQubits, numShots, numMeasurements, numDetectors);
4247 throw std::runtime_error(
"GpuLibrary: Unable to create stabilizer simulator");
4252 void DestroyStabilizerSimulator(
void *obj)
4257 fDestroyStabilizerSimulator(obj);
4259 throw std::runtime_error(
"GpuLibrary: Unable to destroy stabilizer simulator");
4262 bool ExecuteStabilizerCircuit(
void *obj,
const char *circuitStr,
int randomizeMeasurements,
unsigned long long int seed)
4267 return fExecuteStabilizerCircuit(obj, circuitStr, randomizeMeasurements, seed) == 1;
4269 throw std::runtime_error(
"GpuLibrary: Unable to execute stabilizer circuit");
4274 long long GetStabilizerXZTableSize(
void *obj)
4279 return fGetStabilizerXZTableSize(obj);
4281 throw std::runtime_error(
"GpuLibrary: Unable to get stabilizer XZ table size");
4286 long long GetStabilizerMTableSize(
void *obj)
4291 return fGetStabilizerMTableSize(obj);
4293 throw std::runtime_error(
"GpuLibrary: Unable to get stabilizer M table size");
4298 long long GetStabilizerTableStrideMajor(
void *obj)
4303 return fGetStabilizerTableStrideMajor(obj);
4305 throw std::runtime_error(
"GpuLibrary: Unable to get stabilizer table stride major");
4309 long long GetStabilizerNumQubits(
void *obj)
4314 return fGetStabilizerNumQubits(obj);
4316 throw std::runtime_error(
"GpuLibrary: Unable to get stabilizer number of qubits");
4321 long long GetStabilizerNumShots(
void *obj)
4326 return fGetStabilizerNumShots(obj);
4328 throw std::runtime_error(
"GpuLibrary: Unable to get stabilizer number of shots");
4333 long long GetStabilizerNumMeasurements(
void *obj)
4338 return fGetStabilizerNumMeasurements(obj);
4340 throw std::runtime_error(
"GpuLibrary: Unable to get stabilizer number of measurements");
4345 long long GetStabilizerNumDetectors(
void *obj)
4350 return fGetStabilizerNumDetectors(obj);
4352 throw std::runtime_error(
"GpuLibrary: Unable to get stabilizer number of detectors");
4357 int CopyStabilizerXTable(
void *obj,
unsigned int *xtable)
4362 return fCopyStabilizerXTable(obj, xtable);
4364 throw std::runtime_error(
"GpuLibrary: Unable to copy stabilizer X table");
4368 int CopyStabilizerZTable(
void *obj,
unsigned int *ztable)
4373 return fCopyStabilizerZTable(obj, ztable);
4375 throw std::runtime_error(
"GpuLibrary: Unable to copy stabilizer Z table");
4379 int CopyStabilizerMTable(
void *obj,
unsigned int *mtable)
4384 return fCopyStabilizerMTable(obj, mtable);
4386 throw std::runtime_error(
"GpuLibrary: Unable to copy stabilizer M table");
4390 int InitStabilizerXTable(
void *obj,
const unsigned int *xtable)
4395 return fInitStabilizerXTable(obj, xtable);
4397 throw std::runtime_error(
"GpuLibrary: Unable to initialize stabilizer X table");
4401 int InitStabilizerZTable(
void *obj,
const unsigned int *ztable)
4406 return fInitStabilizerZTable(obj, ztable);
4408 throw std::runtime_error(
"GpuLibrary: Unable to initialize stabilizer Z table");
4413 void *CreatePauliPropSimulator(
int nrQubits)
4416 return fCreatePauliPropSimulator(nrQubits);
4418 throw std::runtime_error(
"GpuLibrary: Unable to create pauli propagation simulator");
4422 void DestroyPauliPropSimulator(
void *obj)
4427 fDestroyPauliPropSimulator(obj);
4429 throw std::runtime_error(
"GpuLibrary: Unable to destroy pauli propagation simulator");
4432 int PauliPropGetNrQubits(
void *obj)
4437 return fPauliPropGetNrQubits(obj);
4439 throw std::runtime_error(
"GpuLibrary: Unable to get number of qubits in pauli propagation "
4444 int PauliPropSetWillUseSampling(
void *obj,
int willUseSampling)
4449 return fPauliPropSetWillUseSampling(obj, willUseSampling) == 1;
4451 throw std::runtime_error(
"GpuLibrary: Unable to set 'will use sampling' in pauli propagation "
4456 int PauliPropGetWillUseSampling(
void *obj)
4461 return fPauliPropGetWillUseSampling(obj);
4463 throw std::runtime_error(
"GpuLibrary: Unable to get 'will use sampling' in pauli propagation "
4468 double PauliPropGetCoefficientTruncationCutoff(
void *obj)
4473 return fPauliPropGetCoefficientTruncationCutoff(obj);
4475 throw std::runtime_error(
"GpuLibrary: Unable to get coefficient truncation cutoff in pauli "
4476 "propagation simulator");
4480 void PauliPropSetCoefficientTruncationCutoff(
void *obj,
double cutoff)
4485 fPauliPropSetCoefficientTruncationCutoff(obj, cutoff);
4487 throw std::runtime_error(
"GpuLibrary: Unable to set coefficient truncation cutoff in pauli "
4488 "propagation simulator");
4491 double PauliPropGetWeightTruncationCutoff(
void *obj)
4496 return fPauliPropGetWeightTruncationCutoff(obj);
4498 throw std::runtime_error(
"GpuLibrary: Unable to get weight truncation cutoff in pauli "
4499 "propagation simulator");
4503 void PauliPropSetWeightTruncationCutoff(
void *obj,
double cutoff)
4508 fPauliPropSetWeightTruncationCutoff(obj, cutoff);
4510 throw std::runtime_error(
"GpuLibrary: Unable to set weight truncation cutoff in pauli "
4511 "propagation simulator");
4514 int PauliPropGetNumGatesBetweenTruncations(
void *obj)
4519 return fPauliPropGetNumGatesBetweenTruncations(obj);
4521 throw std::runtime_error(
"GpuLibrary: Unable to get number of gates between truncations in "
4522 "pauli propagation simulator");
4526 void PauliPropSetNumGatesBetweenTruncations(
void *obj,
int numGates)
4531 fPauliPropSetNumGatesBetweenTruncations(obj, numGates);
4533 throw std::runtime_error(
"GpuLibrary: Unable to set number of gates between truncations in "
4535 "propagation simulator");
4538 int PauliPropGetNumGatesBetweenDeduplications(
void *obj)
4543 return fPauliPropGetNumGatesBetweenDeduplications(obj);
4545 throw std::runtime_error(
"GpuLibrary: Unable to get number of gates between deduplications in "
4546 "pauli propagation simulator");
4550 void PauliPropSetNumGatesBetweenDeduplications(
void *obj,
int numGates)
4555 fPauliPropSetNumGatesBetweenDeduplications(obj, numGates);
4557 throw std::runtime_error(
"GpuLibrary: Unable to set number of gates between deduplications in "
4559 "propagation simulator");
4562 bool PauliPropClearOperators(
void *obj)
4567 return fPauliPropClearOperators(obj) == 1;
4569 throw std::runtime_error(
"GpuLibrary: Unable to clear operators in pauli propagation "
4574 bool PauliPropAllocateMemory(
void *obj,
double percentage)
4579 return fPauliPropAllocateMemory(obj, percentage) == 1;
4581 throw std::runtime_error(
"GpuLibrary: Unable to allocate memory in pauli propagation "
4586 double PauliPropGetExpectationValue(
void *obj)
4591 return fPauliPropGetExpectationValue(obj);
4593 throw std::runtime_error(
"GpuLibrary: Unable to get expectation value in pauli propagation "
4598 bool PauliPropExecute(
void *obj)
4603 return fPauliPropExecute(obj) == 1;
4605 throw std::runtime_error(
"GpuLibrary: Unable to execute pauli propagation simulator");
4609 bool PauliPropSetSeed(
void *obj,
unsigned long long seed)
const
4611 return obj && fPauliPropSetSeed && fPauliPropSetSeed(obj, seed) == 1;
4614 bool PauliPropSetInPauliExpansionUnique(
void *obj,
const char *pauliString)
4619 return fPauliPropSetInPauliExpansionUnique(obj, pauliString) == 1;
4621 throw std::runtime_error(
"GpuLibrary: Unable to set unique pauli in pauli propagation "
4626 bool PauliPropSetInPauliExpansionMultiple(
void *obj,
const char **pauliStrings,
const double *coefficients,
int nrPaulis)
4631 return fPauliPropSetInPauliExpansionMultiple(obj, pauliStrings, coefficients, nrPaulis) == 1;
4633 throw std::runtime_error(
"GpuLibrary: Unable to set multiple pauli in pauli propagation "
4638 bool PauliPropApplyX(
void *obj,
int qubit)
4643 return fPauliPropApplyX(obj, qubit) == 1;
4645 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate on mps");
4649 bool PauliPropApplyY(
void *obj,
int qubit)
4654 return fPauliPropApplyY(obj, qubit) == 1;
4656 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate on mps");
4660 bool PauliPropApplyZ(
void *obj,
int qubit)
4665 return fPauliPropApplyZ(obj, qubit) == 1;
4667 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate on mps");
4671 bool PauliPropApplyH(
void *obj,
int qubit)
4676 return fPauliPropApplyH(obj, qubit) == 1;
4678 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate on mps");
4682 bool PauliPropApplyS(
void *obj,
int qubit)
4687 return fPauliPropApplyS(obj, qubit) == 1;
4689 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate on mps");
4693 bool PauliPropApplySQRTX(
void *obj,
int qubit)
4698 return fPauliPropApplySQRTX(obj, qubit) == 1;
4700 throw std::runtime_error(
"GpuLibrary: Unable to apply SQRTX gate on mps");
4704 bool PauliPropApplySQRTY(
void *obj,
int qubit)
4709 return fPauliPropApplySQRTY(obj, qubit) == 1;
4711 throw std::runtime_error(
"GpuLibrary: Unable to apply SQRTY gate on mps");
4715 bool PauliPropApplySQRTZ(
void *obj,
int qubit)
4720 return fPauliPropApplySQRTZ(obj, qubit) == 1;
4722 throw std::runtime_error(
"GpuLibrary: Unable to apply SQRTZ gate on mps");
4726 bool PauliPropApplyCX(
void *obj,
int targetQubit,
int controlQubit)
4731 return fPauliPropApplyCX(obj, targetQubit, controlQubit) == 1;
4733 throw std::runtime_error(
"GpuLibrary: Unable to apply CX gate on mps");
4737 bool PauliPropApplyCY(
void *obj,
int targetQubit,
int controlQubit)
4742 return fPauliPropApplyCY(obj, targetQubit, controlQubit) == 1;
4744 throw std::runtime_error(
"GpuLibrary: Unable to apply CY gate on mps");
4748 bool PauliPropApplyCZ(
void *obj,
int targetQubit,
int controlQubit)
4753 return fPauliPropApplyCZ(obj, targetQubit, controlQubit) == 1;
4755 throw std::runtime_error(
"GpuLibrary: Unable to apply CZ gate on mps");
4759 bool PauliPropApplySWAP(
void *obj,
int qubit1,
int qubit2)
4764 return fPauliPropApplySWAP(obj, qubit1, qubit2) == 1;
4766 throw std::runtime_error(
"GpuLibrary: Unable to apply SWAP gate on mps");
4770 bool PauliPropApplyISWAP(
void *obj,
int qubit1,
int qubit2)
4775 return fPauliPropApplyISWAP(obj, qubit1, qubit2) == 1;
4777 throw std::runtime_error(
"GpuLibrary: Unable to apply ISWAP gate on mps");
4781 bool PauliPropApplyRX(
void *obj,
int qubit,
double angle)
4786 return fPauliPropApplyRX(obj, qubit, angle) == 1;
4788 throw std::runtime_error(
"GpuLibrary: Unable to apply RX gate on mps");
4792 bool PauliPropApplyRY(
void *obj,
int qubit,
double angle)
4797 return fPauliPropApplyRY(obj, qubit, angle) == 1;
4799 throw std::runtime_error(
"GpuLibrary: Unable to apply RY gate on mps");
4803 bool PauliPropApplyRZ(
void *obj,
int qubit,
double angle)
4808 return fPauliPropApplyRZ(obj, qubit, angle) == 1;
4810 throw std::runtime_error(
"GpuLibrary: Unable to apply RZ gate on mps");
4814 bool PauliPropAddNoiseX(
void *obj,
int qubit,
double probability)
4819 return fPauliPropAddNoiseX(obj, qubit, probability) == 1;
4821 throw std::runtime_error(
"GpuLibrary: Unable to add X noise on mps");
4825 bool PauliPropAddNoiseY(
void *obj,
int qubit,
double probability)
4830 return fPauliPropAddNoiseY(obj, qubit, probability) == 1;
4832 throw std::runtime_error(
"GpuLibrary: Unable to add Y noise on mps");
4836 bool PauliPropAddNoiseZ(
void *obj,
int qubit,
double probability)
4841 return fPauliPropAddNoiseZ(obj, qubit, probability) == 1;
4843 throw std::runtime_error(
"GpuLibrary: Unable to add Z noise on mps");
4847 bool PauliPropAddNoiseXYZ(
void *obj,
int qubit,
double probabilityX,
double probabilityY,
double probabilityZ)
4852 return fPauliPropAddNoiseXYZ(obj, qubit, probabilityX, probabilityY, probabilityZ) == 1;
4854 throw std::runtime_error(
"GpuLibrary: Unable to add XYZ noise on mps");
4858 bool PauliPropAddAmplitudeDamping(
void *obj,
int qubit,
double dampingProb,
double exciteProb)
4863 return fPauliPropAddAmplitudeDamping(obj, qubit, dampingProb, exciteProb) == 1;
4865 throw std::runtime_error(
"GpuLibrary: Unable to add amplitude damping on mps");
4869 double PauliPropQubitProbability0(
void *obj,
int qubit)
4874 return fPauliPropQubitProbability0(obj, qubit);
4876 throw std::runtime_error(
"GpuLibrary: Unable to get qubit probability 0 in pauli propagation "
4881 double PauliPropProbability(
void *obj,
unsigned long long int outcome)
4886 return fPauliPropProbability(obj, outcome);
4888 throw std::runtime_error(
"GpuLibrary: Unable to get probability of outcome in pauli "
4889 "propagation simulator");
4893 bool PauliPropMeasureQubit(
void *obj,
int qubit)
4898 return fPauliPropMeasureQubit(obj, qubit) == 1;
4900 throw std::runtime_error(
"GpuLibrary: Unable to measure qubit in pauli propagation simulator");
4904 unsigned char *PauliPropSampleQubits(
void *obj,
const int *qubits,
int nrQubits)
4909 return fPauliPropSampleQubits(obj, qubits, nrQubits);
4911 throw std::runtime_error(
"GpuLibrary: Unable to sample qubits in pauli propagation simulator");
4915 void PauliPropFreeSampledQubits(
unsigned char *samples)
4920 fPauliPropFreeSampledQubits(samples);
4922 throw std::runtime_error(
"GpuLibrary: Unable to free sampled qubits in pauli propagation "
4926 void PauliPropSaveState(
void *obj)
4931 fPauliPropSaveState(obj);
4933 throw std::runtime_error(
"GpuLibrary: Unable to save state in pauli propagation simulator");
4936 void PauliPropRestoreState(
void *obj)
4941 fPauliPropRestoreState(obj);
4943 throw std::runtime_error(
"GpuLibrary: Unable to restore state in pauli propagation simulator");
4947 std::recursive_mutex initializationMutex;
4948 std::string loadedPath;
4949 bool licenseValidated =
false;
4950 bool initializationFailed =
false;
4951 const char *(*fGetLicenseError)() =
nullptr;
4952 void *LibraryHandle =
nullptr;
4954 int (*fValidateLicense)(
const char *) =
nullptr;
4955 void *(*InitLib)() =
nullptr;
4956 void (*FreeLib)() =
nullptr;
4958 inline static thread_local int creationDevice = 0;
4959 int (*fGetStateVectorGpuId)(
void *) =
nullptr;
4960 int (*fStateVectorSynchronize)(
void *) =
nullptr;
4961 int (*fDMSynchronize)(
void *) =
nullptr;
4962 int (*fMPSGetGpuId)(
void *) =
nullptr;
4963 int (*fTNGetGpuId)(
void *) =
nullptr;
4964 int (*fDMGetGpuId)(
void *) =
nullptr;
4965 int (*fMPOGetGpuId)(
void *) =
nullptr;
4966 int (*fGetStabilizerGpuId)(
void *) =
nullptr;
4967 int (*fPauliPropGetGpuId)(
void *) =
nullptr;
4968 int (*fSetGpuDevice)(int) =
nullptr;
4969 int (*fGetGpuDeviceCount)() =
nullptr;
4971 void *(*fCreateStateVector)(
void *) =
nullptr;
4972 void (*fDestroyStateVector)(
void *) =
nullptr;
4974 int (*fSetDataType)(
void *, int) =
nullptr;
4975 int (*fIsDoublePrecision)(
void *) =
nullptr;
4976 int (*fGetNrQubits)(
void *) =
nullptr;
4977 int (*fCreate)(
void *,
unsigned int) =
nullptr;
4978 int (*fReset)(
void *) =
nullptr;
4979 int (*fCreateWithState)(
void *,
unsigned int,
const double *) =
nullptr;
4980 int (*fMeasureQubitCollapse)(
void *, int) =
nullptr;
4981 int (*fMeasureQubitNoCollapse)(
void *, int) =
nullptr;
4982 int (*fMeasureQubitsCollapse)(
void *,
int *,
int *, int) =
nullptr;
4983 int (*fMeasureQubitsNoCollapse)(
void *,
int *,
int *, int) =
nullptr;
4984 unsigned long long (*fMeasureAllQubitsCollapse)(
void *) =
nullptr;
4985 unsigned long long (*fMeasureAllQubitsNoCollapse)(
void *) =
nullptr;
4987 int (*fSaveState)(
void *) =
nullptr;
4988 int (*fSaveStateToHost)(
void *) =
nullptr;
4989 int (*fSaveStateDestructive)(
void *) =
nullptr;
4990 int (*fRestoreStateFreeSaved)(
void *) =
nullptr;
4991 int (*fRestoreStateNoFreeSaved)(
void *) =
nullptr;
4992 void (*fFreeSavedState)(
void *obj) =
nullptr;
4993 void *(*fClone)(
void *) =
nullptr;
4994 int (*fSetSeed)(
void *,
unsigned long long) =
nullptr;
4995 int (*fSample)(
void *,
unsigned int,
long int *,
unsigned int,
int *) =
nullptr;
4996 int (*fSampleAll)(
void *,
unsigned int,
long int *) =
nullptr;
4997 int (*fAmplitude)(
void *,
long long int,
double *,
double *) =
nullptr;
4998 double (*fProbability)(
void *,
int *,
int *, int) =
nullptr;
4999 double (*fBasisStateProbability)(
void *,
long long int) =
nullptr;
5000 int (*fAllProbabilities)(
void *,
double *) =
nullptr;
5001 double (*fExpectationValue)(
void *,
const char *, int) =
nullptr;
5003 int (*fApplyX)(
void *, int) =
nullptr;
5004 int (*fApplyY)(
void *, int) =
nullptr;
5005 int (*fApplyZ)(
void *, int) =
nullptr;
5006 int (*fApplyH)(
void *, int) =
nullptr;
5007 int (*fApplyS)(
void *, int) =
nullptr;
5008 int (*fApplySDG)(
void *, int) =
nullptr;
5009 int (*fApplyT)(
void *, int) =
nullptr;
5010 int (*fApplyTDG)(
void *, int) =
nullptr;
5011 int (*fApplySX)(
void *, int) =
nullptr;
5012 int (*fApplySXDG)(
void *, int) =
nullptr;
5013 int (*fApplyK)(
void *, int) =
nullptr;
5014 int (*fApplyP)(
void *, int, double) =
nullptr;
5015 int (*fApplyRx)(
void *, int, double) =
nullptr;
5016 int (*fApplyRy)(
void *, int, double) =
nullptr;
5017 int (*fApplyRz)(
void *, int, double) =
nullptr;
5018 int (*fApplyU)(
void *, int, double, double, double, double) =
nullptr;
5019 int (*fApplyCX)(
void *, int, int) =
nullptr;
5020 int (*fApplyCY)(
void *, int, int) =
nullptr;
5021 int (*fApplyCZ)(
void *, int, int) =
nullptr;
5022 int (*fApplyCH)(
void *, int, int) =
nullptr;
5023 int (*fApplyCSX)(
void *, int, int) =
nullptr;
5024 int (*fApplyCSXDG)(
void *, int, int) =
nullptr;
5025 int (*fApplyCP)(
void *, int, int, double) =
nullptr;
5026 int (*fApplyCRx)(
void *, int, int, double) =
nullptr;
5027 int (*fApplyCRy)(
void *, int, int, double) =
nullptr;
5028 int (*fApplyCRz)(
void *, int, int, double) =
nullptr;
5029 int (*fApplyCCX)(
void *, int, int, int) =
nullptr;
5030 int (*fApplySwap)(
void *, int, int) =
nullptr;
5031 int (*fApplyCSwap)(
void *, int, int, int) =
nullptr;
5032 int (*fApplyCU)(
void *, int, int, double, double, double, double) =
nullptr;
5033 int (*fApplyOneQubitMatrix)(
void *, int,
const double *) =
nullptr;
5034 int (*fApplyOneQubitMatrixWithLayout)(
void *, int,
const double *, int) =
nullptr;
5035 int (*fApplyTwoQubitMatrix)(
void *, int, int,
const double *) =
nullptr;
5036 int (*fApplyTwoQubitMatrixWithLayout)(
void *, int, int,
const double *, int) =
nullptr;
5037 int (*fApplyThreeQubitMatrix)(
void *, int, int, int,
const double *) =
nullptr;
5038 int (*fApplyThreeQubitMatrixWithLayout)(
void *, int, int, int,
const double *, int) =
nullptr;
5040 void *(*fCreateMPS)(
void *) =
nullptr;
5041 void (*fDestroyMPS)(
void *) =
nullptr;
5043 int (*fMPSCreate)(
void *,
unsigned int) =
nullptr;
5044 int (*fMPSCreateWithBasisState)(
void *,
unsigned int,
unsigned long long) =
nullptr;
5045 int (*fMPSCreateWithBasisStateBits)(
void *,
unsigned int,
const unsigned char *) =
nullptr;
5046 int (*fMPSReset)(
void *) =
nullptr;
5047 int (*fMPSTrim)(
void *) =
nullptr;
5048 int (*fMPSExpectationValues)(
void *, int,
const char *
const *,
const int *,
double *) =
nullptr;
5049 int (*fMPOExpectationValues)(
void *, int,
const char *
const *,
const int *,
double *) =
nullptr;
5050 int (*fMPOExpectationValuesComplex)(
void *, int,
const char *
const *,
const int *, int,
double *,
double *) =
nullptr;
5051 int (*fMPSGetStateVector)(
void *,
double *) =
nullptr;
5052 int (*fMPSAllProbabilities)(
void *,
double *) =
nullptr;
5053 int (*fMPSMoveAtBeginningOfChain)(
void *,
const int *, int) =
nullptr;
5054 int (*fMPSExpectationValueOperators)(
void *, int,
const int *,
const double *,
double *,
double *) =
nullptr;
5055 int (*fMPSSetBondDimensionSummaryCallback)(
void *, void (*)(
void *, int64_t)) =
nullptr;
5056 int (*fMPOSetBondDimensionSummaryCallback)(
void *, void (*)(
void *, int64_t)) =
nullptr;
5057 long long (*fMPSGetMaxBondDimension)(
void *) =
nullptr;
5058 long long (*fMPOGetMaxBondDimension)(
void *) =
nullptr;
5059 int (*fMPSReCanonicalize)(
void *) =
nullptr;
5060 int (*fMPSSetInitialQubitsMap)(
void *,
const long long int *, int) =
nullptr;
5061 int (*fMPSSetUseOptimalMeetingPosition)(
void *, int) =
nullptr;
5062 int (*fMPSGetUseOptimalMeetingPosition)(
void *) =
nullptr;
5064 int (*fMPSIsValid)(
void *) =
nullptr;
5065 int (*fMPSIsCreated)(
void *) =
nullptr;
5067 int (*fMPSSetDataType)(
void *, int) =
nullptr;
5068 int (*fMPSIsDoublePrecision)(
void *) =
nullptr;
5069 int (*fMPSSetCutoff)(
void *, double) =
nullptr;
5070 double (*fMPSGetCutoff)(
void *) =
nullptr;
5071 int (*fMPSSetTruncationMode)(
void *, int) =
nullptr;
5072 int (*fMPSGetTruncationMode)(
void *) =
nullptr;
5073 int (*fMPSSetGesvdJ)(
void *, int) =
nullptr;
5074 int (*fMPSGetGesvdJ)(
void *) =
nullptr;
5075 int (*fMPSSetGesvdP)(
void *, int) =
nullptr;
5076 int (*fMPSGetGesvdP)(
void *) =
nullptr;
5077 int (*fMPSSetGesvdR)(
void *, int) =
nullptr;
5078 int (*fMPSGetGesvdR)(
void *) =
nullptr;
5079 int (*fMPSGetLastSvdAlgo)(
void *) =
nullptr;
5080 int (*fMPSSetMaxExtent)(
void *,
long int) =
nullptr;
5081 long int (*fMPSGetMaxExtent)(
void *) =
nullptr;
5082 int (*fMPSGetNrQubits)(
void *) =
nullptr;
5083 int (*fMPSGetBondDimensions)(
void *,
long long int *) =
nullptr;
5084 int (*fMPSSwapRelabels)() =
nullptr;
5085 int (*fMPOSwapRelabels)() =
nullptr;
5086 int (*fMPSGetQubitsMap)(
void *,
long long *, int) =
nullptr;
5087 int (*fMPSSetCallbackContext)(
void *,
void *) =
nullptr;
5088 int (*fMPSSetMeetingPositionCallback)(
void *, int64_t (*)(
void *,
const int64_t *)) =
nullptr;
5089 int (*fMPSSetBondDimensionsCallback)(
void *, void (*)(
void *,
const int64_t *)) =
nullptr;
5091 int (*fMPSAmplitude)(
void *,
long int,
long int *,
double *,
double *) =
nullptr;
5092 double (*fMPSProbability0)(
void *,
unsigned int) =
nullptr;
5093 int (*fMPSMeasure)(
void *,
unsigned int) =
nullptr;
5094 int (*fMPSMeasureQubits)(
void *,
long int,
unsigned int *,
int *) =
nullptr;
5095 void *(*fMPSGetMapForSample)() =
nullptr;
5096 int (*fMPSFreeMapForSample)(
void *) =
nullptr;
5097 int (*fMPSSample)(
void *,
long int,
long int,
unsigned int *,
void *) =
nullptr;
5098 int (*fMPSSampleRaw)(
void *,
unsigned int,
long int *,
unsigned int,
const unsigned int *) =
nullptr;
5099 int (*fMPSSampleAll)(
void *,
unsigned int,
long int *) =
nullptr;
5101 int (*fMPSSaveState)(
void *) =
nullptr;
5102 int (*fMPSRestoreState)(
void *) =
nullptr;
5103 int (*fMPSCleanSavedState)(
void *) =
nullptr;
5104 void *(*fMPSClone)(
void *) =
nullptr;
5105 int (*fMPSSetSeed)(
void *,
unsigned long long) =
nullptr;
5107 double (*fMPSExpectationValue)(
void *,
const char *, int) =
nullptr;
5108 int (*fMPSProjectOnZero)(
void *,
double *,
double *) =
nullptr;
5110 int (*fMPSApplyX)(
void *,
unsigned int) =
nullptr;
5111 int (*fMPSApplyY)(
void *,
unsigned int) =
nullptr;
5112 int (*fMPSApplyZ)(
void *,
unsigned int) =
nullptr;
5113 int (*fMPSApplyH)(
void *,
unsigned int) =
nullptr;
5114 int (*fMPSApplyS)(
void *,
unsigned int) =
nullptr;
5115 int (*fMPSApplySDG)(
void *,
unsigned int) =
nullptr;
5116 int (*fMPSApplyT)(
void *,
unsigned int) =
nullptr;
5117 int (*fMPSApplyTDG)(
void *,
unsigned int) =
nullptr;
5118 int (*fMPSApplySX)(
void *,
unsigned int) =
nullptr;
5119 int (*fMPSApplySXDG)(
void *,
unsigned int) =
nullptr;
5120 int (*fMPSApplyK)(
void *,
unsigned int) =
nullptr;
5121 int (*fMPSApplyP)(
void *,
unsigned int, double) =
nullptr;
5122 int (*fMPSApplyRx)(
void *,
unsigned int, double) =
nullptr;
5123 int (*fMPSApplyRy)(
void *,
unsigned int, double) =
nullptr;
5124 int (*fMPSApplyRz)(
void *,
unsigned int, double) =
nullptr;
5125 int (*fMPSApplyU)(
void *,
unsigned int, double, double, double, double) =
nullptr;
5126 int (*fMPSApplyOneQubitMatrix)(
void *,
unsigned int,
const double *) =
nullptr;
5127 int (*fMPSApplyTwoQubitMatrix)(
void *,
unsigned int,
unsigned int,
const double *) =
nullptr;
5128 int (*fMPSApplySwap)(
void *,
unsigned int,
unsigned int) =
nullptr;
5129 int (*fMPSApplyCX)(
void *,
unsigned int,
unsigned int) =
nullptr;
5130 int (*fMPSApplyCY)(
void *,
unsigned int,
unsigned int) =
nullptr;
5131 int (*fMPSApplyCZ)(
void *,
unsigned int,
unsigned int) =
nullptr;
5132 int (*fMPSApplyCH)(
void *,
unsigned int,
unsigned int) =
nullptr;
5133 int (*fMPSApplyCSX)(
void *,
unsigned int,
unsigned int) =
nullptr;
5134 int (*fMPSApplyCSXDG)(
void *,
unsigned int,
unsigned int) =
nullptr;
5135 int (*fMPSApplyCP)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
5136 int (*fMPSApplyCRx)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
5137 int (*fMPSApplyCRy)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
5138 int (*fMPSApplyCRz)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
5139 int (*fMPSApplyCU)(
void *,
unsigned int,
unsigned int, double, double, double, double) =
nullptr;
5142 void *(*fCreateTensorNet)(
void *) =
nullptr;
5143 void (*fDestroyTensorNet)(
void *) =
nullptr;
5145 int (*fTNCreate)(
void *,
unsigned int) =
nullptr;
5146 int (*fTNReset)(
void *) =
nullptr;
5147 int (*fTNIsValid)(
void *) =
nullptr;
5148 int (*fTNIsCreated)(
void *) =
nullptr;
5150 int (*fTNSetDataType)(
void *, int) =
nullptr;
5151 int (*fTNIsDoublePrecision)(
void *) =
nullptr;
5152 int (*fTNSetCutoff)(
void *, double) =
nullptr;
5153 double (*fTNGetCutoff)(
void *) =
nullptr;
5154 int (*fTNSetTruncationMode)(
void *, int) =
nullptr;
5155 int (*fTNGetTruncationMode)(
void *) =
nullptr;
5156 int (*fTNSetGesvdJ)(
void *, int) =
nullptr;
5157 int (*fTNGetGesvdJ)(
void *) =
nullptr;
5158 int (*fTNSetGesvdP)(
void *, int) =
nullptr;
5159 int (*fTNGetGesvdP)(
void *) =
nullptr;
5160 int (*fTNSetGesvdR)(
void *, int) =
nullptr;
5161 int (*fTNGetGesvdR)(
void *) =
nullptr;
5162 int (*fTNSetMaxExtent)(
void *,
long int) =
nullptr;
5163 long int (*fTNGetMaxExtent)(
void *) =
nullptr;
5164 int (*fTNGetNrQubits)(
void *) =
nullptr;
5165 int (*fTNAmplitude)(
void *,
long int,
long int *,
double *,
double *) =
nullptr;
5166 double (*fTNProbability0)(
void *,
unsigned int) =
nullptr;
5167 int (*fTNMeasure)(
void *,
unsigned int) =
nullptr;
5168 int (*fTNMeasureQubits)(
void *,
long int,
unsigned int *,
int *) =
nullptr;
5169 void *(*fTNGetMapForSample)() =
nullptr;
5170 int (*fTNFreeMapForSample)(
void *) =
nullptr;
5171 int (*fTNSample)(
void *,
long int,
long int,
unsigned int *,
void *) =
nullptr;
5173 int (*fTNSaveState)(
void *) =
nullptr;
5174 int (*fTNRestoreState)(
void *) =
nullptr;
5175 int (*fTNCleanSavedState)(
void *) =
nullptr;
5176 void *(*fTNClone)(
void *) =
nullptr;
5177 int (*fTNSetSeed)(
void *,
unsigned long long) =
nullptr;
5179 double (*fTNExpectationValue)(
void *,
const char *, int) =
nullptr;
5181 int (*fTNApplyX)(
void *,
unsigned int) =
nullptr;
5182 int (*fTNApplyY)(
void *,
unsigned int) =
nullptr;
5183 int (*fTNApplyZ)(
void *,
unsigned int) =
nullptr;
5184 int (*fTNApplyH)(
void *,
unsigned int) =
nullptr;
5185 int (*fTNApplyS)(
void *,
unsigned int) =
nullptr;
5186 int (*fTNApplySDG)(
void *,
unsigned int) =
nullptr;
5187 int (*fTNApplyT)(
void *,
unsigned int) =
nullptr;
5188 int (*fTNApplyTDG)(
void *,
unsigned int) =
nullptr;
5189 int (*fTNApplySX)(
void *,
unsigned int) =
nullptr;
5190 int (*fTNApplySXDG)(
void *,
unsigned int) =
nullptr;
5191 int (*fTNApplyK)(
void *,
unsigned int) =
nullptr;
5192 int (*fTNApplyP)(
void *,
unsigned int, double) =
nullptr;
5193 int (*fTNApplyRx)(
void *,
unsigned int, double) =
nullptr;
5194 int (*fTNApplyRy)(
void *,
unsigned int, double) =
nullptr;
5195 int (*fTNApplyRz)(
void *,
unsigned int, double) =
nullptr;
5196 int (*fTNApplyU)(
void *,
unsigned int, double, double, double, double) =
nullptr;
5197 int (*fTNApplySwap)(
void *,
unsigned int,
unsigned int) =
nullptr;
5198 int (*fTNApplyCX)(
void *,
unsigned int,
unsigned int) =
nullptr;
5199 int (*fTNApplyCY)(
void *,
unsigned int,
unsigned int) =
nullptr;
5200 int (*fTNApplyCZ)(
void *,
unsigned int,
unsigned int) =
nullptr;
5201 int (*fTNApplyCH)(
void *,
unsigned int,
unsigned int) =
nullptr;
5202 int (*fTNApplyCSX)(
void *,
unsigned int,
unsigned int) =
nullptr;
5203 int (*fTNApplyCSXDG)(
void *,
unsigned int,
unsigned int) =
nullptr;
5204 int (*fTNApplyCP)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
5205 int (*fTNApplyCRx)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
5206 int (*fTNApplyCRy)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
5207 int (*fTNApplyCRz)(
void *,
unsigned int,
unsigned int, double) =
nullptr;
5208 int (*fTNApplyCU)(
void *,
unsigned int,
unsigned int, double, double, double, double) =
nullptr;
5209 int (*fTNApplyCCX)(
void *,
unsigned int,
unsigned int,
unsigned int) =
nullptr;
5210 int (*fTNApplyCSwap)(
void *,
unsigned int,
unsigned int,
unsigned int) =
nullptr;
5212 void *(*fCreateStabilizerSimulator)(
long long int,
long long int,
long long int,
long long int) =
nullptr;
5213 void (*fDestroyStabilizerSimulator)(
void *) =
nullptr;
5214 int (*fExecuteStabilizerCircuit)(
void *,
const char *, int,
unsigned long long int) =
nullptr;
5215 long long (*fGetStabilizerXZTableSize)(
void *) =
nullptr;
5216 long long (*fGetStabilizerMTableSize)(
void *) =
nullptr;
5217 long long (*fGetStabilizerTableStrideMajor)(
void *) =
nullptr;
5218 long long (*fGetStabilizerNumQubits)(
void *) =
nullptr;
5219 long long (*fGetStabilizerNumShots)(
void *) =
nullptr;
5220 long long (*fGetStabilizerNumMeasurements)(
void *) =
nullptr;
5221 long long (*fGetStabilizerNumDetectors)(
void *) =
nullptr;
5222 int (*fCopyStabilizerXTable)(
void *,
unsigned int *) =
nullptr;
5223 int (*fCopyStabilizerZTable)(
void *,
unsigned int *) =
nullptr;
5224 int (*fCopyStabilizerMTable)(
void *,
unsigned int *) =
nullptr;
5225 int (*fInitStabilizerXTable)(
void *,
const unsigned int *) =
nullptr;
5226 int (*fInitStabilizerZTable)(
void *,
const unsigned int *) =
nullptr;
5228 void *(*fCreatePauliPropSimulator)(int) =
nullptr;
5229 void (*fDestroyPauliPropSimulator)(
void *) =
nullptr;
5231 int (*fPauliPropGetNrQubits)(
void *) =
nullptr;
5232 int (*fPauliPropSetWillUseSampling)(
void *, int) =
nullptr;
5233 int (*fPauliPropGetWillUseSampling)(
void *) =
nullptr;
5234 double (*fPauliPropGetCoefficientTruncationCutoff)(
void *) =
nullptr;
5235 void (*fPauliPropSetCoefficientTruncationCutoff)(
void *, double) =
nullptr;
5236 double (*fPauliPropGetWeightTruncationCutoff)(
void *) =
nullptr;
5237 void (*fPauliPropSetWeightTruncationCutoff)(
void *, double) =
nullptr;
5238 int (*fPauliPropGetNumGatesBetweenTruncations)(
void *) =
nullptr;
5239 void (*fPauliPropSetNumGatesBetweenTruncations)(
void *, int) =
nullptr;
5240 int (*fPauliPropGetNumGatesBetweenDeduplications)(
void *) =
nullptr;
5241 void (*fPauliPropSetNumGatesBetweenDeduplications)(
void *, int) =
nullptr;
5242 int (*fPauliPropClearOperators)(
void *) =
nullptr;
5243 int (*fPauliPropAllocateMemory)(
void *, double) =
nullptr;
5244 double (*fPauliPropGetExpectationValue)(
void *) =
nullptr;
5245 int (*fPauliPropExecute)(
void *) =
nullptr;
5246 int (*fPauliPropSetSeed)(
void *,
unsigned long long) =
nullptr;
5247 int (*fPauliPropSetInPauliExpansionUnique)(
void *,
const char *) =
nullptr;
5248 int (*fPauliPropSetInPauliExpansionMultiple)(
void *,
const char **,
const double *, int) =
nullptr;
5250 int (*fPauliPropApplyX)(
void *, int) =
nullptr;
5251 int (*fPauliPropApplyY)(
void *, int) =
nullptr;
5252 int (*fPauliPropApplyZ)(
void *, int) =
nullptr;
5253 int (*fPauliPropApplyH)(
void *, int) =
nullptr;
5254 int (*fPauliPropApplyS)(
void *, int) =
nullptr;
5255 int (*fPauliPropApplySQRTX)(
void *, int) =
nullptr;
5256 int (*fPauliPropApplySQRTY)(
void *, int) =
nullptr;
5257 int (*fPauliPropApplySQRTZ)(
void *, int) =
nullptr;
5258 int (*fPauliPropApplyCX)(
void *, int, int) =
nullptr;
5259 int (*fPauliPropApplyCY)(
void *, int, int) =
nullptr;
5260 int (*fPauliPropApplyCZ)(
void *, int, int) =
nullptr;
5261 int (*fPauliPropApplySWAP)(
void *, int, int) =
nullptr;
5262 int (*fPauliPropApplyISWAP)(
void *, int, int) =
nullptr;
5263 int (*fPauliPropApplyRX)(
void *, int, double) =
nullptr;
5264 int (*fPauliPropApplyRY)(
void *, int, double) =
nullptr;
5265 int (*fPauliPropApplyRZ)(
void *, int, double) =
nullptr;
5266 int (*fPauliPropAddNoiseX)(
void *, int, double) =
nullptr;
5267 int (*fPauliPropAddNoiseY)(
void *, int, double) =
nullptr;
5268 int (*fPauliPropAddNoiseZ)(
void *, int, double) =
nullptr;
5269 int (*fPauliPropAddNoiseXYZ)(
void *, int, double, double, double) =
nullptr;
5270 int (*fPauliPropAddAmplitudeDamping)(
void *, int, double, double) =
nullptr;
5271 double (*fPauliPropQubitProbability0)(
void *, int) =
nullptr;
5272 double (*fPauliPropProbability)(
void *,
unsigned long long int) =
nullptr;
5274 int (*fPauliPropMeasureQubit)(
void *, int) =
nullptr;
5275 unsigned char *(*fPauliPropSampleQubits)(
void *,
const int *, int) =
nullptr;
5276 void (*fPauliPropFreeSampledQubits)(
unsigned char *) =
nullptr;
5277 void (*fPauliPropSaveState)(
void *) =
nullptr;
5278 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
Bounded online routing based on current physical bond dimensions.