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*,
46 (
char* (*)(
unsigned long int,
const char*,
const char*,
50 fFreeResult = (void (*)(
char*))
GetFunction(
"FreeResult");
54 (
unsigned long int (*)(int, int))
GetFunction(
"CreateSimulator");
57 (
void* (*)(
unsigned long int))
GetFunction(
"GetSimulator");
60 (void (*)(
unsigned long int))
GetFunction(
"DestroySimulator");
63 fInitializeSimulator =
66 fResetSimulator = (int (*)(
void*))
GetFunction(
"ResetSimulator");
69 (int (*)(
void*,
const char*,
const char*))
GetFunction(
70 "ConfigureSimulator");
73 (
char* (*)(
void*,
const char*))
GetFunction(
"GetConfiguration");
75 fAllocateQubits = (
unsigned long int (*)(
76 void*,
unsigned long int))
GetFunction(
"AllocateQubits");
79 (
unsigned long int (*)(
void*))
GetFunction(
"GetNumberOfQubits");
81 fClearSimulator = (int (*)(
void*))
GetFunction(
"ClearSimulator");
83 fMeasure = (
unsigned long long int (*)(
84 void*,
const unsigned long int*,
87 fApplyReset = (int (*)(
void*,
const unsigned long int*,
90 fProbability = (double (*)(
void*,
unsigned long long int))
GetFunction(
97 (void (*)(
unsigned long long int*))
GetFunction(
"FreeULLIVector");
99 fAmplitude = (
double* (*)(
void*,
unsigned long long int))
GetFunction(
103 (
double* (*)(
void*))
GetFunction(
"AllProbabilities");
106 (
double* (*)(
void*,
const unsigned long long int*,
110 (
unsigned long long int* (*)(
void*,
const unsigned long long int*,
115 fGetSimulatorType = (int (*)(
void*))
GetFunction(
"GetSimulatorType");
117 fGetSimulationType = (int (*)(
void*))
GetFunction(
"GetSimulationType");
119 fFlushSimulator = (int (*)(
void*))
GetFunction(
"FlushSimulator");
121 fSaveStateToInternalDestructive =
122 (int (*)(
void*))
GetFunction(
"SaveStateToInternalDestructive");
123 CheckFunction((
void*)fSaveStateToInternalDestructive, __LINE__);
124 fRestoreInternalDestructiveSavedState = (int (*)(
void*))
GetFunction(
125 "RestoreInternalDestructiveSavedState");
126 CheckFunction((
void*)fRestoreInternalDestructiveSavedState, __LINE__);
127 fSaveState = (int (*)(
void*))
GetFunction(
"SaveState");
129 fRestoreState = (int (*)(
void*))
GetFunction(
"RestoreState");
132 (int (*)(
void*, int))
GetFunction(
"SetMultithreading");
134 fGetMultithreading = (int (*)(
void*))
GetFunction(
"GetMultithreading");
138 fMeasureNoCollapse = (
unsigned long long int (*)(
void*))
GetFunction(
139 "MeasureNoCollapse");
142 fApplyX = (int (*)(
void*, int))
GetFunction(
"ApplyX");
144 fApplyY = (int (*)(
void*, int))
GetFunction(
"ApplyY");
146 fApplyZ = (int (*)(
void*, int))
GetFunction(
"ApplyZ");
148 fApplyH = (int (*)(
void*, int))
GetFunction(
"ApplyH");
150 fApplyS = (int (*)(
void*, int))
GetFunction(
"ApplyS");
152 fApplySDG = (int (*)(
void*, int))
GetFunction(
"ApplySDG");
154 fApplyT = (int (*)(
void*, int))
GetFunction(
"ApplyT");
156 fApplyTDG = (int (*)(
void*, int))
GetFunction(
"ApplyTDG");
158 fApplySX = (int (*)(
void*, int))
GetFunction(
"ApplySX");
160 fApplySXDG = (int (*)(
void*, int))
GetFunction(
"ApplySXDG");
162 fApplyK = (int (*)(
void*, int))
GetFunction(
"ApplyK");
164 fApplyP = (int (*)(
void*, int, double))
GetFunction(
"ApplyP");
166 fApplyRx = (int (*)(
void*, int, double))
GetFunction(
"ApplyRx");
168 fApplyRy = (int (*)(
void*, int, double))
GetFunction(
"ApplyRy");
170 fApplyRz = (int (*)(
void*, int, double))
GetFunction(
"ApplyRz");
172 fApplyU = (int (*)(
void*, int, double, double, double,
175 fApplyCX = (int (*)(
void*, int, int))
GetFunction(
"ApplyCX");
177 fApplyCY = (int (*)(
void*, int, int))
GetFunction(
"ApplyCY");
179 fApplyCZ = (int (*)(
void*, int, int))
GetFunction(
"ApplyCZ");
181 fApplyCH = (int (*)(
void*, int, int))
GetFunction(
"ApplyCH");
183 fApplyCSX = (int (*)(
void*, int, int))
GetFunction(
"ApplyCSX");
185 fApplyCSXDG = (int (*)(
void*, int, int))
GetFunction(
"ApplyCSXDG");
187 fApplyCP = (int (*)(
void*, int, int, double))
GetFunction(
"ApplyCP");
189 fApplyCRx = (int (*)(
void*, int, int, double))
GetFunction(
"ApplyCRx");
191 fApplyCRy = (int (*)(
void*, int, int, double))
GetFunction(
"ApplyCRy");
193 fApplyCRz = (int (*)(
void*, int, int, double))
GetFunction(
"ApplyCRz");
195 fApplyCCX = (int (*)(
void*, int, int, int))
GetFunction(
"ApplyCCX");
197 fApplySwap = (int (*)(
void*, int, int))
GetFunction(
"ApplySwap");
200 (int (*)(
void*, int, int, int))
GetFunction(
"ApplyCSwap");
202 fApplyCU = (int (*)(
void*, int, int, double, double, double,
209 std::cerr <<
"MaestroLibrary: Unable to get initialization function "
213 std::cerr <<
"MaestroLibrary: Unable to load the library" << std::endl;
220 std::cerr <<
"MaestroLibrary: Unable to load function, line #: " << line;
223 const char* dlsym_error = dlerror();
224 if (dlsym_error) std::cerr <<
", error: " << dlsym_error;
226 const DWORD error = GetLastError();
227 std::cerr <<
", error code: " << error;
230 std::cerr << std::endl;
234 bool IsValid()
const {
return maestro !=
nullptr; }
237 if (maestro && fCreateSimpleSimulator)
238 return fCreateSimpleSimulator(nrQubits);
240 throw std::runtime_error(
241 "MaestroLibrary: Unable to create the simple simulator.");
247 if (maestro && fDestroySimpleSimulator)
248 fDestroySimpleSimulator(simHandle);
250 throw std::runtime_error(
251 "MaestroLibrary: Unable to destroy the simple simulator.");
255 int simType,
int simExecType) {
256 if (maestro && fRemoveAllOptimizationSimulatorsAndAdd)
257 return fRemoveAllOptimizationSimulatorsAndAdd(simHandle, simType,
260 throw std::runtime_error(
261 "MaestroLibrary: Unable to remove all optimization simulators and "
269 if (maestro && fAddOptimizationSimulator)
270 return fAddOptimizationSimulator(simHandle, simType, simExecType);
272 throw std::runtime_error(
273 "MaestroLibrary: Unable to add an optimization simulator.");
279 const char* jsonConfig) {
280 if (maestro && fSimpleExecute)
281 return fSimpleExecute(simpleSim, jsonCircuit, jsonConfig);
283 throw std::runtime_error(
284 "MaestroLibrary: Unable to execute the simple simulator.");
290 const char* observableStr,
const char* jsonConfig) {
291 if (maestro && fSimpleEstimate)
292 return fSimpleEstimate(simpleSim, jsonCircuit, observableStr, jsonConfig);
294 throw std::runtime_error(
295 "MaestroLibrary: Unable to execute the simple simulator for "
296 "expectation values.");
302 if (maestro && fFreeResult)
305 throw std::runtime_error(
"MaestroLibrary: Unable to free the result.");
309 if (maestro && fCreateSimulator)
310 return fCreateSimulator(simType, simExecType);
312 throw std::runtime_error(
313 "MaestroLibrary: Unable to create the simulator.");
319 if (maestro && fGetSimulator)
320 return fGetSimulator(simHandle);
322 throw std::runtime_error(
"MaestroLibrary: Unable to get the simulator.");
326 if (maestro && fDestroySimulator)
327 fDestroySimulator(simHandle);
329 throw std::runtime_error(
330 "MaestroLibrary: Unable to destroy the simulator.");
334 if (maestro && sim && fInitializeSimulator)
335 return fInitializeSimulator(sim);
337 throw std::runtime_error(
338 "MaestroLibrary: Unable to initialize the simulator.");
344 if (maestro && sim && fResetSimulator)
345 return fResetSimulator(sim);
347 throw std::runtime_error(
348 "MaestroLibrary: Unable to reset the simulator.");
354 if (maestro && sim && fConfigureSimulator)
355 return fConfigureSimulator(sim, key, value);
357 throw std::runtime_error(
358 "MaestroLibrary: Unable to configure the simulator.");
364 if (maestro && sim && fGetConfiguration)
365 return fGetConfiguration(sim, key);
367 throw std::runtime_error(
368 "MaestroLibrary: Unable to get the configuration of the simulator.");
373 if (maestro && sim && fAllocateQubits)
374 return fAllocateQubits(sim, nrQubits);
376 throw std::runtime_error(
377 "MaestroLibrary: Unable to allocate qubits in the simulator.");
382 if (maestro && sim && fGetNumberOfQubits)
383 return fGetNumberOfQubits(sim);
385 throw std::runtime_error(
386 "MaestroLibrary: Unable to get the number of qubits in the "
392 if (maestro && sim && fClearSimulator)
393 return fClearSimulator(sim);
395 throw std::runtime_error(
396 "MaestroLibrary: Unable to clear the simulator.");
400 unsigned long long int Measure(
void* sim,
const unsigned long int* qubits,
401 unsigned long int nrQubits) {
402 if (maestro && sim && fMeasure)
403 return fMeasure(sim, qubits, nrQubits);
405 throw std::runtime_error(
406 "MaestroLibrary: Unable to measure the simulator.");
411 unsigned long int nrQubits) {
412 if (maestro && sim && fApplyReset)
413 return fApplyReset(sim, qubits, nrQubits);
415 throw std::runtime_error(
416 "MaestroLibrary: Unable to apply reset to the simulator.");
421 if (maestro && sim && fProbability)
422 return fProbability(sim, outcome);
424 throw std::runtime_error(
425 "MaestroLibrary: Unable to get the probability of an outcome.");
430 if (maestro && fFreeDoubleVector)
431 fFreeDoubleVector(vec);
433 throw std::runtime_error(
434 "MaestroLibrary: Unable to free the double vector.");
438 if (maestro && fFreeULLIVector)
439 fFreeULLIVector(vec);
441 throw std::runtime_error(
442 "MaestroLibrary: Unable to free the unsigned long long int vector.");
445 double*
Amplitude(
void* sim,
unsigned long long int outcome) {
446 if (maestro && sim && fAmplitude)
447 return fAmplitude(sim, outcome);
449 throw std::runtime_error(
450 "MaestroLibrary: Unable to get the amplitude of an outcome.");
455 if (maestro && sim && fAllProbabilities)
456 return fAllProbabilities(sim);
458 throw std::runtime_error(
459 "MaestroLibrary: Unable to get all probabilities.");
464 unsigned long int nrQubits) {
465 if (maestro && sim && fProbabilities)
466 return fProbabilities(sim, qubits, nrQubits);
468 throw std::runtime_error(
469 "MaestroLibrary: Unable to get probabilities for specified qubits.");
474 const unsigned long long int* qubits,
475 unsigned long int nrQubits,
476 unsigned long int shots) {
477 if (maestro && sim && fSampleCounts)
478 return fSampleCounts(sim, qubits, nrQubits, shots);
480 throw std::runtime_error(
481 "MaestroLibrary: Unable to get sample counts for specified qubits.");
486 if (maestro && sim && fGetSimulatorType)
487 return fGetSimulatorType(sim);
489 throw std::runtime_error(
490 "MaestroLibrary: Unable to get the simulator type.");
495 if (maestro && sim && fGetSimulationType)
496 return fGetSimulationType(sim);
498 throw std::runtime_error(
499 "MaestroLibrary: Unable to get the simulation type.");
504 if (maestro && sim && fFlushSimulator)
505 return fFlushSimulator(sim);
507 throw std::runtime_error(
508 "MaestroLibrary: Unable to flush the simulator.");
513 if (maestro && sim && fSaveStateToInternalDestructive)
514 return fSaveStateToInternalDestructive(sim);
516 throw std::runtime_error(
517 "MaestroLibrary: Unable to save the state to internal destructive "
523 if (maestro && sim && fRestoreInternalDestructiveSavedState)
524 return fRestoreInternalDestructiveSavedState(sim);
526 throw std::runtime_error(
527 "MaestroLibrary: Unable to restore the state from internal "
528 "destructive storage.");
533 if (maestro && sim && fSaveState)
534 return fSaveState(sim);
536 throw std::runtime_error(
"MaestroLibrary: Unable to save the state.");
541 if (maestro && sim && fRestoreState)
542 return fRestoreState(sim);
544 throw std::runtime_error(
"MaestroLibrary: Unable to restore the state.");
549 if (maestro && sim && fSetMultithreading)
550 return fSetMultithreading(sim, multithreading);
552 throw std::runtime_error(
"MaestroLibrary: Unable to set multithreading.");
557 if (maestro && sim && fGetMultithreading)
558 return fGetMultithreading(sim);
560 throw std::runtime_error(
561 "MaestroLibrary: Unable to get multithreading status.");
566 if (maestro && sim && fIsQcsim)
567 return fIsQcsim(sim);
569 throw std::runtime_error(
570 "MaestroLibrary: Unable to check if the simulator is a QCSIM.");
575 if (maestro && sim && fMeasureNoCollapse)
576 return fMeasureNoCollapse(sim);
578 throw std::runtime_error(
579 "MaestroLibrary: Unable to measure without collapse.");
584 if (maestro && sim && fApplyX)
585 return fApplyX(sim, qubit);
587 throw std::runtime_error(
"MaestroLibrary: Unable to apply X gate.");
592 if (maestro && sim && fApplyY)
593 return fApplyY(sim, qubit);
595 throw std::runtime_error(
"MaestroLibrary: Unable to apply Y gate.");
600 if (maestro && sim && fApplyZ)
601 return fApplyZ(sim, qubit);
603 throw std::runtime_error(
"MaestroLibrary: Unable to apply Z gate.");
608 if (maestro && sim && fApplyH)
609 return fApplyH(sim, qubit);
611 throw std::runtime_error(
"MaestroLibrary: Unable to apply H gate.");
616 if (maestro && sim && fApplyS)
617 return fApplyS(sim, qubit);
619 throw std::runtime_error(
"MaestroLibrary: Unable to apply S gate.");
624 if (maestro && sim && fApplySDG)
625 return fApplySDG(sim, qubit);
627 throw std::runtime_error(
"MaestroLibrary: Unable to apply SDG gate.");
632 if (maestro && sim && fApplyT)
633 return fApplyT(sim, qubit);
635 throw std::runtime_error(
"MaestroLibrary: Unable to apply T gate.");
640 if (maestro && sim && fApplyTDG)
641 return fApplyTDG(sim, qubit);
643 throw std::runtime_error(
"MaestroLibrary: Unable to apply TDG gate.");
648 if (maestro && sim && fApplySX)
649 return fApplySX(sim, qubit);
651 throw std::runtime_error(
"MaestroLibrary: Unable to apply SX gate.");
656 if (maestro && sim && fApplySXDG)
657 return fApplySXDG(sim, qubit);
659 throw std::runtime_error(
"MaestroLibrary: Unable to apply SXDG gate.");
664 if (maestro && sim && fApplyK)
665 return fApplyK(sim, qubit);
667 throw std::runtime_error(
"MaestroLibrary: Unable to apply K gate.");
671 int ApplyP(
void* sim,
int qubit,
double theta) {
672 if (maestro && sim && fApplyP)
673 return fApplyP(sim, qubit, theta);
675 throw std::runtime_error(
"MaestroLibrary: Unable to apply P gate.");
679 int ApplyRx(
void* sim,
int qubit,
double theta) {
680 if (maestro && sim && fApplyRx)
681 return fApplyRx(sim, qubit, theta);
683 throw std::runtime_error(
"MaestroLibrary: Unable to apply Rx gate.");
687 int ApplyRy(
void* sim,
int qubit,
double theta) {
688 if (maestro && sim && fApplyRy)
689 return fApplyRy(sim, qubit, theta);
691 throw std::runtime_error(
"MaestroLibrary: Unable to apply Ry gate.");
695 int ApplyRz(
void* sim,
int qubit,
double theta) {
696 if (maestro && sim && fApplyRz)
697 return fApplyRz(sim, qubit, theta);
699 throw std::runtime_error(
"MaestroLibrary: Unable to apply Rz gate.");
703 int ApplyU(
void* sim,
int qubit,
double theta,
double phi,
double lambda,
705 if (maestro && sim && fApplyU)
706 return fApplyU(sim, qubit, theta, phi, lambda, gamma);
708 throw std::runtime_error(
"MaestroLibrary: Unable to apply U gate.");
712 int ApplyCX(
void* sim,
int controlQubit,
int targetQubit) {
713 if (maestro && sim && fApplyCX)
714 return fApplyCX(sim, controlQubit, targetQubit);
716 throw std::runtime_error(
"MaestroLibrary: Unable to apply CX gate.");
720 int ApplyCY(
void* sim,
int controlQubit,
int targetQubit) {
721 if (maestro && sim && fApplyCY)
722 return fApplyCY(sim, controlQubit, targetQubit);
724 throw std::runtime_error(
"MaestroLibrary: Unable to apply CY gate.");
728 int ApplyCZ(
void* sim,
int controlQubit,
int targetQubit) {
729 if (maestro && sim && fApplyCZ)
730 return fApplyCZ(sim, controlQubit, targetQubit);
732 throw std::runtime_error(
"MaestroLibrary: Unable to apply CZ gate.");
736 int ApplyCH(
void* sim,
int controlQubit,
int targetQubit) {
737 if (maestro && sim && fApplyCH)
738 return fApplyCH(sim, controlQubit, targetQubit);
740 throw std::runtime_error(
"MaestroLibrary: Unable to apply CH gate.");
744 int ApplyCSX(
void* sim,
int controlQubit,
int targetQubit) {
745 if (maestro && sim && fApplyCSX)
746 return fApplyCSX(sim, controlQubit, targetQubit);
748 throw std::runtime_error(
"MaestroLibrary: Unable to apply CSX gate.");
752 int ApplyCSXDG(
void* sim,
int controlQubit,
int targetQubit) {
753 if (maestro && sim && fApplyCSXDG)
754 return fApplyCSXDG(sim, controlQubit, targetQubit);
756 throw std::runtime_error(
"MaestroLibrary: Unable to apply CSXDG gate.");
760 int ApplyCP(
void* sim,
int controlQubit,
int targetQubit,
double theta) {
761 if (maestro && sim && fApplyCP)
762 return fApplyCP(sim, controlQubit, targetQubit, theta);
764 throw std::runtime_error(
"MaestroLibrary: Unable to apply CP gate.");
768 int ApplyCRx(
void* sim,
int controlQubit,
int targetQubit,
double theta) {
769 if (maestro && sim && fApplyCRx)
770 return fApplyCRx(sim, controlQubit, targetQubit, theta);
772 throw std::runtime_error(
"MaestroLibrary: Unable to apply CRx gate.");
776 int ApplyCRy(
void* sim,
int controlQubit,
int targetQubit,
double theta) {
777 if (maestro && sim && fApplyCRy)
778 return fApplyCRy(sim, controlQubit, targetQubit, theta);
780 throw std::runtime_error(
"MaestroLibrary: Unable to apply CRy gate.");
784 int ApplyCRz(
void* sim,
int controlQubit,
int targetQubit,
double theta) {
785 if (maestro && sim && fApplyCRz)
786 return fApplyCRz(sim, controlQubit, targetQubit, theta);
788 throw std::runtime_error(
"MaestroLibrary: Unable to apply CRz gate.");
792 int ApplyCCX(
void* sim,
int controlQubit1,
int controlQubit2,
794 if (maestro && sim && fApplyCCX)
795 return fApplyCCX(sim, controlQubit1, controlQubit2, targetQubit);
797 throw std::runtime_error(
"MaestroLibrary: Unable to apply CCX gate.");
802 if (maestro && sim && fApplySwap)
803 return fApplySwap(sim, qubit1, qubit2);
805 throw std::runtime_error(
"MaestroLibrary: Unable to apply Swap gate.");
809 int ApplyCSwap(
void* sim,
int controlQubit,
int qubit1,
int qubit2) {
810 if (maestro && sim && fApplyCSwap)
811 return fApplyCSwap(sim, controlQubit, qubit1, qubit2);
813 throw std::runtime_error(
"MaestroLibrary: Unable to apply CSwap gate.");
817 int ApplyCU(
void* sim,
int controlQubit,
int targetQubit,
double theta,
818 double phi,
double lambda,
double gamma) {
819 if (maestro && sim && fApplyCU)
820 return fApplyCU(sim, controlQubit, targetQubit, theta, phi, lambda,
823 throw std::runtime_error(
"MaestroLibrary: Unable to apply CU gate.");
828 void* maestro =
nullptr;
830 void* (*fGetMaestroObject)();
832 unsigned long int (*fCreateSimpleSimulator)(int);
833 void (*fDestroySimpleSimulator)(
unsigned long int);
835 int (*fRemoveAllOptimizationSimulatorsAndAdd)(
unsigned long int, int, int);
836 int (*fAddOptimizationSimulator)(
unsigned long int, int, int);
838 char* (*fSimpleExecute)(
unsigned long int,
const char*,
const char*);
839 char* (*fSimpleEstimate)(
unsigned long int,
const char*,
const char*,
841 void (*fFreeResult)(
char*);
843 unsigned long int (*fCreateSimulator)(int, int);
844 void* (*fGetSimulator)(
unsigned long int);
845 void (*fDestroySimulator)(
unsigned long int);
847 int (*fInitializeSimulator)(
void*);
848 int (*fResetSimulator)(
void*);
849 int (*fConfigureSimulator)(
void*,
const char*,
const char*);
850 char* (*fGetConfiguration)(
void*,
const char*);
851 unsigned long int (*fAllocateQubits)(
void*,
unsigned long int);
852 unsigned long int (*fGetNumberOfQubits)(
void*);
853 int (*fClearSimulator)(
void*);
854 unsigned long long int (*fMeasure)(
void*,
const unsigned long int*,
856 int (*fApplyReset)(
void*,
const unsigned long int*,
unsigned long int);
857 double (*fProbability)(
void*,
unsigned long long int);
858 void (*fFreeDoubleVector)(
double*);
859 void (*fFreeULLIVector)(
unsigned long long int*);
860 double* (*fAmplitude)(
void*,
unsigned long long int);
861 double* (*fAllProbabilities)(
void*);
862 double* (*fProbabilities)(
void*,
const unsigned long long int*,
864 unsigned long long int* (*fSampleCounts)(
void*,
const unsigned long long int*,
867 int (*fGetSimulatorType)(
void*);
868 int (*fGetSimulationType)(
void*);
869 int (*fFlushSimulator)(
void*);
870 int (*fSaveStateToInternalDestructive)(
void*);
871 int (*fRestoreInternalDestructiveSavedState)(
void*);
872 int (*fSaveState)(
void*);
873 int (*fRestoreState)(
void*);
874 int (*fSetMultithreading)(
void*, int);
875 int (*fGetMultithreading)(
void*);
876 int (*fIsQcsim)(
void*);
877 unsigned long long int (*fMeasureNoCollapse)(
void*);
879 int (*fApplyX)(
void*, int);
880 int (*fApplyY)(
void*, int);
881 int (*fApplyZ)(
void*, int);
882 int (*fApplyH)(
void*, int);
883 int (*fApplyS)(
void*, int);
884 int (*fApplySDG)(
void*, int);
885 int (*fApplyT)(
void*, int);
886 int (*fApplyTDG)(
void*, int);
887 int (*fApplySX)(
void*, int);
888 int (*fApplySXDG)(
void*, int);
889 int (*fApplyK)(
void*, int);
890 int (*fApplyP)(
void*, int, double);
891 int (*fApplyRx)(
void*, int, double);
892 int (*fApplyRy)(
void*, int, double);
893 int (*fApplyRz)(
void*, int, double);
894 int (*fApplyU)(
void*, int, double, double, double, double);
895 int (*fApplyCX)(
void*, int, int);
896 int (*fApplyCY)(
void*, int, int);
897 int (*fApplyCZ)(
void*, int, int);
898 int (*fApplyCH)(
void*, int, int);
899 int (*fApplyCSX)(
void*, int, int);
900 int (*fApplyCSXDG)(
void*, int, int);
901 int (*fApplyCP)(
void*, int, int, double);
902 int (*fApplyCRx)(
void*, int, int, double);
903 int (*fApplyCRy)(
void*, int, int, double);
904 int (*fApplyCRz)(
void*, int, int, double);
905 int (*fApplyCCX)(
void*, int, int, int);
906 int (*fApplySwap)(
void*, int, int);
907 int (*fApplyCSwap)(
void*, int, int, int);
908 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