3#include "../Utils/Library.h"
17 bool Init(
const char* libName)
noexcept override {
19 fGetMaestroObject = (
void* (*)())
GetFunction(
"GetMaestroObjectWithMute");
21 if (fGetMaestroObject) {
22 maestro = fGetMaestroObject();
24 fCreateSimpleSimulator =
25 (
unsigned long int (*)(int))
GetFunction(
"CreateSimpleSimulator");
27 fDestroySimpleSimulator = (void (*)(
unsigned long int))
GetFunction(
28 "DestroySimpleSimulator");
31 fRemoveAllOptimizationSimulatorsAndAdd = (int (*)(
32 unsigned long int simHandle,
int simType,
int simExecType))
33 GetFunction(
"RemoveAllOptimizationSimulatorsAndAdd");
36 fAddOptimizationSimulator =
37 (int (*)(
unsigned long int simHandle,
int simType,
38 int simExecType))
GetFunction(
"AddOptimizationSimulator");
41 fSimpleExecute = (
char* (*)(
unsigned long int,
const char*,
45 fSimpleEstimate = (
char* (*)(
unsigned long int,
const char*,
const char*,
49 fFreeResult = (void (*)(
char*))
GetFunction(
"FreeResult");
53 (
unsigned long int (*)(int, int))
GetFunction(
"CreateSimulator");
56 (
void* (*)(
unsigned long int))
GetFunction(
"GetSimulator");
59 (void (*)(
unsigned long int))
GetFunction(
"DestroySimulator");
62 fInitializeSimulator =
65 fResetSimulator = (int (*)(
void*))
GetFunction(
"ResetSimulator");
68 (int (*)(
void*,
const char*,
const char*))
GetFunction(
69 "ConfigureSimulator");
72 (
char* (*)(
void*,
const char*))
GetFunction(
"GetConfiguration");
74 fAllocateQubits = (
unsigned long int (*)(
75 void*,
unsigned long int))
GetFunction(
"AllocateQubits");
78 (
unsigned long int (*)(
void*))
GetFunction(
"GetNumberOfQubits");
80 fClearSimulator = (int (*)(
void*))
GetFunction(
"ClearSimulator");
82 fMeasure = (
unsigned long long int (*)(
83 void*,
const unsigned long int*,
86 fApplyReset = (int (*)(
void*,
const unsigned long int*,
89 fProbability = (double (*)(
void*,
unsigned long long int))
GetFunction(
96 (void (*)(
unsigned long long int*))
GetFunction(
"FreeULLIVector");
98 fAmplitude = (
double* (*)(
void*,
unsigned long long int))
GetFunction(
102 (
double* (*)(
void*))
GetFunction(
"AllProbabilities");
105 (
double* (*)(
void*,
const unsigned long long int*,
109 (
unsigned long long int* (*)(
void*,
const unsigned long long int*,
114 fGetSimulatorType = (int (*)(
void*))
GetFunction(
"GetSimulatorType");
116 fGetSimulationType = (int (*)(
void*))
GetFunction(
"GetSimulationType");
118 fFlushSimulator = (int (*)(
void*))
GetFunction(
"FlushSimulator");
120 fSaveStateToInternalDestructive =
121 (int (*)(
void*))
GetFunction(
"SaveStateToInternalDestructive");
122 CheckFunction((
void*)fSaveStateToInternalDestructive, __LINE__);
123 fRestoreInternalDestructiveSavedState = (int (*)(
void*))
GetFunction(
124 "RestoreInternalDestructiveSavedState");
125 CheckFunction((
void*)fRestoreInternalDestructiveSavedState, __LINE__);
126 fSaveState = (int (*)(
void*))
GetFunction(
"SaveState");
128 fRestoreState = (int (*)(
void*))
GetFunction(
"RestoreState");
131 (int (*)(
void*, int))
GetFunction(
"SetMultithreading");
133 fGetMultithreading = (int (*)(
void*))
GetFunction(
"GetMultithreading");
137 fMeasureNoCollapse = (
unsigned long long int (*)(
void*))
GetFunction(
138 "MeasureNoCollapse");
141 fApplyX = (int (*)(
void*, int))
GetFunction(
"ApplyX");
143 fApplyY = (int (*)(
void*, int))
GetFunction(
"ApplyY");
145 fApplyZ = (int (*)(
void*, int))
GetFunction(
"ApplyZ");
147 fApplyH = (int (*)(
void*, int))
GetFunction(
"ApplyH");
149 fApplyS = (int (*)(
void*, int))
GetFunction(
"ApplyS");
151 fApplySDG = (int (*)(
void*, int))
GetFunction(
"ApplySDG");
153 fApplyT = (int (*)(
void*, int))
GetFunction(
"ApplyT");
155 fApplyTDG = (int (*)(
void*, int))
GetFunction(
"ApplyTDG");
157 fApplySX = (int (*)(
void*, int))
GetFunction(
"ApplySX");
159 fApplySXDG = (int (*)(
void*, int))
GetFunction(
"ApplySXDG");
161 fApplyK = (int (*)(
void*, int))
GetFunction(
"ApplyK");
163 fApplyP = (int (*)(
void*, int, double))
GetFunction(
"ApplyP");
165 fApplyRx = (int (*)(
void*, int, double))
GetFunction(
"ApplyRx");
167 fApplyRy = (int (*)(
void*, int, double))
GetFunction(
"ApplyRy");
169 fApplyRz = (int (*)(
void*, int, double))
GetFunction(
"ApplyRz");
171 fApplyU = (int (*)(
void*, int, double, double, double,
174 fApplyCX = (int (*)(
void*, int, int))
GetFunction(
"ApplyCX");
176 fApplyCY = (int (*)(
void*, int, int))
GetFunction(
"ApplyCY");
178 fApplyCZ = (int (*)(
void*, int, int))
GetFunction(
"ApplyCZ");
180 fApplyCH = (int (*)(
void*, int, int))
GetFunction(
"ApplyCH");
182 fApplyCSX = (int (*)(
void*, int, int))
GetFunction(
"ApplyCSX");
184 fApplyCSXDG = (int (*)(
void*, int, int))
GetFunction(
"ApplyCSXDG");
186 fApplyCP = (int (*)(
void*, int, int, double))
GetFunction(
"ApplyCP");
188 fApplyCRx = (int (*)(
void*, int, int, double))
GetFunction(
"ApplyCRx");
190 fApplyCRy = (int (*)(
void*, int, int, double))
GetFunction(
"ApplyCRy");
192 fApplyCRz = (int (*)(
void*, int, int, double))
GetFunction(
"ApplyCRz");
194 fApplyCCX = (int (*)(
void*, int, int, int))
GetFunction(
"ApplyCCX");
196 fApplySwap = (int (*)(
void*, int, int))
GetFunction(
"ApplySwap");
199 (int (*)(
void*, int, int, int))
GetFunction(
"ApplyCSwap");
201 fApplyCU = (int (*)(
void*, int, int, double, double, double,
208 std::cerr <<
"MaestroLibrary: Unable to get initialization function "
212 std::cerr <<
"MaestroLibrary: Unable to load the library" << std::endl;
219 std::cerr <<
"MaestroLibrary: Unable to load function, line #: " << line;
222 const char* dlsym_error = dlerror();
223 if (dlsym_error) std::cerr <<
", error: " << dlsym_error;
225 const DWORD error = GetLastError();
226 std::cerr <<
", error code: " << error;
229 std::cerr << std::endl;
233 bool IsValid()
const {
return maestro !=
nullptr; }
236 if (maestro && fCreateSimpleSimulator)
237 return fCreateSimpleSimulator(nrQubits);
239 throw std::runtime_error(
240 "MaestroLibrary: Unable to create the simple simulator.");
246 if (maestro && fDestroySimpleSimulator)
247 fDestroySimpleSimulator(simHandle);
249 throw std::runtime_error(
250 "MaestroLibrary: Unable to destroy the simple simulator.");
254 int simType,
int simExecType) {
255 if (maestro && fRemoveAllOptimizationSimulatorsAndAdd)
256 return fRemoveAllOptimizationSimulatorsAndAdd(simHandle, simType,
259 throw std::runtime_error(
260 "MaestroLibrary: Unable to remove all optimization simulators and "
268 if (maestro && fAddOptimizationSimulator)
269 return fAddOptimizationSimulator(simHandle, simType, simExecType);
271 throw std::runtime_error(
272 "MaestroLibrary: Unable to add an optimization simulator.");
278 const char* jsonConfig) {
279 if (maestro && fSimpleExecute)
280 return fSimpleExecute(simpleSim, jsonCircuit, jsonConfig);
282 throw std::runtime_error(
283 "MaestroLibrary: Unable to execute the simple simulator.");
289 const char* observableStr,
const char* jsonConfig) {
290 if (maestro && fSimpleEstimate)
291 return fSimpleEstimate(simpleSim, jsonCircuit, observableStr, jsonConfig);
293 throw std::runtime_error(
294 "MaestroLibrary: Unable to execute the simple simulator for "
295 "expectation values.");
301 if (maestro && fFreeResult)
304 throw std::runtime_error(
"MaestroLibrary: Unable to free the result.");
308 if (maestro && fCreateSimulator)
309 return fCreateSimulator(simType, simExecType);
311 throw std::runtime_error(
312 "MaestroLibrary: Unable to create the simulator.");
318 if (maestro && fGetSimulator)
319 return fGetSimulator(simHandle);
321 throw std::runtime_error(
"MaestroLibrary: Unable to get the simulator.");
325 if (maestro && fDestroySimulator)
326 fDestroySimulator(simHandle);
328 throw std::runtime_error(
329 "MaestroLibrary: Unable to destroy the simulator.");
333 if (maestro && sim && fInitializeSimulator)
334 return fInitializeSimulator(sim);
336 throw std::runtime_error(
337 "MaestroLibrary: Unable to initialize the simulator.");
343 if (maestro && sim && fResetSimulator)
344 return fResetSimulator(sim);
346 throw std::runtime_error(
347 "MaestroLibrary: Unable to reset the simulator.");
353 if (maestro && sim && fConfigureSimulator)
354 return fConfigureSimulator(sim, key, value);
356 throw std::runtime_error(
357 "MaestroLibrary: Unable to configure the simulator.");
363 if (maestro && sim && fGetConfiguration)
364 return fGetConfiguration(sim, key);
366 throw std::runtime_error(
367 "MaestroLibrary: Unable to get the configuration of the simulator.");
372 if (maestro && sim && fAllocateQubits)
373 return fAllocateQubits(sim, nrQubits);
375 throw std::runtime_error(
376 "MaestroLibrary: Unable to allocate qubits in the simulator.");
381 if (maestro && sim && fGetNumberOfQubits)
382 return fGetNumberOfQubits(sim);
384 throw std::runtime_error(
385 "MaestroLibrary: Unable to get the number of qubits in the "
391 if (maestro && sim && fClearSimulator)
392 return fClearSimulator(sim);
394 throw std::runtime_error(
395 "MaestroLibrary: Unable to clear the simulator.");
399 unsigned long long int Measure(
void* sim,
const unsigned long int* qubits,
400 unsigned long int nrQubits) {
401 if (maestro && sim && fMeasure)
402 return fMeasure(sim, qubits, nrQubits);
404 throw std::runtime_error(
405 "MaestroLibrary: Unable to measure the simulator.");
410 unsigned long int nrQubits) {
411 if (maestro && sim && fApplyReset)
412 return fApplyReset(sim, qubits, nrQubits);
414 throw std::runtime_error(
415 "MaestroLibrary: Unable to apply reset to the simulator.");
420 if (maestro && sim && fProbability)
421 return fProbability(sim, outcome);
423 throw std::runtime_error(
424 "MaestroLibrary: Unable to get the probability of an outcome.");
429 if (maestro && fFreeDoubleVector)
430 fFreeDoubleVector(vec);
432 throw std::runtime_error(
433 "MaestroLibrary: Unable to free the double vector.");
437 if (maestro && fFreeULLIVector)
438 fFreeULLIVector(vec);
440 throw std::runtime_error(
441 "MaestroLibrary: Unable to free the unsigned long long int vector.");
444 double*
Amplitude(
void* sim,
unsigned long long int outcome) {
445 if (maestro && sim && fAmplitude)
446 return fAmplitude(sim, outcome);
448 throw std::runtime_error(
449 "MaestroLibrary: Unable to get the amplitude of an outcome.");
454 if (maestro && sim && fAllProbabilities)
455 return fAllProbabilities(sim);
457 throw std::runtime_error(
458 "MaestroLibrary: Unable to get all probabilities.");
463 unsigned long int nrQubits) {
464 if (maestro && sim && fProbabilities)
465 return fProbabilities(sim, qubits, nrQubits);
467 throw std::runtime_error(
468 "MaestroLibrary: Unable to get probabilities for specified qubits.");
473 const unsigned long long int* qubits,
474 unsigned long int nrQubits,
475 unsigned long int shots) {
476 if (maestro && sim && fSampleCounts)
477 return fSampleCounts(sim, qubits, nrQubits, shots);
479 throw std::runtime_error(
480 "MaestroLibrary: Unable to get sample counts for specified qubits.");
485 if (maestro && sim && fGetSimulatorType)
486 return fGetSimulatorType(sim);
488 throw std::runtime_error(
489 "MaestroLibrary: Unable to get the simulator type.");
494 if (maestro && sim && fGetSimulationType)
495 return fGetSimulationType(sim);
497 throw std::runtime_error(
498 "MaestroLibrary: Unable to get the simulation type.");
503 if (maestro && sim && fFlushSimulator)
504 return fFlushSimulator(sim);
506 throw std::runtime_error(
507 "MaestroLibrary: Unable to flush the simulator.");
512 if (maestro && sim && fSaveStateToInternalDestructive)
513 return fSaveStateToInternalDestructive(sim);
515 throw std::runtime_error(
516 "MaestroLibrary: Unable to save the state to internal destructive "
522 if (maestro && sim && fRestoreInternalDestructiveSavedState)
523 return fRestoreInternalDestructiveSavedState(sim);
525 throw std::runtime_error(
526 "MaestroLibrary: Unable to restore the state from internal "
527 "destructive storage.");
532 if (maestro && sim && fSaveState)
533 return fSaveState(sim);
535 throw std::runtime_error(
"MaestroLibrary: Unable to save the state.");
540 if (maestro && sim && fRestoreState)
541 return fRestoreState(sim);
543 throw std::runtime_error(
"MaestroLibrary: Unable to restore the state.");
548 if (maestro && sim && fSetMultithreading)
549 return fSetMultithreading(sim, multithreading);
551 throw std::runtime_error(
"MaestroLibrary: Unable to set multithreading.");
556 if (maestro && sim && fGetMultithreading)
557 return fGetMultithreading(sim);
559 throw std::runtime_error(
560 "MaestroLibrary: Unable to get multithreading status.");
565 if (maestro && sim && fIsQcsim)
566 return fIsQcsim(sim);
568 throw std::runtime_error(
569 "MaestroLibrary: Unable to check if the simulator is a QCSIM.");
574 if (maestro && sim && fMeasureNoCollapse)
575 return fMeasureNoCollapse(sim);
577 throw std::runtime_error(
578 "MaestroLibrary: Unable to measure without collapse.");
583 if (maestro && sim && fApplyX)
584 return fApplyX(sim, qubit);
586 throw std::runtime_error(
"MaestroLibrary: Unable to apply X gate.");
591 if (maestro && sim && fApplyY)
592 return fApplyY(sim, qubit);
594 throw std::runtime_error(
"MaestroLibrary: Unable to apply Y gate.");
599 if (maestro && sim && fApplyZ)
600 return fApplyZ(sim, qubit);
602 throw std::runtime_error(
"MaestroLibrary: Unable to apply Z gate.");
607 if (maestro && sim && fApplyH)
608 return fApplyH(sim, qubit);
610 throw std::runtime_error(
"MaestroLibrary: Unable to apply H gate.");
615 if (maestro && sim && fApplyS)
616 return fApplyS(sim, qubit);
618 throw std::runtime_error(
"MaestroLibrary: Unable to apply S gate.");
623 if (maestro && sim && fApplySDG)
624 return fApplySDG(sim, qubit);
626 throw std::runtime_error(
"MaestroLibrary: Unable to apply SDG gate.");
631 if (maestro && sim && fApplyT)
632 return fApplyT(sim, qubit);
634 throw std::runtime_error(
"MaestroLibrary: Unable to apply T gate.");
639 if (maestro && sim && fApplyTDG)
640 return fApplyTDG(sim, qubit);
642 throw std::runtime_error(
"MaestroLibrary: Unable to apply TDG gate.");
647 if (maestro && sim && fApplySX)
648 return fApplySX(sim, qubit);
650 throw std::runtime_error(
"MaestroLibrary: Unable to apply SX gate.");
655 if (maestro && sim && fApplySXDG)
656 return fApplySXDG(sim, qubit);
658 throw std::runtime_error(
"MaestroLibrary: Unable to apply SXDG gate.");
663 if (maestro && sim && fApplyK)
664 return fApplyK(sim, qubit);
666 throw std::runtime_error(
"MaestroLibrary: Unable to apply K gate.");
670 int ApplyP(
void* sim,
int qubit,
double theta) {
671 if (maestro && sim && fApplyP)
672 return fApplyP(sim, qubit, theta);
674 throw std::runtime_error(
"MaestroLibrary: Unable to apply P gate.");
678 int ApplyRx(
void* sim,
int qubit,
double theta) {
679 if (maestro && sim && fApplyRx)
680 return fApplyRx(sim, qubit, theta);
682 throw std::runtime_error(
"MaestroLibrary: Unable to apply Rx gate.");
686 int ApplyRy(
void* sim,
int qubit,
double theta) {
687 if (maestro && sim && fApplyRy)
688 return fApplyRy(sim, qubit, theta);
690 throw std::runtime_error(
"MaestroLibrary: Unable to apply Ry gate.");
694 int ApplyRz(
void* sim,
int qubit,
double theta) {
695 if (maestro && sim && fApplyRz)
696 return fApplyRz(sim, qubit, theta);
698 throw std::runtime_error(
"MaestroLibrary: Unable to apply Rz gate.");
702 int ApplyU(
void* sim,
int qubit,
double theta,
double phi,
double lambda,
704 if (maestro && sim && fApplyU)
705 return fApplyU(sim, qubit, theta, phi, lambda, gamma);
707 throw std::runtime_error(
"MaestroLibrary: Unable to apply U gate.");
711 int ApplyCX(
void* sim,
int controlQubit,
int targetQubit) {
712 if (maestro && sim && fApplyCX)
713 return fApplyCX(sim, controlQubit, targetQubit);
715 throw std::runtime_error(
"MaestroLibrary: Unable to apply CX gate.");
719 int ApplyCY(
void* sim,
int controlQubit,
int targetQubit) {
720 if (maestro && sim && fApplyCY)
721 return fApplyCY(sim, controlQubit, targetQubit);
723 throw std::runtime_error(
"MaestroLibrary: Unable to apply CY gate.");
727 int ApplyCZ(
void* sim,
int controlQubit,
int targetQubit) {
728 if (maestro && sim && fApplyCZ)
729 return fApplyCZ(sim, controlQubit, targetQubit);
731 throw std::runtime_error(
"MaestroLibrary: Unable to apply CZ gate.");
735 int ApplyCH(
void* sim,
int controlQubit,
int targetQubit) {
736 if (maestro && sim && fApplyCH)
737 return fApplyCH(sim, controlQubit, targetQubit);
739 throw std::runtime_error(
"MaestroLibrary: Unable to apply CH gate.");
743 int ApplyCSX(
void* sim,
int controlQubit,
int targetQubit) {
744 if (maestro && sim && fApplyCSX)
745 return fApplyCSX(sim, controlQubit, targetQubit);
747 throw std::runtime_error(
"MaestroLibrary: Unable to apply CSX gate.");
751 int ApplyCSXDG(
void* sim,
int controlQubit,
int targetQubit) {
752 if (maestro && sim && fApplyCSXDG)
753 return fApplyCSXDG(sim, controlQubit, targetQubit);
755 throw std::runtime_error(
"MaestroLibrary: Unable to apply CSXDG gate.");
759 int ApplyCP(
void* sim,
int controlQubit,
int targetQubit,
double theta) {
760 if (maestro && sim && fApplyCP)
761 return fApplyCP(sim, controlQubit, targetQubit, theta);
763 throw std::runtime_error(
"MaestroLibrary: Unable to apply CP gate.");
767 int ApplyCRx(
void* sim,
int controlQubit,
int targetQubit,
double theta) {
768 if (maestro && sim && fApplyCRx)
769 return fApplyCRx(sim, controlQubit, targetQubit, theta);
771 throw std::runtime_error(
"MaestroLibrary: Unable to apply CRx gate.");
775 int ApplyCRy(
void* sim,
int controlQubit,
int targetQubit,
double theta) {
776 if (maestro && sim && fApplyCRy)
777 return fApplyCRy(sim, controlQubit, targetQubit, theta);
779 throw std::runtime_error(
"MaestroLibrary: Unable to apply CRy gate.");
783 int ApplyCRz(
void* sim,
int controlQubit,
int targetQubit,
double theta) {
784 if (maestro && sim && fApplyCRz)
785 return fApplyCRz(sim, controlQubit, targetQubit, theta);
787 throw std::runtime_error(
"MaestroLibrary: Unable to apply CRz gate.");
791 int ApplyCCX(
void* sim,
int controlQubit1,
int controlQubit2,
793 if (maestro && sim && fApplyCCX)
794 return fApplyCCX(sim, controlQubit1, controlQubit2, targetQubit);
796 throw std::runtime_error(
"MaestroLibrary: Unable to apply CCX gate.");
801 if (maestro && sim && fApplySwap)
802 return fApplySwap(sim, qubit1, qubit2);
804 throw std::runtime_error(
"MaestroLibrary: Unable to apply Swap gate.");
808 int ApplyCSwap(
void* sim,
int controlQubit,
int qubit1,
int qubit2) {
809 if (maestro && sim && fApplyCSwap)
810 return fApplyCSwap(sim, controlQubit, qubit1, qubit2);
812 throw std::runtime_error(
"MaestroLibrary: Unable to apply CSwap gate.");
816 int ApplyCU(
void* sim,
int controlQubit,
int targetQubit,
double theta,
817 double phi,
double lambda,
double gamma) {
818 if (maestro && sim && fApplyCU)
819 return fApplyCU(sim, controlQubit, targetQubit, theta, phi, lambda,
822 throw std::runtime_error(
"MaestroLibrary: Unable to apply CU gate.");
827 void* maestro =
nullptr;
829 void* (*fGetMaestroObject)();
831 unsigned long int (*fCreateSimpleSimulator)(int);
832 void (*fDestroySimpleSimulator)(
unsigned long int);
834 int (*fRemoveAllOptimizationSimulatorsAndAdd)(
unsigned long int, int, int);
835 int (*fAddOptimizationSimulator)(
unsigned long int, int, int);
837 char* (*fSimpleExecute)(
unsigned long int,
const char*,
const char*);
838 char* (*fSimpleEstimate)(
unsigned long int,
const char*,
const char*,
840 void (*fFreeResult)(
char*);
842 unsigned long int (*fCreateSimulator)(int, int);
843 void* (*fGetSimulator)(
unsigned long int);
844 void (*fDestroySimulator)(
unsigned long int);
846 int (*fInitializeSimulator)(
void*);
847 int (*fResetSimulator)(
void*);
848 int (*fConfigureSimulator)(
void*,
const char*,
const char*);
849 char* (*fGetConfiguration)(
void*,
const char*);
850 unsigned long int (*fAllocateQubits)(
void*,
unsigned long int);
851 unsigned long int (*fGetNumberOfQubits)(
void*);
852 int (*fClearSimulator)(
void*);
853 unsigned long long int (*fMeasure)(
void*,
const unsigned long int*,
855 int (*fApplyReset)(
void*,
const unsigned long int*,
unsigned long int);
856 double (*fProbability)(
void*,
unsigned long long int);
857 void (*fFreeDoubleVector)(
double*);
858 void (*fFreeULLIVector)(
unsigned long long int*);
859 double* (*fAmplitude)(
void*,
unsigned long long int);
860 double* (*fAllProbabilities)(
void*);
861 double* (*fProbabilities)(
void*,
const unsigned long long int*,
863 unsigned long long int* (*fSampleCounts)(
void*,
const unsigned long long int*,
866 int (*fGetSimulatorType)(
void*);
867 int (*fGetSimulationType)(
void*);
868 int (*fFlushSimulator)(
void*);
869 int (*fSaveStateToInternalDestructive)(
void*);
870 int (*fRestoreInternalDestructiveSavedState)(
void*);
871 int (*fSaveState)(
void*);
872 int (*fRestoreState)(
void*);
873 int (*fSetMultithreading)(
void*, int);
874 int (*fGetMultithreading)(
void*);
875 int (*fIsQcsim)(
void*);
876 unsigned long long int (*fMeasureNoCollapse)(
void*);
878 int (*fApplyX)(
void*, int);
879 int (*fApplyY)(
void*, int);
880 int (*fApplyZ)(
void*, int);
881 int (*fApplyH)(
void*, int);
882 int (*fApplyS)(
void*, int);
883 int (*fApplySDG)(
void*, int);
884 int (*fApplyT)(
void*, int);
885 int (*fApplyTDG)(
void*, int);
886 int (*fApplySX)(
void*, int);
887 int (*fApplySXDG)(
void*, int);
888 int (*fApplyK)(
void*, int);
889 int (*fApplyP)(
void*, int, double);
890 int (*fApplyRx)(
void*, int, double);
891 int (*fApplyRy)(
void*, int, double);
892 int (*fApplyRz)(
void*, int, double);
893 int (*fApplyU)(
void*, int, double, double, double, double);
894 int (*fApplyCX)(
void*, int, int);
895 int (*fApplyCY)(
void*, int, int);
896 int (*fApplyCZ)(
void*, int, int);
897 int (*fApplyCH)(
void*, int, int);
898 int (*fApplyCSX)(
void*, int, int);
899 int (*fApplyCSXDG)(
void*, int, int);
900 int (*fApplyCP)(
void*, int, int, double);
901 int (*fApplyCRx)(
void*, int, int, double);
902 int (*fApplyCRy)(
void*, int, int, double);
903 int (*fApplyCRz)(
void*, int, int, double);
904 int (*fApplyCCX)(
void*, int, int, int);
905 int (*fApplySwap)(
void*, int, int);
906 int (*fApplyCSwap)(
void*, int, int, int);
907 int (*fApplyCU)(
void*, int, int, double, double, double, double);
int ApplyCCX(void *sim, int controlQubit1, int controlQubit2, int targetQubit)
int ResetSimulator(void *sim)
void * GetSimulator(unsigned long int simHandle)
int ApplyCZ(void *sim, int controlQubit, int targetQubit)
MaestroLibrary() noexcept
unsigned long int AllocateQubits(void *sim, unsigned long int nrQubits)
int ConfigureSimulator(void *sim, const char *key, const char *value)
MaestroLibrary & operator=(const MaestroLibrary &)=delete
unsigned long long int * SampleCounts(void *sim, const unsigned long long int *qubits, unsigned long int nrQubits, unsigned long int shots)
int ApplySXDG(void *sim, int qubit)
int ApplyS(void *sim, int qubit)
int GetSimulationType(void *sim)
int GetSimulatorType(void *sim)
int ApplyH(void *sim, int qubit)
double * AllProbabilities(void *sim)
unsigned long long int Measure(void *sim, const unsigned long int *qubits, unsigned long int nrQubits)
int ApplySDG(void *sim, int qubit)
int RemoveAllOptimizationSimulatorsAndAdd(unsigned long int simHandle, int simType, int simExecType)
int ApplyT(void *sim, int qubit)
int ApplyY(void *sim, int qubit)
virtual ~MaestroLibrary()
static void CheckFunction(void *func, int line) noexcept
int ApplySX(void *sim, int qubit)
int ApplyX(void *sim, int qubit)
int ApplyCY(void *sim, int controlQubit, int targetQubit)
int ApplyCX(void *sim, int controlQubit, int targetQubit)
void DestroySimpleSimulator(unsigned long int simHandle)
int ApplyCRx(void *sim, int controlQubit, int targetQubit, double theta)
int ClearSimulator(void *sim)
int ApplyCSX(void *sim, int controlQubit, int targetQubit)
int ApplyK(void *sim, int qubit)
char * SimpleExecute(unsigned long int simpleSim, const char *jsonCircuit, const char *jsonConfig)
int RestoreState(void *sim)
int ApplyCRz(void *sim, int controlQubit, int targetQubit, double theta)
double * Amplitude(void *sim, unsigned long long int outcome)
int AddOptimizationSimulator(unsigned long int simHandle, int simType, int simExecType)
virtual unsigned long int CreateSimpleSimulator(int nrQubits)
char * SimpleEstimate(unsigned long int simpleSim, const char *jsonCircuit, const char *observableStr, const char *jsonConfig)
double Probability(void *sim, unsigned long long int outcome)
int ApplyCH(void *sim, int controlQubit, int targetQubit)
int ApplyCSwap(void *sim, int controlQubit, int qubit1, int qubit2)
virtual void FreeULLIVector(unsigned long long int *vec)
virtual unsigned long int CreateSimulator(int simType, int simExecType)
int ApplyCSXDG(void *sim, int controlQubit, int targetQubit)
int SaveStateToInternalDestructive(void *sim)
virtual void FreeDoubleVector(double *vec)
MaestroLibrary & operator=(MaestroLibrary &&)=default
int ApplyCRy(void *sim, int controlQubit, int targetQubit, double theta)
double * Probabilities(void *sim, const unsigned long long int *qubits, unsigned long int nrQubits)
int ApplyRz(void *sim, int qubit, double theta)
MaestroLibrary(const MaestroLibrary &)=delete
int ApplySwap(void *sim, int qubit1, int qubit2)
void DestroySimulator(unsigned long int simHandle)
int ApplyU(void *sim, int qubit, double theta, double phi, double lambda, double gamma)
int ApplyZ(void *sim, int qubit)
int RestoreInternalDestructiveSavedState(void *sim)
int ApplyCU(void *sim, int controlQubit, int targetQubit, double theta, double phi, double lambda, double gamma)
int ApplyReset(void *sim, const unsigned long int *qubits, unsigned long int nrQubits)
int InitializeSimulator(void *sim)
int ApplyP(void *sim, int qubit, double theta)
int ApplyRy(void *sim, int qubit, double theta)
bool Init(const char *libName) noexcept override
int ApplyCP(void *sim, int controlQubit, int targetQubit, double theta)
int FlushSimulator(void *sim)
MaestroLibrary(MaestroLibrary &&)=default
int GetMultithreading(void *sim)
virtual void FreeResult(char *result)
int ApplyRx(void *sim, int qubit, double theta)
unsigned long int GetNumberOfQubits(void *sim)
char * GetConfiguration(void *sim, const char *key)
int ApplyTDG(void *sim, int qubit)
unsigned long long int MeasureNoCollapse(void *sim)
int SetMultithreading(void *sim, int multithreading)
void * GetFunction(const char *funcName) noexcept
virtual bool Init(const char *libName) noexcept