22#include <unordered_map>
30 GpuLibrary(
const GpuLibrary &) =
delete;
31 GpuLibrary &operator=(
const GpuLibrary &) =
delete;
33 GpuLibrary(GpuLibrary &&) =
default;
34 GpuLibrary &operator=(GpuLibrary &&) =
default;
36 GpuLibrary()
noexcept {}
38 virtual ~GpuLibrary() {
43 bool Init(
const char *libName)
noexcept override {
45 InitLib = (
void *(*)())GetFunction(
"InitLib");
46 CheckFunction((
void *)InitLib, __LINE__);
48 LibraryHandle = InitLib();
50 FreeLib = (void (*)())GetFunction(
"FreeLib");
51 CheckFunction((
void *)FreeLib, __LINE__);
56 (
void *(*)(
void *))GetFunction(
"CreateStateVector");
57 CheckFunction((
void *)fCreateStateVector, __LINE__);
59 (void (*)(
void *))GetFunction(
"DestroyStateVector");
60 CheckFunction((
void *)fDestroyStateVector, __LINE__);
62 fCreate = (int (*)(
void *,
unsigned int))GetFunction(
"Create");
63 CheckFunction((
void *)fCreate, __LINE__);
65 (int (*)(
void *,
unsigned int,
const double *))GetFunction(
67 CheckFunction((
void *)fCreateWithState, __LINE__);
68 fReset = (int (*)(
void *))GetFunction(
"Reset");
69 CheckFunction((
void *)fReset, __LINE__);
71 fSetDataType = (int (*)(
void *, int))GetFunction(
"SetDataType");
72 CheckFunction((
void *)fSetDataType, __LINE__);
74 (int (*)(
void *))GetFunction(
"IsDoublePrecision");
75 CheckFunction((
void *)fIsDoublePrecision, __LINE__);
77 fMeasureQubitCollapse =
78 (int (*)(
void *, int))GetFunction(
"MeasureQubitCollapse");
79 CheckFunction((
void *)fMeasureQubitCollapse, __LINE__);
80 fMeasureQubitNoCollapse =
81 (int (*)(
void *, int))GetFunction(
"MeasureQubitNoCollapse");
82 CheckFunction((
void *)fMeasureQubitNoCollapse, __LINE__);
83 fMeasureQubitsCollapse = (int (*)(
84 void *,
int *,
int *, int))GetFunction(
"MeasureQubitsCollapse");
85 CheckFunction((
void *)fMeasureQubitsCollapse, __LINE__);
86 fMeasureQubitsNoCollapse = (int (*)(
87 void *,
int *,
int *, int))GetFunction(
"MeasureQubitsNoCollapse");
88 CheckFunction((
void *)fMeasureQubitsNoCollapse, __LINE__);
89 fMeasureAllQubitsCollapse = (
unsigned long long (*)(
90 void *))GetFunction(
"MeasureAllQubitsCollapse");
91 CheckFunction((
void *)fMeasureAllQubitsCollapse, __LINE__);
92 fMeasureAllQubitsNoCollapse = (
unsigned long long (*)(
93 void *))GetFunction(
"MeasureAllQubitsNoCollapse");
94 CheckFunction((
void *)fMeasureAllQubitsNoCollapse, __LINE__);
96 fSaveState = (int (*)(
void *))GetFunction(
"SaveState");
97 CheckFunction((
void *)fSaveState, __LINE__);
98 fSaveStateToHost = (int (*)(
void *))GetFunction(
"SaveStateToHost");
99 CheckFunction((
void *)fSaveStateToHost, __LINE__);
100 fSaveStateDestructive =
101 (int (*)(
void *))GetFunction(
"SaveStateDestructive");
102 CheckFunction((
void *)fSaveStateDestructive, __LINE__);
103 fRestoreStateFreeSaved =
104 (int (*)(
void *))GetFunction(
"RestoreStateFreeSaved");
105 CheckFunction((
void *)fRestoreStateFreeSaved, __LINE__);
106 fRestoreStateNoFreeSaved =
107 (int (*)(
void *))GetFunction(
"RestoreStateNoFreeSaved");
108 CheckFunction((
void *)fRestoreStateNoFreeSaved, __LINE__);
109 fFreeSavedState = (void (*)(
void *))GetFunction(
"FreeSavedState");
110 CheckFunction((
void *)fFreeSavedState, __LINE__);
111 fClone = (
void *(*)(
void *))GetFunction(
"Clone");
112 CheckFunction((
void *)fClone, __LINE__);
114 fSample = (int (*)(
void *,
unsigned int,
long int *,
unsigned int,
115 int *))GetFunction(
"Sample");
116 CheckFunction((
void *)fSample, __LINE__);
117 fSampleAll = (int (*)(
void *,
unsigned int,
long int *))GetFunction(
119 CheckFunction((
void *)fSampleAll, __LINE__);
120 fAmplitude = (int (*)(
void *,
long long int,
double *,
121 double *))GetFunction(
"Amplitude");
122 CheckFunction((
void *)fAmplitude, __LINE__);
124 (double (*)(
void *,
int *,
int *, int))GetFunction(
"Probability");
125 CheckFunction((
void *)fProbability, __LINE__);
126 fBasisStateProbability = (double (*)(
127 void *,
long long int))GetFunction(
"BasisStateProbability");
128 CheckFunction((
void *)fBasisStateProbability, __LINE__);
129 fAllProbabilities = (int (*)(
130 void *obj,
double *probabilities))GetFunction(
"AllProbabilities");
131 CheckFunction((
void *)fAllProbabilities, __LINE__);
132 fExpectationValue = (double (*)(
void *,
const char *,
133 int))GetFunction(
"ExpectationValue");
134 CheckFunction((
void *)fExpectationValue, __LINE__);
136 fApplyX = (int (*)(
void *, int))GetFunction(
"ApplyX");
137 CheckFunction((
void *)fApplyX, __LINE__);
138 fApplyY = (int (*)(
void *, int))GetFunction(
"ApplyY");
139 CheckFunction((
void *)fApplyY, __LINE__);
140 fApplyZ = (int (*)(
void *, int))GetFunction(
"ApplyZ");
141 CheckFunction((
void *)fApplyZ, __LINE__);
142 fApplyH = (int (*)(
void *, int))GetFunction(
"ApplyH");
143 CheckFunction((
void *)fApplyH, __LINE__);
144 fApplyS = (int (*)(
void *, int))GetFunction(
"ApplyS");
145 CheckFunction((
void *)fApplyS, __LINE__);
146 fApplySDG = (int (*)(
void *, int))GetFunction(
"ApplySDG");
147 CheckFunction((
void *)fApplySDG, __LINE__);
148 fApplyT = (int (*)(
void *, int))GetFunction(
"ApplyT");
149 CheckFunction((
void *)fApplyT, __LINE__);
150 fApplyTDG = (int (*)(
void *, int))GetFunction(
"ApplyTDG");
151 CheckFunction((
void *)fApplyTDG, __LINE__);
152 fApplySX = (int (*)(
void *, int))GetFunction(
"ApplySX");
153 CheckFunction((
void *)fApplySX, __LINE__);
154 fApplySXDG = (int (*)(
void *, int))GetFunction(
"ApplySXDG");
155 CheckFunction((
void *)fApplySXDG, __LINE__);
156 fApplyK = (int (*)(
void *, int))GetFunction(
"ApplyK");
157 CheckFunction((
void *)fApplyK, __LINE__);
158 fApplyP = (int (*)(
void *, int, double))GetFunction(
"ApplyP");
159 CheckFunction((
void *)fApplyP, __LINE__);
160 fApplyRx = (int (*)(
void *, int, double))GetFunction(
"ApplyRx");
161 CheckFunction((
void *)fApplyRx, __LINE__);
162 fApplyRy = (int (*)(
void *, int, double))GetFunction(
"ApplyRy");
163 CheckFunction((
void *)fApplyRy, __LINE__);
164 fApplyRz = (int (*)(
void *, int, double))GetFunction(
"ApplyRz");
165 CheckFunction((
void *)fApplyRz, __LINE__);
166 fApplyU = (int (*)(
void *, int, double, double, double,
167 double))GetFunction(
"ApplyU");
168 CheckFunction((
void *)fApplyU, __LINE__);
169 fApplyCX = (int (*)(
void *, int, int))GetFunction(
"ApplyCX");
170 CheckFunction((
void *)fApplyCX, __LINE__);
171 fApplyCY = (int (*)(
void *, int, int))GetFunction(
"ApplyCY");
172 CheckFunction((
void *)fApplyCY, __LINE__);
173 fApplyCZ = (int (*)(
void *, int, int))GetFunction(
"ApplyCZ");
174 CheckFunction((
void *)fApplyCZ, __LINE__);
175 fApplyCH = (int (*)(
void *, int, int))GetFunction(
"ApplyCH");
176 CheckFunction((
void *)fApplyCH, __LINE__);
177 fApplyCSX = (int (*)(
void *, int, int))GetFunction(
"ApplyCSX");
178 CheckFunction((
void *)fApplyCSX, __LINE__);
179 fApplyCSXDG = (int (*)(
void *, int, int))GetFunction(
"ApplyCSXDG");
180 CheckFunction((
void *)fApplyCSXDG, __LINE__);
181 fApplyCP = (int (*)(
void *, int, int, double))GetFunction(
"ApplyCP");
182 CheckFunction((
void *)fApplyCP, __LINE__);
184 (int (*)(
void *, int, int, double))GetFunction(
"ApplyCRx");
185 CheckFunction((
void *)fApplyCRx, __LINE__);
187 (int (*)(
void *, int, int, double))GetFunction(
"ApplyCRy");
188 CheckFunction((
void *)fApplyCRy, __LINE__);
190 (int (*)(
void *, int, int, double))GetFunction(
"ApplyCRz");
191 CheckFunction((
void *)fApplyCRz, __LINE__);
192 fApplyCCX = (int (*)(
void *, int, int, int))GetFunction(
"ApplyCCX");
193 CheckFunction((
void *)fApplyCCX, __LINE__);
194 fApplySwap = (int (*)(
void *, int, int))GetFunction(
"ApplySwap");
195 CheckFunction((
void *)fApplySwap, __LINE__);
197 (int (*)(
void *, int, int, int))GetFunction(
"ApplyCSwap");
198 CheckFunction((
void *)fApplyCSwap, __LINE__);
199 fApplyCU = (int (*)(
void *, int, int, double, double, double,
200 double))GetFunction(
"ApplyCU");
201 CheckFunction((
void *)fApplyCU, __LINE__);
205 fCreateMPS = (
void *(*)(
void *))GetFunction(
"CreateMPS");
206 CheckFunction((
void *)fCreateMPS, __LINE__);
207 fDestroyMPS = (void (*)(
void *))GetFunction(
"DestroyMPS");
208 CheckFunction((
void *)fDestroyMPS, __LINE__);
210 fMPSCreate = (int (*)(
void *,
unsigned int))GetFunction(
"MPSCreate");
211 CheckFunction((
void *)fMPSCreate, __LINE__);
212 fMPSReset = (int (*)(
void *))GetFunction(
"MPSReset");
213 CheckFunction((
void *)fMPSReset, __LINE__);
215 fMPSIsValid = (int (*)(
void *))GetFunction(
"MPSIsValid");
216 CheckFunction((
void *)fMPSIsValid, __LINE__);
217 fMPSIsCreated = (int (*)(
void *))GetFunction(
"MPSIsCreated");
218 CheckFunction((
void *)fMPSIsCreated, __LINE__);
220 fMPSSetDataType = (int (*)(
void *, int))GetFunction(
"MPSSetDataType");
221 CheckFunction((
void *)fMPSSetDataType, __LINE__);
222 fMPSIsDoublePrecision =
223 (int (*)(
void *))GetFunction(
"MPSIsDoublePrecision");
224 CheckFunction((
void *)fMPSIsDoublePrecision, __LINE__);
225 fMPSSetCutoff = (int (*)(
void *, double))GetFunction(
"MPSSetCutoff");
226 CheckFunction((
void *)fMPSSetCutoff, __LINE__);
227 fMPSGetCutoff = (double (*)(
void *))GetFunction(
"MPSGetCutoff");
228 CheckFunction((
void *)fMPSGetCutoff, __LINE__);
229 fMPSSetGesvdJ = (int (*)(
void *, int))GetFunction(
"MPSSetGesvdJ");
230 CheckFunction((
void *)fMPSSetGesvdJ, __LINE__);
231 fMPSGetGesvdJ = (int (*)(
void *))GetFunction(
"MPSGetGesvdJ");
232 CheckFunction((
void *)fMPSGetGesvdJ, __LINE__);
234 (int (*)(
void *,
long int))GetFunction(
"MPSSetMaxExtent");
235 CheckFunction((
void *)fMPSSetMaxExtent, __LINE__);
237 (
long int (*)(
void *))GetFunction(
"MPSGetMaxExtent");
238 CheckFunction((
void *)fMPSGetMaxExtent, __LINE__);
239 fMPSGetNrQubits = (int (*)(
void *))GetFunction(
"MPSGetNrQubits");
240 CheckFunction((
void *)fMPSGetNrQubits, __LINE__);
241 fMPSAmplitude = (int (*)(
void *,
long int,
long int *,
double *,
242 double *))GetFunction(
"MPSAmplitude");
243 CheckFunction((
void *)fMPSAmplitude, __LINE__);
245 (double (*)(
void *,
unsigned int))GetFunction(
"MPSProbability0");
246 CheckFunction((
void *)fMPSProbability0, __LINE__);
248 (int (*)(
void *,
unsigned int))GetFunction(
"MPSMeasure");
249 CheckFunction((
void *)fMPSMeasure, __LINE__);
250 fMPSMeasureQubits = (int (*)(
void *,
long int,
unsigned int *,
251 int *))GetFunction(
"MPSMeasureQubits");
252 CheckFunction((
void *)fMPSMeasureQubits, __LINE__);
254 fMPSGetMapForSample = (
void *(*)())GetFunction(
"MPSGetMapForSample");
255 CheckFunction((
void *)fMPSGetMapForSample, __LINE__);
256 fMPSFreeMapForSample =
257 (int (*)(
void *))GetFunction(
"MPSFreeMapForSample");
258 CheckFunction((
void *)fMPSFreeMapForSample, __LINE__);
259 fMPSSample = (int (*)(
void *,
long int,
long int,
unsigned int *,
260 void *))GetFunction(
"MPSSample");
261 CheckFunction((
void *)fMPSSample, __LINE__);
263 fMPSSaveState = (int (*)(
void *))GetFunction(
"MPSSaveState");
264 CheckFunction((
void *)fMPSSaveState, __LINE__);
265 fMPSRestoreState = (int (*)(
void *))GetFunction(
"MPSRestoreState");
266 CheckFunction((
void *)fMPSRestoreState, __LINE__);
267 fMPSCleanSavedState =
268 (int (*)(
void *))GetFunction(
"MPSCleanSavedState");
269 CheckFunction((
void *)fMPSCleanSavedState, __LINE__);
270 fMPSClone = (
void *(*)(
void *))GetFunction(
"MPSClone");
271 CheckFunction((
void *)fMPSClone, __LINE__);
273 fMPSExpectationValue = (double (*)(
274 void *,
const char *, int))GetFunction(
"MPSExpectationValue");
275 CheckFunction((
void *)fMPSExpectationValue, __LINE__);
277 fMPSApplyX = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyX");
278 CheckFunction((
void *)fMPSApplyX, __LINE__);
279 fMPSApplyY = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyY");
280 CheckFunction((
void *)fMPSApplyY, __LINE__);
281 fMPSApplyZ = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyZ");
282 CheckFunction((
void *)fMPSApplyZ, __LINE__);
283 fMPSApplyH = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyH");
284 CheckFunction((
void *)fMPSApplyH, __LINE__);
285 fMPSApplyS = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyS");
286 CheckFunction((
void *)fMPSApplyS, __LINE__);
288 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySDG");
289 CheckFunction((
void *)fMPSApplySDG, __LINE__);
290 fMPSApplyT = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyT");
291 CheckFunction((
void *)fMPSApplyT, __LINE__);
293 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyTDG");
294 CheckFunction((
void *)fMPSApplyTDG, __LINE__);
296 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySX");
297 CheckFunction((
void *)fMPSApplySX, __LINE__);
299 (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplySXDG");
300 CheckFunction((
void *)fMPSApplySXDG, __LINE__);
301 fMPSApplyK = (int (*)(
void *,
unsigned int))GetFunction(
"MPSApplyK");
302 CheckFunction((
void *)fMPSApplyK, __LINE__);
304 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyP");
305 CheckFunction((
void *)fMPSApplyP, __LINE__);
307 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRx");
308 CheckFunction((
void *)fMPSApplyRx, __LINE__);
310 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRy");
311 CheckFunction((
void *)fMPSApplyRy, __LINE__);
313 (int (*)(
void *,
unsigned int, double))GetFunction(
"MPSApplyRz");
314 CheckFunction((
void *)fMPSApplyRz, __LINE__);
315 fMPSApplyU = (int (*)(
void *,
unsigned int, double, double, double,
316 double))GetFunction(
"MPSApplyU");
317 CheckFunction((
void *)fMPSApplyU, __LINE__);
318 fMPSApplySwap = (int (*)(
void *,
unsigned int,
319 unsigned int))GetFunction(
"MPSApplySwap");
320 CheckFunction((
void *)fMPSApplySwap, __LINE__);
321 fMPSApplyCX = (int (*)(
void *,
unsigned int,
322 unsigned int))GetFunction(
"MPSApplyCX");
323 CheckFunction((
void *)fMPSApplyCX, __LINE__);
324 fMPSApplyCY = (int (*)(
void *,
unsigned int,
325 unsigned int))GetFunction(
"MPSApplyCY");
326 CheckFunction((
void *)fMPSApplyCY, __LINE__);
327 fMPSApplyCZ = (int (*)(
void *,
unsigned int,
328 unsigned int))GetFunction(
"MPSApplyCZ");
329 CheckFunction((
void *)fMPSApplyCZ, __LINE__);
330 fMPSApplyCH = (int (*)(
void *,
unsigned int,
331 unsigned int))GetFunction(
"MPSApplyCH");
332 CheckFunction((
void *)fMPSApplyCH, __LINE__);
333 fMPSApplyCSX = (int (*)(
void *,
unsigned int,
334 unsigned int))GetFunction(
"MPSApplyCSX");
335 CheckFunction((
void *)fMPSApplyCSX, __LINE__);
336 fMPSApplyCSXDG = (int (*)(
void *,
unsigned int,
337 unsigned int))GetFunction(
"MPSApplyCSXDG");
338 CheckFunction((
void *)fMPSApplyCSXDG, __LINE__);
339 fMPSApplyCP = (int (*)(
void *,
unsigned int,
unsigned int,
340 double))GetFunction(
"MPSApplyCP");
341 CheckFunction((
void *)fMPSApplyCP, __LINE__);
342 fMPSApplyCRx = (int (*)(
void *,
unsigned int,
unsigned int,
343 double))GetFunction(
"MPSApplyCRx");
344 CheckFunction((
void *)fMPSApplyCRx, __LINE__);
345 fMPSApplyCRy = (int (*)(
void *,
unsigned int,
unsigned int,
346 double))GetFunction(
"MPSApplyCRy");
347 CheckFunction((
void *)fMPSApplyCRy, __LINE__);
348 fMPSApplyCRz = (int (*)(
void *,
unsigned int,
unsigned int,
349 double))GetFunction(
"MPSApplyCRz");
350 CheckFunction((
void *)fMPSApplyCRz, __LINE__);
352 (int (*)(
void *,
unsigned int,
unsigned int, double, double,
353 double, double))GetFunction(
"MPSApplyCU");
354 CheckFunction((
void *)fMPSApplyCU, __LINE__);
358 std::cout <<
"GpuLibrary: Unable to initialize gpu library"
361 std::cout <<
"GpuLibrary: Unable to get initialization function for "
365 std::cout <<
"GpuLibrary: Unable to load gpu library" << std::endl;
370 static void CheckFunction(
void *func,
int line) {
372 std::cout <<
"GpuLibrary: Unable to load function, line #: "
373 << std::to_string(line);
374 const char *dlsym_error = dlerror();
376 std::cout <<
", error: " << dlsym_error;
378 std::cout << std::endl;
382 bool IsValid()
const {
return LibraryHandle !=
nullptr; }
386 void *CreateStateVector() {
388 return fCreateStateVector(LibraryHandle);
390 throw std::runtime_error(
"GpuLibrary: Unable to create state vector");
393 void DestroyStateVector(
void *obj) {
395 fDestroyStateVector(obj);
397 throw std::runtime_error(
"GpuLibrary: Unable to destroy state vector");
400 bool Create(
void *obj,
unsigned int nrQubits) {
402 return fCreate(obj, nrQubits) == 1;
404 throw std::runtime_error(
405 "GpuLibrary: Unable to create state vector state");
410 bool CreateWithState(
void *obj,
unsigned int nrQubits,
const double *state) {
412 return fCreateWithState(obj, nrQubits, state) == 1;
414 throw std::runtime_error(
415 "GpuLibrary: Unable to create state vector state with a state");
420 bool Reset(
void *obj) {
422 return fReset(obj) == 1;
424 throw std::runtime_error(
"GpuLibrary: Unable to reset state vector");
429 bool SetDataType(
void *obj,
int dataType) {
431 return fSetDataType(obj, dataType) == 1;
433 throw std::runtime_error(
"GpuLibrary: Unable to set data type");
438 bool IsDoublePrecision(
void *obj)
const {
440 return fIsDoublePrecision(obj) == 1;
442 throw std::runtime_error(
443 "GpuLibrary: Unable to check if double precision");
448 bool MeasureQubitCollapse(
void *obj,
int qubitIndex) {
450 return fMeasureQubitCollapse(obj, qubitIndex) == 1;
452 throw std::runtime_error(
453 "GpuLibrary: Unable to measure qubit with collapse");
458 bool MeasureQubitNoCollapse(
void *obj,
int qubitIndex) {
460 return fMeasureQubitNoCollapse(obj, qubitIndex) == 1;
462 throw std::runtime_error(
463 "GpuLibrary: Unable to measure qubit no collapse");
468 bool MeasureQubitsCollapse(
void *obj,
int *qubits,
int *bitstring,
471 return fMeasureQubitsCollapse(obj, qubits, bitstring, bitstringLen) == 1;
473 throw std::runtime_error(
474 "GpuLibrary: Unable to measure qubits with collapse");
479 bool MeasureQubitsNoCollapse(
void *obj,
int *qubits,
int *bitstring,
482 return fMeasureQubitsNoCollapse(obj, qubits, bitstring, bitstringLen) ==
485 throw std::runtime_error(
486 "GpuLibrary: Unable to measure qubits with no collapse");
491 unsigned long long MeasureAllQubitsCollapse(
void *obj) {
493 return fMeasureAllQubitsCollapse(obj);
495 throw std::runtime_error(
496 "GpuLibrary: Unable to measure all qubits with collapse");
501 unsigned long long MeasureAllQubitsNoCollapse(
void *obj) {
503 return fMeasureAllQubitsNoCollapse(obj);
505 throw std::runtime_error(
506 "GpuLibrary: Unable to measure all qubits with no collapse");
513 return fSaveState(obj) == 1;
515 throw std::runtime_error(
"GpuLibrary: Unable to save state");
520 bool SaveStateToHost(
void *obj) {
522 return fSaveStateToHost(obj) == 1;
524 throw std::runtime_error(
"GpuLibrary: Unable to save state to host");
529 bool SaveStateDestructive(
void *obj) {
531 return fSaveStateDestructive(obj) == 1;
533 throw std::runtime_error(
534 "GpuLibrary: Unable to save state destructively");
539 bool RestoreStateFreeSaved(
void *obj) {
541 return fRestoreStateFreeSaved(obj) == 1;
543 throw std::runtime_error(
544 "GpuLibrary: Unable to restore state free saved");
549 bool RestoreStateNoFreeSaved(
void *obj) {
551 return fRestoreStateNoFreeSaved(obj) == 1;
553 throw std::runtime_error(
554 "GpuLibrary: Unable to restore state no free saved");
559 void FreeSavedState(
void *obj) {
561 fFreeSavedState(obj);
563 throw std::runtime_error(
"GpuLibrary: Unable to free saved state");
566 void *Clone(
void *obj)
const {
570 throw std::runtime_error(
"GpuLibrary: Unable to clone state vector");
575 bool Sample(
void *obj,
unsigned int nSamples,
long int *samples,
576 unsigned int nBits,
int *bits) {
578 return fSample(obj, nSamples, samples, nBits, bits) == 1;
580 throw std::runtime_error(
"GpuLibrary: Unable to sample state vector");
585 bool SampleAll(
void *obj,
unsigned int nSamples,
long int *samples) {
587 return fSampleAll(obj, nSamples, samples) == 1;
589 throw std::runtime_error(
"GpuLibrary: Unable to sample state vector");
594 bool Amplitude(
void *obj,
long long int state,
double *real,
595 double *imaginary)
const {
597 return fAmplitude(obj, state, real, imaginary) == 1;
599 throw std::runtime_error(
"GpuLibrary: Unable to get amplitude");
604 double Probability(
void *obj,
int *qubits,
int *mask,
int len)
const {
606 return fProbability(obj, qubits, mask, len);
608 throw std::runtime_error(
"GpuLibrary: Unable to get probability");
613 double BasisStateProbability(
void *obj,
long long int state)
const {
615 return fBasisStateProbability(obj, state);
617 throw std::runtime_error(
618 "GpuLibrary: Unable to get basis state probability");
625 return fAllProbabilities(obj, probabilities) == 1;
627 throw std::runtime_error(
"GpuLibrary: Unable to get all probabilities");
632 double ExpectationValue(
void *obj,
const char *pauliString,
int len)
const {
634 return fExpectationValue(obj, pauliString, len);
636 throw std::runtime_error(
"GpuLibrary: Unable to get expectation value");
641 bool ApplyX(
void *obj,
int qubit) {
643 return fApplyX(obj, qubit) == 1;
645 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate");
650 bool ApplyY(
void *obj,
int qubit) {
652 return fApplyY(obj, qubit) == 1;
654 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate");
659 bool ApplyZ(
void *obj,
int qubit) {
661 return fApplyZ(obj, qubit) == 1;
663 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate");
668 bool ApplyH(
void *obj,
int qubit) {
670 return fApplyH(obj, qubit) == 1;
672 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate");
677 bool ApplyS(
void *obj,
int qubit) {
679 return fApplyS(obj, qubit) == 1;
681 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate");
686 bool ApplySDG(
void *obj,
int qubit) {
688 return fApplySDG(obj, qubit) == 1;
690 throw std::runtime_error(
"GpuLibrary: Unable to apply SDG gate");
695 bool ApplyT(
void *obj,
int qubit) {
697 return fApplyT(obj, qubit) == 1;
699 throw std::runtime_error(
"GpuLibrary: Unable to apply T gate");
704 bool ApplyTDG(
void *obj,
int qubit) {
706 return fApplyTDG(obj, qubit) == 1;
708 throw std::runtime_error(
"GpuLibrary: Unable to apply TDG gate");
713 bool ApplySX(
void *obj,
int qubit) {
715 return fApplySX(obj, qubit) == 1;
717 throw std::runtime_error(
"GpuLibrary: Unable to apply SX gate");
724 return fApplySXDG(obj, qubit) == 1;
726 throw std::runtime_error(
"GpuLibrary: Unable to apply SXDG gate");
731 bool ApplyK(
void *obj,
int qubit) {
733 return fApplyK(obj, qubit) == 1;
735 throw std::runtime_error(
"GpuLibrary: Unable to apply K gate");
740 bool ApplyP(
void *obj,
int qubit,
double theta) {
742 return fApplyP(obj, qubit, theta) == 1;
744 throw std::runtime_error(
"GpuLibrary: Unable to apply P gate");
749 bool ApplyRx(
void *obj,
int qubit,
double theta) {
751 return fApplyRx(obj, qubit, theta) == 1;
753 throw std::runtime_error(
"GpuLibrary: Unable to apply Rx gate");
758 bool ApplyRy(
void *obj,
int qubit,
double theta) {
760 return fApplyRy(obj, qubit, theta) == 1;
762 throw std::runtime_error(
"GpuLibrary: Unable to apply Ry gate");
767 bool ApplyRz(
void *obj,
int qubit,
double theta) {
769 return fApplyRz(obj, qubit, theta) == 1;
771 throw std::runtime_error(
"GpuLibrary: Unable to apply Rz gate");
776 bool ApplyU(
void *obj,
int qubit,
double theta,
double phi,
double lambda,
779 return fApplyU(obj, qubit, theta, phi, lambda, gamma) == 1;
781 throw std::runtime_error(
"GpuLibrary: Unable to apply U gate");
786 bool ApplyCX(
void *obj,
int controlQubit,
int targetQubit) {
788 return fApplyCX(obj, controlQubit, targetQubit) == 1;
790 throw std::runtime_error(
"GpuLibrary: Unable to apply CX gate");
795 bool ApplyCY(
void *obj,
int controlQubit,
int targetQubit) {
797 return fApplyCY(obj, controlQubit, targetQubit) == 1;
799 throw std::runtime_error(
"GpuLibrary: Unable to apply CY gate");
804 bool ApplyCZ(
void *obj,
int controlQubit,
int targetQubit) {
806 return fApplyCZ(obj, controlQubit, targetQubit) == 1;
808 throw std::runtime_error(
"GpuLibrary: Unable to apply CZ gate");
813 bool ApplyCH(
void *obj,
int controlQubit,
int targetQubit) {
815 return fApplyCH(obj, controlQubit, targetQubit) == 1;
817 throw std::runtime_error(
"GpuLibrary: Unable to apply CH gate");
822 bool ApplyCSX(
void *obj,
int controlQubit,
int targetQubit) {
824 return fApplyCSX(obj, controlQubit, targetQubit) == 1;
826 throw std::runtime_error(
"GpuLibrary: Unable to apply CSX gate");
831 bool ApplyCSXDG(
void *obj,
int controlQubit,
int targetQubit) {
833 return fApplyCSXDG(obj, controlQubit, targetQubit) == 1;
835 throw std::runtime_error(
"GpuLibrary: Unable to apply CSXDG gate");
840 bool ApplyCP(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
842 return fApplyCP(obj, controlQubit, targetQubit, theta) == 1;
844 throw std::runtime_error(
"GpuLibrary: Unable to apply CP gate");
849 bool ApplyCRx(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
851 return fApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
853 throw std::runtime_error(
"GpuLibrary: Unable to apply CRx gate");
858 bool ApplyCRy(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
860 return fApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
862 throw std::runtime_error(
"GpuLibrary: Unable to apply CRy gate");
867 bool ApplyCRz(
void *obj,
int controlQubit,
int targetQubit,
double theta) {
869 return fApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
871 throw std::runtime_error(
"GpuLibrary: Unable to apply CRz gate");
876 bool ApplyCCX(
void *obj,
int controlQubit1,
int controlQubit2,
879 return fApplyCCX(obj, controlQubit1, controlQubit2, targetQubit) == 1;
881 throw std::runtime_error(
"GpuLibrary: Unable to apply CCX gate");
886 bool ApplySwap(
void *obj,
int qubit1,
int qubit2) {
888 return fApplySwap(obj, qubit1, qubit2) == 1;
890 throw std::runtime_error(
"GpuLibrary: Unable to apply Swap gate");
895 bool ApplyCSwap(
void *obj,
int controlQubit,
int qubit1,
int qubit2) {
897 return fApplyCSwap(obj, controlQubit, qubit1, qubit2) == 1;
899 throw std::runtime_error(
"GpuLibrary: Unable to apply CSwap gate");
904 bool ApplyCU(
void *obj,
int controlQubit,
int targetQubit,
double theta,
905 double phi,
double lambda,
double gamma) {
907 return fApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda,
910 throw std::runtime_error(
"GpuLibrary: Unable to apply CU gate");
919 return fCreateMPS(LibraryHandle);
921 throw std::runtime_error(
"GpuLibrary: Unable to create mps");
924 void DestroyMPS(
void *obj) {
928 throw std::runtime_error(
"GpuLibrary: Unable to destroy mps");
931 bool MPSCreate(
void *obj,
unsigned int nrQubits) {
933 return fMPSCreate(obj, nrQubits) == 1;
935 throw std::runtime_error(
"GpuLibrary: Unable to create mps with the "
936 "specified number of qubits");
941 bool MPSReset(
void *obj) {
943 return fMPSReset(obj) == 1;
945 throw std::runtime_error(
"GpuLibrary: Unable to reset mps");
950 bool MPSIsValid(
void *obj)
const {
952 return fMPSIsValid(obj) == 1;
954 throw std::runtime_error(
"GpuLibrary: Unable to check if mps is valid");
959 bool MPSIsCreated(
void *obj)
const {
961 return fMPSIsCreated(obj) == 1;
963 throw std::runtime_error(
"GpuLibrary: Unable to check if mps is created");
968 bool MPSSetDataType(
void *obj,
int useDoublePrecision) {
970 return fMPSSetDataType(obj, useDoublePrecision) == 1;
972 throw std::runtime_error(
"GpuLibrary: Unable to set precision for mps");
977 bool MPSIsDoublePrecision(
void *obj)
const {
979 return fMPSIsDoublePrecision(obj) == 1;
981 throw std::runtime_error(
"GpuLibrary: Unable to get precision for mps");
986 bool MPSSetCutoff(
void *obj,
double val) {
988 return fMPSSetCutoff(obj, val) == 1;
990 throw std::runtime_error(
"GpuLibrary: Unable to set cutoff for mps");
995 double MPSGetCutoff(
void *obj)
const {
997 return fMPSGetCutoff(obj);
999 throw std::runtime_error(
"GpuLibrary: Unable to get cutoff for mps");
1002 bool MPSSetGesvdJ(
void *obj,
int val) {
1004 return fMPSSetGesvdJ(obj, val) == 1;
1006 throw std::runtime_error(
"GpuLibrary: Unable to set GesvdJ for mps");
1011 bool MPSGetGesvdJ(
void *obj)
const {
1013 return fMPSGetGesvdJ(obj) == 1;
1015 throw std::runtime_error(
"GpuLibrary: Unable to get GesvdJ for mps");
1020 bool MPSSetMaxExtent(
void *obj,
long int val) {
1022 return fMPSSetMaxExtent(obj, val) == 1;
1024 throw std::runtime_error(
"GpuLibrary: Unable to set max extent for mps");
1029 long int MPSGetMaxExtent(
void *obj) {
1031 return fMPSGetMaxExtent(obj);
1033 throw std::runtime_error(
"GpuLibrary: Unable to get max extent for mps");
1038 int MPSGetNrQubits(
void *obj) {
1040 return fMPSGetNrQubits(obj);
1042 throw std::runtime_error(
"GpuLibrary: Unable to get nr qubits for mps");
1047 bool MPSAmplitude(
void *obj,
long int numFixedValues,
long int *fixedValues,
1048 double *real,
double *imaginary) {
1050 return fMPSAmplitude(obj, numFixedValues, fixedValues, real, imaginary) ==
1053 throw std::runtime_error(
"GpuLibrary: Unable to get mps amplitude");
1058 double MPSProbability0(
void *obj,
unsigned int qubit) {
1060 return fMPSProbability0(obj, qubit);
1062 throw std::runtime_error(
1063 "GpuLibrary: Unable to get probability for 0 for mps");
1068 bool MPSMeasure(
void *obj,
unsigned int qubit) {
1070 return fMPSMeasure(obj, qubit) == 1;
1072 throw std::runtime_error(
"GpuLibrary: Unable to measure qubit on mps");
1077 bool MPSMeasureQubits(
void *obj,
long int numQubits,
unsigned int *qubits,
1080 return fMPSMeasureQubits(obj, numQubits, qubits, result) == 1;
1082 throw std::runtime_error(
"GpuLibrary: Unable to measure qubits on mps");
1087 std::unordered_map<std::vector<bool>, int64_t> *MPSGetMapForSample() {
1089 return (std::unordered_map<std::vector<bool>, int64_t> *)
1090 fMPSGetMapForSample();
1092 throw std::runtime_error(
1093 "GpuLibrary: Unable to get map for sample for mps");
1099 MPSFreeMapForSample(std::unordered_map<std::vector<bool>, int64_t> *map) {
1101 return fMPSFreeMapForSample((
void *)map) == 1;
1103 throw std::runtime_error(
1104 "GpuLibrary: Unable to free map for sample for mps");
1109 bool MPSSample(
void *obj,
long int numShots,
long int numQubits,
1110 unsigned int *qubits,
void *resultMap) {
1112 return fMPSSample(obj, numShots, numQubits, qubits, resultMap) == 1;
1114 throw std::runtime_error(
"GpuLibrary: Unable to sample mps");
1119 bool MPSSaveState(
void *obj) {
1121 return fMPSSaveState(obj) == 1;
1123 throw std::runtime_error(
"GpuLibrary: Unable to save mps state");
1128 bool MPSRestoreState(
void *obj) {
1130 return fMPSRestoreState(obj) == 1;
1132 throw std::runtime_error(
"GpuLibrary: Unable to restore mps state");
1137 bool MPSCleanSavedState(
void *obj) {
1139 return fMPSCleanSavedState(obj) == 1;
1141 throw std::runtime_error(
"GpuLibrary: Unable to clean mps saved state");
1146 void *MPSClone(
void *obj) {
1148 return fMPSClone(obj);
1150 throw std::runtime_error(
"GpuLibrary: Unable to clone mps");
1155 double MPSExpectationValue(
void *obj,
const char *pauliString,
1158 return fMPSExpectationValue(obj, pauliString, len);
1160 throw std::runtime_error(
1161 "GpuLibrary: Unable to get mps expectation value");
1166 bool MPSApplyX(
void *obj,
unsigned int siteA) {
1168 return fMPSApplyX(obj, siteA) == 1;
1170 throw std::runtime_error(
"GpuLibrary: Unable to apply X gate on mps");
1175 bool MPSApplyY(
void *obj,
unsigned int siteA) {
1177 return fMPSApplyY(obj, siteA) == 1;
1179 throw std::runtime_error(
"GpuLibrary: Unable to apply Y gate on mps");
1184 bool MPSApplyZ(
void *obj,
unsigned int siteA) {
1186 return fMPSApplyZ(obj, siteA) == 1;
1188 throw std::runtime_error(
"GpuLibrary: Unable to apply Z gate on mps");
1193 bool MPSApplyH(
void *obj,
unsigned int siteA) {
1195 return fMPSApplyH(obj, siteA) == 1;
1197 throw std::runtime_error(
"GpuLibrary: Unable to apply H gate on mps");
1202 bool MPSApplyS(
void *obj,
unsigned int siteA) {
1204 return fMPSApplyS(obj, siteA) == 1;
1206 throw std::runtime_error(
"GpuLibrary: Unable to apply S gate on mps");
1211 bool MPSApplySDG(
void *obj,
unsigned int siteA) {
1213 return fMPSApplySDG(obj, siteA) == 1;
1215 throw std::runtime_error(
"GpuLibrary: Unable to apply sdg gate on mps");
1220 bool MPSApplyT(
void *obj,
unsigned int siteA) {
1222 return fMPSApplyT(obj, siteA) == 1;
1224 throw std::runtime_error(
"GpuLibrary: Unable to apply t gate on mps");
1229 bool MPSApplyTDG(
void *obj,
unsigned int siteA) {
1231 return fMPSApplyTDG(obj, siteA) == 1;
1233 throw std::runtime_error(
"GpuLibrary: Unable to appl tdg gate on mps");
1238 bool MPSApplySX(
void *obj,
unsigned int siteA) {
1240 return fMPSApplySX(obj, siteA) == 1;
1242 throw std::runtime_error(
"GpuLibrary: Unable to apply sx gate on mps");
1247 bool MPSApplySXDG(
void *obj,
unsigned int siteA) {
1249 return fMPSApplySXDG(obj, siteA) == 1;
1251 throw std::runtime_error(
"GpuLibrary: Unable to apply sxdg gate on mps");
1256 bool MPSApplyK(
void *obj,
unsigned int siteA) {
1258 return fMPSApplyK(obj, siteA) == 1;
1260 throw std::runtime_error(
"GpuLibrary: Unable to apply k gate on mps");
1265 bool MPSApplyP(
void *obj,
unsigned int siteA,
double theta) {
1267 return fMPSApplyP(obj, siteA, theta) == 1;
1269 throw std::runtime_error(
"GpuLibrary: Unable to apply p gate on mps");
1273 bool MPSApplyRx(
void *obj,
unsigned int siteA,
double theta) {
1275 return fMPSApplyRx(obj, siteA, theta) == 1;
1277 throw std::runtime_error(
"GpuLibrary: Unable to apply rx gate on mps");
1282 bool MPSApplyRy(
void *obj,
unsigned int siteA,
double theta) {
1284 return fMPSApplyRy(obj, siteA, theta) == 1;
1286 throw std::runtime_error(
"GpuLibrary: Unable to apply ry gate on mps");
1291 bool MPSApplyRz(
void *obj,
unsigned int siteA,
double theta) {
1293 return fMPSApplyRz(obj, siteA, theta) == 1;
1295 throw std::runtime_error(
"GpuLibrary: Unable to apply rz gate on mps");
1300 bool MPSApplyU(
void *obj,
unsigned int siteA,
double theta,
double phi,
1301 double lambda,
double gamma) {
1303 return fMPSApplyU(obj, siteA, theta, phi, lambda, gamma) == 1;
1305 throw std::runtime_error(
"GpuLibrary: Unable to apply u gate on mps");
1310 bool MPSApplySwap(
void *obj,
unsigned int controlQubit,
1311 unsigned int targetQubit) {
1313 return fMPSApplySwap(obj, controlQubit, targetQubit) == 1;
1315 throw std::runtime_error(
"GpuLibrary: Unable to apply swap gate on mps");
1320 bool MPSApplyCX(
void *obj,
unsigned int controlQubit,
1321 unsigned int targetQubit) {
1323 return fMPSApplyCX(obj, controlQubit, targetQubit) == 1;
1325 throw std::runtime_error(
"GpuLibrary: Unable to apply cx gate on mps");
1330 bool MPSApplyCY(
void *obj,
unsigned int controlQubit,
1331 unsigned int targetQubit) {
1333 return fMPSApplyCY(obj, controlQubit, targetQubit) == 1;
1335 throw std::runtime_error(
"GpuLibrary: Unable to apply cy gate on mps");
1340 bool MPSApplyCZ(
void *obj,
unsigned int controlQubit,
1341 unsigned int targetQubit) {
1343 return fMPSApplyCZ(obj, controlQubit, targetQubit) == 1;
1345 throw std::runtime_error(
"GpuLibrary: Unable to apply cz gate on mps");
1350 bool MPSApplyCH(
void *obj,
unsigned int controlQubit,
1351 unsigned int targetQubit) {
1353 return fMPSApplyCH(obj, controlQubit, targetQubit) == 1;
1355 throw std::runtime_error(
"GpuLibrary: Unable to apply ch gate on mps");
1360 bool MPSApplyCSX(
void *obj,
unsigned int controlQubit,
1361 unsigned int targetQubit) {
1363 return fMPSApplyCSX(obj, controlQubit, targetQubit) == 1;
1365 throw std::runtime_error(
"GpuLibrary: Unable to apply csx gate on mps");
1368 bool MPSApplyCSXDG(
void *obj,
unsigned int controlQubit,
1369 unsigned int targetQubit) {
1371 return fMPSApplyCSXDG(obj, controlQubit, targetQubit) == 1;
1373 throw std::runtime_error(
"GpuLibrary: Unable to apply csxdg gate on mps");
1378 bool MPSApplyCP(
void *obj,
unsigned int controlQubit,
1379 unsigned int targetQubit,
double theta) {
1381 return fMPSApplyCP(obj, controlQubit, targetQubit, theta) == 1;
1383 throw std::runtime_error(
"GpuLibrary: Unable to apply cp gate on mps");
1388 bool MPSApplyCRx(
void *obj,
unsigned int controlQubit,
1389 unsigned int targetQubit,
double theta) {
1391 return fMPSApplyCRx(obj, controlQubit, targetQubit, theta) == 1;
1393 throw std::runtime_error(
"GpuLibrary: Unable to apply crx gate on mps");
1398 bool MPSApplyCRy(
void *obj,
unsigned int controlQubit,
1399 unsigned int targetQubit,
double theta) {
1401 return fMPSApplyCRy(obj, controlQubit, targetQubit, theta) == 1;
1403 throw std::runtime_error(
"GpuLibrary: Unable to apply cry gate on mps");
1408 bool MPSApplyCRz(
void *obj,
unsigned int controlQubit,
1409 unsigned int targetQubit,
double theta) {
1411 return fMPSApplyCRz(obj, controlQubit, targetQubit, theta) == 1;
1413 throw std::runtime_error(
"GpuLibrary: Unable to apply crz gate on mps");
1418 bool MPSApplyCU(
void *obj,
unsigned int controlQubit,
1419 unsigned int targetQubit,
double theta,
double phi,
1420 double lambda,
double gamma) {
1422 return fMPSApplyCU(obj, controlQubit, targetQubit, theta, phi, lambda,
1425 throw std::runtime_error(
"GpuLibrary: Unable to apply cu gate on mps");
1431 void *LibraryHandle =
nullptr;
1436 void *(*fCreateStateVector)(
void *);
1437 void (*fDestroyStateVector)(
void *);
1440 int (*fSetDataType)(
void *, int);
1441 int (*fIsDoublePrecision)(
void *);
1442 int (*fCreate)(
void *,
unsigned int);
1443 int (*fReset)(
void *);
1444 int (*fCreateWithState)(
void *,
unsigned int,
const double *);
1445 int (*fMeasureQubitCollapse)(
void *, int);
1446 int (*fMeasureQubitNoCollapse)(
void *, int);
1447 int (*fMeasureQubitsCollapse)(
void *,
int *,
int *, int);
1448 int (*fMeasureQubitsNoCollapse)(
void *,
int *,
int *, int);
1449 unsigned long long (*fMeasureAllQubitsCollapse)(
void *);
1450 unsigned long long (*fMeasureAllQubitsNoCollapse)(
void *);
1452 int (*fSaveState)(
void *);
1453 int (*fSaveStateToHost)(
void *);
1454 int (*fSaveStateDestructive)(
void *);
1455 int (*fRestoreStateFreeSaved)(
void *);
1456 int (*fRestoreStateNoFreeSaved)(
void *);
1457 void (*fFreeSavedState)(
void *obj);
1458 void *(*fClone)(
void *);
1459 int (*fSample)(
void *,
unsigned int,
long int *,
unsigned int,
int *);
1460 int (*fSampleAll)(
void *,
unsigned int,
long int *);
1461 int (*fAmplitude)(
void *,
long long int,
double *,
double *);
1462 double (*fProbability)(
void *,
int *,
int *, int);
1463 double (*fBasisStateProbability)(
void *,
long long int);
1464 int (*fAllProbabilities)(
void *,
double *);
1465 double (*fExpectationValue)(
void *,
const char *, int);
1467 int (*fApplyX)(
void *, int);
1468 int (*fApplyY)(
void *, int);
1469 int (*fApplyZ)(
void *, int);
1470 int (*fApplyH)(
void *, int);
1471 int (*fApplyS)(
void *, int);
1472 int (*fApplySDG)(
void *, int);
1473 int (*fApplyT)(
void *, int);
1474 int (*fApplyTDG)(
void *, int);
1475 int (*fApplySX)(
void *, int);
1476 int (*fApplySXDG)(
void *, int);
1477 int (*fApplyK)(
void *, int);
1478 int (*fApplyP)(
void *, int, double);
1479 int (*fApplyRx)(
void *, int, double);
1480 int (*fApplyRy)(
void *, int, double);
1481 int (*fApplyRz)(
void *, int, double);
1482 int (*fApplyU)(
void *, int, double, double, double, double);
1483 int (*fApplyCX)(
void *, int, int);
1484 int (*fApplyCY)(
void *, int, int);
1485 int (*fApplyCZ)(
void *, int, int);
1486 int (*fApplyCH)(
void *, int, int);
1487 int (*fApplyCSX)(
void *, int, int);
1488 int (*fApplyCSXDG)(
void *, int, int);
1489 int (*fApplyCP)(
void *, int, int, double);
1490 int (*fApplyCRx)(
void *, int, int, double);
1491 int (*fApplyCRy)(
void *, int, int, double);
1492 int (*fApplyCRz)(
void *, int, int, double);
1493 int (*fApplyCCX)(
void *, int, int, int);
1494 int (*fApplySwap)(
void *, int, int);
1495 int (*fApplyCSwap)(
void *, int, int, int);
1496 int (*fApplyCU)(
void *, int, int, double, double, double, double);
1499 void *(*fCreateMPS)(
void *);
1500 void (*fDestroyMPS)(
void *);
1502 int (*fMPSCreate)(
void *,
unsigned int);
1503 int (*fMPSReset)(
void *);
1505 int (*fMPSIsValid)(
void *);
1506 int (*fMPSIsCreated)(
void *);
1508 int (*fMPSSetDataType)(
void *, int);
1509 int (*fMPSIsDoublePrecision)(
void *);
1510 int (*fMPSSetCutoff)(
void *, double);
1511 double (*fMPSGetCutoff)(
void *);
1512 int (*fMPSSetGesvdJ)(
void *, int);
1513 int (*fMPSGetGesvdJ)(
void *);
1514 int (*fMPSSetMaxExtent)(
void *,
long int);
1515 long int (*fMPSGetMaxExtent)(
void *);
1516 int (*fMPSGetNrQubits)(
void *);
1517 int (*fMPSAmplitude)(
void *,
long int,
long int *,
double *,
double *);
1518 double (*fMPSProbability0)(
void *,
unsigned int);
1519 int (*fMPSMeasure)(
void *,
unsigned int);
1520 int (*fMPSMeasureQubits)(
void *,
long int,
unsigned int *,
int *);
1522 void *(*fMPSGetMapForSample)();
1523 int (*fMPSFreeMapForSample)(
void *);
1524 int (*fMPSSample)(
void *,
long int,
long int,
unsigned int *,
void *);
1526 int (*fMPSSaveState)(
void *);
1527 int (*fMPSRestoreState)(
void *);
1528 int (*fMPSCleanSavedState)(
void *);
1529 void *(*fMPSClone)(
void *);
1531 double (*fMPSExpectationValue)(
void *,
const char *, int);
1533 int (*fMPSApplyX)(
void *,
unsigned int);
1534 int (*fMPSApplyY)(
void *,
unsigned int);
1535 int (*fMPSApplyZ)(
void *,
unsigned int);
1536 int (*fMPSApplyH)(
void *,
unsigned int);
1537 int (*fMPSApplyS)(
void *,
unsigned int);
1538 int (*fMPSApplySDG)(
void *,
unsigned int);
1539 int (*fMPSApplyT)(
void *,
unsigned int);
1540 int (*fMPSApplyTDG)(
void *,
unsigned int);
1541 int (*fMPSApplySX)(
void *,
unsigned int);
1542 int (*fMPSApplySXDG)(
void *,
unsigned int);
1543 int (*fMPSApplyK)(
void *,
unsigned int);
1544 int (*fMPSApplyP)(
void *,
unsigned int, double);
1545 int (*fMPSApplyRx)(
void *,
unsigned int, double);
1546 int (*fMPSApplyRy)(
void *,
unsigned int, double);
1547 int (*fMPSApplyRz)(
void *,
unsigned int, double);
1548 int (*fMPSApplyU)(
void *,
unsigned int, double, double, double, double);
1549 int (*fMPSApplySwap)(
void *,
unsigned int,
unsigned int);
1550 int (*fMPSApplyCX)(
void *,
unsigned int,
unsigned int);
1551 int (*fMPSApplyCY)(
void *,
unsigned int,
unsigned int);
1552 int (*fMPSApplyCZ)(
void *,
unsigned int,
unsigned int);
1553 int (*fMPSApplyCH)(
void *,
unsigned int,
unsigned int);
1554 int (*fMPSApplyCSX)(
void *,
unsigned int,
unsigned int);
1555 int (*fMPSApplyCSXDG)(
void *,
unsigned int,
unsigned int);
1556 int (*fMPSApplyCP)(
void *,
unsigned int,
unsigned int, double);
1557 int (*fMPSApplyCRx)(
void *,
unsigned int,
unsigned int, double);
1558 int (*fMPSApplyCRy)(
void *,
unsigned int,
unsigned int, double);
1559 int (*fMPSApplyCRz)(
void *,
unsigned int,
unsigned int, double);
1560 int (*fMPSApplyCU)(
void *,
unsigned int,
unsigned int, double, double, double,
int ApplyK(void *sim, int qubit)
double Probability(void *sim, unsigned long long int outcome)
int ApplyRx(void *sim, int qubit, double theta)
int ApplyX(void *sim, int qubit)
int ApplyU(void *sim, int qubit, double theta, double phi, double lambda, double gamma)
int ApplyCRy(void *sim, int controlQubit, int targetQubit, double theta)
int ApplyTDG(void *sim, int qubit)
int ApplyCSXDG(void *sim, int controlQubit, int targetQubit)
int ApplyS(void *sim, int qubit)
int ApplyCX(void *sim, int controlQubit, int targetQubit)
int ApplyCRz(void *sim, int controlQubit, int targetQubit, double theta)
double * AllProbabilities(void *sim)
int ApplyCP(void *sim, int controlQubit, int targetQubit, double theta)
int ApplySXDG(void *sim, int qubit)
int ApplySDG(void *sim, int qubit)
int ApplyCSwap(void *sim, int controlQubit, int qubit1, int qubit2)
int ApplyCCX(void *sim, int controlQubit1, int controlQubit2, int targetQubit)
int ApplyY(void *sim, int qubit)
double * Amplitude(void *sim, unsigned long long int outcome)
int ApplyZ(void *sim, int qubit)
int ApplyH(void *sim, int qubit)
int ApplyCY(void *sim, int controlQubit, int targetQubit)
int ApplyCU(void *sim, int controlQubit, int targetQubit, double theta, double phi, double lambda, double gamma)
int ApplySwap(void *sim, int qubit1, int qubit2)
int ApplyRy(void *sim, int qubit, double theta)
int ApplyP(void *sim, int qubit, double theta)
int ApplyCH(void *sim, int controlQubit, int targetQubit)
int ApplySX(void *sim, int qubit)
int ApplyCZ(void *sim, int controlQubit, int targetQubit)
int ApplyRz(void *sim, int qubit, double theta)
int ApplyT(void *sim, int qubit)
int ApplyCRx(void *sim, int controlQubit, int targetQubit, double theta)
int ApplyCSX(void *sim, int controlQubit, int targetQubit)
virtual bool Init(const char *libName) noexcept
bool IsMuted() const noexcept