Maestro 0.3.11
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
QuestLibSim.h
Go to the documentation of this file.
1
11
12#pragma once
13
14#ifndef _QUEST_LIB_SIM_H_
15#define _QUEST_LIB_SIM_H_
16
17#include "../../Utils/Library.h"
18#include <complex>
19#include <vector>
20
21namespace Simulators
22{
23
24// use it as a singleton
26{
27 public:
28 QuestLibSim(const QuestLibSim &) = delete;
29 QuestLibSim &operator=(const QuestLibSim &) = delete;
30
31 QuestLibSim(QuestLibSim &&) = default;
33
34 QuestLibSim() noexcept
35 {
36 }
37
38 virtual ~QuestLibSim()
39 {
40 if (initialized && fFinalize)
41 {
42 fFinalize();
43 initialized = false;
44 }
45 }
46
47 bool Init(const char *libName) noexcept override
48 {
49 if (Utils::Library::Init(libName))
50 {
51 fInitialize = (void (*)())GetFunction("Initialize");
52 CheckFunction((void *)fInitialize, __LINE__);
53 fFinalize = (void (*)())GetFunction("Finalize");
54 CheckFunction((void *)fFinalize, __LINE__);
55
56 fCreateSimulator = (unsigned long int (*)(int))GetFunction("CreateSimulator");
57 CheckFunction((void *)fCreateSimulator, __LINE__);
58 fDestroySimulator = (void (*)(unsigned long int))GetFunction("DestroySimulator");
59 CheckFunction((void *)fDestroySimulator, __LINE__);
60 fCloneSimulator = (unsigned long int (*)(void *))GetFunction("CloneSimulator");
61 CheckFunction((void *)fCloneSimulator, __LINE__);
62 fGetSimulator = (void *(*)(unsigned long int))GetFunction("GetSimulator");
63 CheckFunction((void *)fGetSimulator, __LINE__);
64
65 fGetNumQubits = (int (*)(void *))GetFunction("GetNumQubits");
66 CheckFunction((void *)fGetNumQubits, __LINE__);
67 fGetQubitProbability0 = (double (*)(void *, int))GetFunction("GetQubitProbability0");
68 CheckFunction((void *)fGetQubitProbability0, __LINE__);
69 fGetQubitProbability1 = (double (*)(void *, int))GetFunction("GetQubitProbability1");
70 CheckFunction((void *)fGetQubitProbability1, __LINE__);
71 fGetOutcomeProbability = (double (*)(void *, long long int))GetFunction("GetOutcomeProbability");
72 CheckFunction((void *)fGetOutcomeProbability, __LINE__);
73 fGetExpectationValue = (double (*)(void *, const char *))GetFunction("GetExpectationValue");
74 CheckFunction((void *)fGetExpectationValue, __LINE__);
75
76 fMeasure = (int (*)(void *, int))GetFunction("Measure");
77 CheckFunction((void *)fMeasure, __LINE__);
78 fMeasureQubits = (long long int (*)(void *, int *, int))GetFunction("MeasureQubits");
79 CheckFunction((void *)fMeasureQubits, __LINE__);
80
81 fApplyP = (void (*)(void *, int, double))GetFunction("ApplyP");
82 CheckFunction((void *)fApplyP, __LINE__);
83 fApplyX = (void (*)(void *, int))GetFunction("ApplyX");
84 CheckFunction((void *)fApplyX, __LINE__);
85 fApplyY = (void (*)(void *, int))GetFunction("ApplyY");
86 CheckFunction((void *)fApplyY, __LINE__);
87 fApplyZ = (void (*)(void *, int))GetFunction("ApplyZ");
88 CheckFunction((void *)fApplyZ, __LINE__);
89 fApplyH = (void (*)(void *, int))GetFunction("ApplyH");
90 CheckFunction((void *)fApplyH, __LINE__);
91 fApplyS = (void (*)(void *, int))GetFunction("ApplyS");
92 CheckFunction((void *)fApplyS, __LINE__);
93 fApplyT = (void (*)(void *, int))GetFunction("ApplyT");
94 CheckFunction((void *)fApplyT, __LINE__);
95
96 fApplyRx = (void (*)(void *, int, double))GetFunction("ApplyRx");
97 CheckFunction((void *)fApplyRx, __LINE__);
98 fApplyRy = (void (*)(void *, int, double))GetFunction("ApplyRy");
99 CheckFunction((void *)fApplyRy, __LINE__);
100 fApplyRz = (void (*)(void *, int, double))GetFunction("ApplyRz");
101 CheckFunction((void *)fApplyRz, __LINE__);
102
103 fApplyCS = (void (*)(void *, int, int))GetFunction("ApplyCS");
104 CheckFunction((void *)fApplyCS, __LINE__);
105 fApplyCT = (void (*)(void *, int, int))GetFunction("ApplyCT");
106 CheckFunction((void *)fApplyCT, __LINE__);
107 fApplyCH = (void (*)(void *, int, int))GetFunction("ApplyCH");
108 CheckFunction((void *)fApplyCH, __LINE__);
109 fApplySwap = (void (*)(void *, int, int))GetFunction("ApplySwap");
110 CheckFunction((void *)fApplySwap, __LINE__);
111 fApplyCX = (void (*)(void *, int, int))GetFunction("ApplyCX");
112 CheckFunction((void *)fApplyCX, __LINE__);
113 fApplyCY = (void (*)(void *, int, int))GetFunction("ApplyCY");
114 CheckFunction((void *)fApplyCY, __LINE__);
115 fApplyCZ = (void (*)(void *, int, int))GetFunction("ApplyCZ");
116 CheckFunction((void *)fApplyCZ, __LINE__);
117
118 fApplyCRx = (void (*)(void *, int, int, double))GetFunction("ApplyCRx");
119 CheckFunction((void *)fApplyCRx, __LINE__);
120 fApplyCRy = (void (*)(void *, int, int, double))GetFunction("ApplyCRy");
121 CheckFunction((void *)fApplyCRy, __LINE__);
122 fApplyCRz = (void (*)(void *, int, int, double))GetFunction("ApplyCRz");
123 CheckFunction((void *)fApplyCRz, __LINE__);
124
125 fApplyCSwap = (void (*)(void *, int, int, int))GetFunction("ApplyCSwap");
126 CheckFunction((void *)fApplyCSwap, __LINE__);
127 fApplyCCX = (void (*)(void *, int, int, int))GetFunction("ApplyCCX");
128 CheckFunction((void *)fApplyCCX, __LINE__);
129
130 fApplySdg = (void (*)(void *, int))GetFunction("ApplySdg");
131 CheckFunction((void *)fApplySdg, __LINE__);
132 fApplyTdg = (void (*)(void *, int))GetFunction("ApplyTdg");
133 CheckFunction((void *)fApplyTdg, __LINE__);
134 fApplySx = (void (*)(void *, int))GetFunction("ApplySx");
135 CheckFunction((void *)fApplySx, __LINE__);
136 fApplySxDg = (void (*)(void *, int))GetFunction("ApplySxDg");
137 CheckFunction((void *)fApplySxDg, __LINE__);
138 fApplyK = (void (*)(void *, int))GetFunction("ApplyK");
139 CheckFunction((void *)fApplyK, __LINE__);
140
141 fApplyU = (void (*)(void *, int, double, double, double, double))GetFunction("ApplyU");
142 CheckFunction((void *)fApplyU, __LINE__);
143 fApplyCU = (void (*)(void *, int, int, double, double, double, double))GetFunction("ApplyCU");
144 CheckFunction((void *)fApplyCU, __LINE__);
145 fApplyCP = (void (*)(void *, int, int, double))GetFunction("ApplyCP");
146 CheckFunction((void *)fApplyCP, __LINE__);
147 fApplyCSx = (void (*)(void *, int, int))GetFunction("ApplyCSx");
148 CheckFunction((void *)fApplyCSx, __LINE__);
149 fApplyCSxDg = (void (*)(void *, int, int))GetFunction("ApplyCSxDg");
150 CheckFunction((void *)fApplyCSxDg, __LINE__);
151
152 fGetAmplitudes = (int (*)(void *, void *, unsigned long long int))GetFunction("GetAmplitudes");
153 CheckFunction((void *)fGetAmplitudes, __LINE__);
154 fGetAmplitude = (int (*)(void *, long long int, void *, unsigned long long int))GetFunction("GetAmplitude");
155 CheckFunction((void *)fGetAmplitude, __LINE__);
156 fIsDoublePrecision = (int (*)())GetFunction("IsDoublePrecision");
157 CheckFunction((void *)fIsDoublePrecision, __LINE__);
158
159 if (fInitialize)
160 {
161 fInitialize();
162 initialized = true;
163 return true;
164 }
165 }
166
167 return false;
168 }
169
170 static void CheckFunction(void *func, int line) noexcept
171 {
172 if (!func)
173 {
174 std::cerr << "QuestLibSim: Unable to load function, line #: " << line;
175
176#ifdef __linux__
177 const char *dlsym_error = dlerror();
178 if (dlsym_error)
179 std::cerr << ", error: " << dlsym_error;
180#elif defined(_WIN32)
181 const DWORD error = GetLastError();
182 std::cerr << ", error code: " << error;
183#endif
184
185 std::cerr << std::endl;
186 }
187 }
188
189 bool IsValid() const
190 {
191 return initialized;
192 }
193
194 // simulator management
195
196 unsigned long int CreateSimulator(int nrQubits)
197 {
198 if (initialized)
199 return fCreateSimulator(nrQubits);
200 else
201 throw std::runtime_error("QuestLibSim: Unable to create simulator");
202
203 return 0;
204 }
205
206 void DestroySimulator(unsigned long int simHandle)
207 {
208 if (initialized)
209 fDestroySimulator(simHandle);
210 else
211 throw std::runtime_error("QuestLibSim: Unable to destroy simulator");
212 }
213
214 unsigned long int CloneSimulator(void *sim)
215 {
216 if (initialized)
217 return fCloneSimulator(sim);
218 else
219 throw std::runtime_error("QuestLibSim: Unable to clone simulator");
220
221 return 0;
222 }
223
224 void *GetSimulator(unsigned long int simHandle)
225 {
226 if (initialized)
227 return fGetSimulator(simHandle);
228 else
229 throw std::runtime_error("QuestLibSim: Unable to get simulator");
230
231 return nullptr;
232 }
233
234 // state query functions
235
236 int GetNumQubits(void *sim) const
237 {
238 if (initialized)
239 return fGetNumQubits(sim);
240 else
241 throw std::runtime_error("QuestLibSim: Unable to get number of qubits");
242
243 return 0;
244 }
245
246 double GetQubitProbability0(void *sim, int qubit) const
247 {
248 if (initialized)
249 return fGetQubitProbability0(sim, qubit);
250 else
251 throw std::runtime_error("QuestLibSim: Unable to get qubit probability 0");
252
253 return 0;
254 }
255
256 double GetQubitProbability1(void *sim, int qubit) const
257 {
258 if (initialized)
259 return fGetQubitProbability1(sim, qubit);
260 else
261 throw std::runtime_error("QuestLibSim: Unable to get qubit probability 1");
262
263 return 0;
264 }
265
266 double GetOutcomeProbability(void *sim, long long int outcome) const
267 {
268 if (initialized)
269 return fGetOutcomeProbability(sim, outcome);
270 else
271 throw std::runtime_error("QuestLibSim: Unable to get outcome probability");
272
273 return 0;
274 }
275
276 double GetExpectationValue(void *sim, const char *pauliStr) const
277 {
278 if (initialized)
279 return fGetExpectationValue(sim, pauliStr);
280 else
281 throw std::runtime_error("QuestLibSim: Unable to get expectation value");
282
283 return 0;
284 }
285
286 // measurement functions
287
288 int Measure(void *sim, int qubit)
289 {
290 if (initialized)
291 return fMeasure(sim, qubit);
292 else
293 throw std::runtime_error("QuestLibSim: Unable to measure qubit");
294
295 return 0;
296 }
297
298 long long int MeasureQubits(void *sim, int *qubits, int numQubits)
299 {
300 if (initialized)
301 return fMeasureQubits(sim, qubits, numQubits);
302 else
303 throw std::runtime_error("QuestLibSim: Unable to measure qubits");
304
305 return 0;
306 }
307
308 // single-qubit gate functions
309
310 void ApplyP(void *sim, int qubit, double angle)
311 {
312 if (initialized)
313 fApplyP(sim, qubit, angle);
314 else
315 throw std::runtime_error("QuestLibSim: Unable to apply P gate");
316 }
317
318 void ApplyX(void *sim, int qubit)
319 {
320 if (initialized)
321 fApplyX(sim, qubit);
322 else
323 throw std::runtime_error("QuestLibSim: Unable to apply X gate");
324 }
325
326 void ApplyY(void *sim, int qubit)
327 {
328 if (initialized)
329 fApplyY(sim, qubit);
330 else
331 throw std::runtime_error("QuestLibSim: Unable to apply Y gate");
332 }
333
334 void ApplyZ(void *sim, int qubit)
335 {
336 if (initialized)
337 fApplyZ(sim, qubit);
338 else
339 throw std::runtime_error("QuestLibSim: Unable to apply Z gate");
340 }
341
342 void ApplyH(void *sim, int qubit)
343 {
344 if (initialized)
345 fApplyH(sim, qubit);
346 else
347 throw std::runtime_error("QuestLibSim: Unable to apply H gate");
348 }
349
350 void ApplyS(void *sim, int qubit)
351 {
352 if (initialized)
353 fApplyS(sim, qubit);
354 else
355 throw std::runtime_error("QuestLibSim: Unable to apply S gate");
356 }
357
358 void ApplyT(void *sim, int qubit)
359 {
360 if (initialized)
361 fApplyT(sim, qubit);
362 else
363 throw std::runtime_error("QuestLibSim: Unable to apply T gate");
364 }
365
366 void ApplySdg(void *sim, int qubit)
367 {
368 if (initialized)
369 fApplySdg(sim, qubit);
370 else
371 throw std::runtime_error("QuestLibSim: Unable to apply Sdg gate");
372 }
373
374 void ApplyTdg(void *sim, int qubit)
375 {
376 if (initialized)
377 fApplyTdg(sim, qubit);
378 else
379 throw std::runtime_error("QuestLibSim: Unable to apply Tdg gate");
380 }
381
382 void ApplySx(void *sim, int qubit)
383 {
384 if (initialized)
385 fApplySx(sim, qubit);
386 else
387 throw std::runtime_error("QuestLibSim: Unable to apply Sx gate");
388 }
389
390 void ApplySxDg(void *sim, int qubit)
391 {
392 if (initialized)
393 fApplySxDg(sim, qubit);
394 else
395 throw std::runtime_error("QuestLibSim: Unable to apply SxDg gate");
396 }
397
398 void ApplyK(void *sim, int qubit)
399 {
400 if (initialized)
401 fApplyK(sim, qubit);
402 else
403 throw std::runtime_error("QuestLibSim: Unable to apply K gate");
404 }
405
406 // single-qubit rotation gate functions
407
408 void ApplyRx(void *sim, int qubit, double angle)
409 {
410 if (initialized)
411 fApplyRx(sim, qubit, angle);
412 else
413 throw std::runtime_error("QuestLibSim: Unable to apply Rx gate");
414 }
415
416 void ApplyRy(void *sim, int qubit, double angle)
417 {
418 if (initialized)
419 fApplyRy(sim, qubit, angle);
420 else
421 throw std::runtime_error("QuestLibSim: Unable to apply Ry gate");
422 }
423
424 void ApplyRz(void *sim, int qubit, double angle)
425 {
426 if (initialized)
427 fApplyRz(sim, qubit, angle);
428 else
429 throw std::runtime_error("QuestLibSim: Unable to apply Rz gate");
430 }
431
432 void ApplyU(void *sim, int qubit, double theta, double phi, double lambda, double gamma)
433 {
434 if (initialized)
435 fApplyU(sim, qubit, theta, phi, lambda, gamma);
436 else
437 throw std::runtime_error("QuestLibSim: Unable to apply U gate");
438 }
439
440 // two-qubit gate functions
441
442 void ApplyCS(void *sim, int control, int target)
443 {
444 if (initialized)
445 fApplyCS(sim, control, target);
446 else
447 throw std::runtime_error("QuestLibSim: Unable to apply CS gate");
448 }
449
450 void ApplyCT(void *sim, int control, int target)
451 {
452 if (initialized)
453 fApplyCT(sim, control, target);
454 else
455 throw std::runtime_error("QuestLibSim: Unable to apply CT gate");
456 }
457
458 void ApplyCH(void *sim, int control, int target)
459 {
460 if (initialized)
461 fApplyCH(sim, control, target);
462 else
463 throw std::runtime_error("QuestLibSim: Unable to apply CH gate");
464 }
465
466 void ApplySwap(void *sim, int qubit1, int qubit2)
467 {
468 if (initialized)
469 fApplySwap(sim, qubit1, qubit2);
470 else
471 throw std::runtime_error("QuestLibSim: Unable to apply Swap gate");
472 }
473
474 void ApplyCX(void *sim, int control, int target)
475 {
476 if (initialized)
477 fApplyCX(sim, control, target);
478 else
479 throw std::runtime_error("QuestLibSim: Unable to apply CX gate");
480 }
481
482 void ApplyCY(void *sim, int control, int target)
483 {
484 if (initialized)
485 fApplyCY(sim, control, target);
486 else
487 throw std::runtime_error("QuestLibSim: Unable to apply CY gate");
488 }
489
490 void ApplyCZ(void *sim, int control, int target)
491 {
492 if (initialized)
493 fApplyCZ(sim, control, target);
494 else
495 throw std::runtime_error("QuestLibSim: Unable to apply CZ gate");
496 }
497
498 void ApplyCRx(void *sim, int control, int target, double angle)
499 {
500 if (initialized)
501 fApplyCRx(sim, control, target, angle);
502 else
503 throw std::runtime_error("QuestLibSim: Unable to apply CRx gate");
504 }
505
506 void ApplyCRy(void *sim, int control, int target, double angle)
507 {
508 if (initialized)
509 fApplyCRy(sim, control, target, angle);
510 else
511 throw std::runtime_error("QuestLibSim: Unable to apply CRy gate");
512 }
513
514 void ApplyCRz(void *sim, int control, int target, double angle)
515 {
516 if (initialized)
517 fApplyCRz(sim, control, target, angle);
518 else
519 throw std::runtime_error("QuestLibSim: Unable to apply CRz gate");
520 }
521
522 void ApplyCP(void *sim, int control, int target, double angle)
523 {
524 if (initialized)
525 fApplyCP(sim, control, target, angle);
526 else
527 throw std::runtime_error("QuestLibSim: Unable to apply CP gate");
528 }
529
530 void ApplyCU(void *sim, int control, int target, double theta, double phi, double lambda, double gamma)
531 {
532 if (initialized)
533 fApplyCU(sim, control, target, theta, phi, lambda, gamma);
534 else
535 throw std::runtime_error("QuestLibSim: Unable to apply CU gate");
536 }
537
538 void ApplyCSx(void *sim, int control, int target)
539 {
540 if (initialized)
541 fApplyCSx(sim, control, target);
542 else
543 throw std::runtime_error("QuestLibSim: Unable to apply CSx gate");
544 }
545
546 void ApplyCSxDg(void *sim, int control, int target)
547 {
548 if (initialized)
549 fApplyCSxDg(sim, control, target);
550 else
551 throw std::runtime_error("QuestLibSim: Unable to apply CSxDg gate");
552 }
553
554 // three-qubit gate functions
555
556 void ApplyCSwap(void *sim, int control, int qubit1, int qubit2)
557 {
558 if (initialized)
559 fApplyCSwap(sim, control, qubit1, qubit2);
560 else
561 throw std::runtime_error("QuestLibSim: Unable to apply CSwap gate");
562 }
563
564 void ApplyCCX(void *sim, int control1, int control2, int target)
565 {
566 if (initialized)
567 fApplyCCX(sim, control1, control2, target);
568 else
569 throw std::runtime_error("QuestLibSim: Unable to apply CCX gate");
570 }
571
572 // amplitude functions
573
574 bool GetAmplitudes(void *sim, std::vector<std::complex<double>> &amplitudes) const
575 {
576 if (initialized)
577 {
578 if (IsDoublePrecision())
579 return fGetAmplitudes(sim, amplitudes.data(), amplitudes.size() * sizeof(std::complex<double>)) == 1;
580 else
581 {
582 std::vector<std::complex<float>> amplitudesSingle(amplitudes.size());
583 if (fGetAmplitudes(sim, amplitudesSingle.data(), amplitudesSingle.size() * sizeof(std::complex<float>)) == 1)
584 {
585 for (size_t i = 0; i < amplitudes.size(); ++i)
586 amplitudes[i] = std::complex<double>(static_cast<double>(amplitudesSingle[i].real()), static_cast<double>(amplitudesSingle[i].imag()));
587
588 return true;
589 }
590 }
591 }
592 else
593 throw std::runtime_error("QuestLibSim: Unable to get amplitudes");
594
595 return false;
596 }
597
598 bool GetAmplitude(void *sim, long long int index, std::complex<double> &amplitude) const
599 {
600 if (initialized)
601 {
602 if (IsDoublePrecision())
603 return fGetAmplitude(sim, index, &amplitude, sizeof(std::complex<double>)) == 1;
604 else
605 {
606 std::complex<float> ampSingle;
607 if (fGetAmplitude(sim, index, &ampSingle, sizeof(std::complex<float>)) == 1)
608 {
609 amplitude = std::complex<double>(static_cast<double>(ampSingle.real()), static_cast<double>(ampSingle.imag()));
610 return true;
611 }
612 }
613 }
614 else
615 throw std::runtime_error("QuestLibSim: Unable to get amplitude");
616 return false;
617 }
618
619 bool IsDoublePrecision() const
620 {
621 if (initialized)
622 return fIsDoublePrecision() == 1;
623 else
624 throw std::runtime_error("QuestLibSim: Unable to check double precision");
625 return false;
626 }
627
628 private:
629 bool initialized = false;
630
631 void (*fInitialize)() = nullptr;
632 void (*fFinalize)() = nullptr;
633
634 unsigned long int (*fCreateSimulator)(int) = nullptr;
635 void (*fDestroySimulator)(unsigned long int) = nullptr;
636 unsigned long int (*fCloneSimulator)(void *) = nullptr;
637 void *(*fGetSimulator)(unsigned long int) = nullptr;
638
639 int (*fGetNumQubits)(void *) = nullptr;
640 double (*fGetQubitProbability0)(void *, int) = nullptr;
641 double (*fGetQubitProbability1)(void *, int) = nullptr;
642 double (*fGetOutcomeProbability)(void *, long long int) = nullptr;
643 double (*fGetExpectationValue)(void *, const char *) = nullptr;
644
645 int (*fMeasure)(void *, int) = nullptr;
646 long long int (*fMeasureQubits)(void *, int *, int) = nullptr;
647
648 void (*fApplyP)(void *, int, double) = nullptr;
649 void (*fApplyX)(void *, int) = nullptr;
650 void (*fApplyY)(void *, int) = nullptr;
651 void (*fApplyZ)(void *, int) = nullptr;
652 void (*fApplyH)(void *, int) = nullptr;
653 void (*fApplyS)(void *, int) = nullptr;
654 void (*fApplyT)(void *, int) = nullptr;
655 void (*fApplyRx)(void *, int, double) = nullptr;
656 void (*fApplyRy)(void *, int, double) = nullptr;
657 void (*fApplyRz)(void *, int, double) = nullptr;
658
659 void (*fApplyCS)(void *, int, int) = nullptr;
660 void (*fApplyCT)(void *, int, int) = nullptr;
661 void (*fApplyCH)(void *, int, int) = nullptr;
662 void (*fApplySwap)(void *, int, int) = nullptr;
663 void (*fApplyCX)(void *, int, int) = nullptr;
664 void (*fApplyCY)(void *, int, int) = nullptr;
665 void (*fApplyCZ)(void *, int, int) = nullptr;
666 void (*fApplyCRx)(void *, int, int, double) = nullptr;
667 void (*fApplyCRy)(void *, int, int, double) = nullptr;
668 void (*fApplyCRz)(void *, int, int, double) = nullptr;
669
670 void (*fApplyCSwap)(void *, int, int, int) = nullptr;
671 void (*fApplyCCX)(void *, int, int, int) = nullptr;
672
673 void (*fApplySdg)(void *, int) = nullptr;
674 void (*fApplyTdg)(void *, int) = nullptr;
675 void (*fApplySx)(void *, int) = nullptr;
676 void (*fApplySxDg)(void *, int) = nullptr;
677 void (*fApplyK)(void *, int) = nullptr;
678
679 void (*fApplyU)(void *, int, double, double, double, double) = nullptr;
680 void (*fApplyCU)(void *, int, int, double, double, double, double) = nullptr;
681 void (*fApplyCP)(void *, int, int, double) = nullptr;
682 void (*fApplyCSx)(void *, int, int) = nullptr;
683 void (*fApplyCSxDg)(void *, int, int) = nullptr;
684 int (*fGetAmplitudes)(void *, void *, unsigned long long int) = nullptr;
685 int (*fGetAmplitude)(void *, long long int, void *, unsigned long long int) = nullptr;
686 int (*fIsDoublePrecision)() = nullptr;
687};
688
689} // namespace Simulators
690
691#endif // _QUEST_LIB_SIM_H_
unsigned long int CreateSimulator(int nrQubits)
void ApplyCRz(void *sim, int control, int target, double angle)
bool IsDoublePrecision() const
QuestLibSim(QuestLibSim &&)=default
void ApplyRy(void *sim, int qubit, double angle)
void ApplyU(void *sim, int qubit, double theta, double phi, double lambda, double gamma)
void ApplyCS(void *sim, int control, int target)
void ApplyCZ(void *sim, int control, int target)
void ApplyCH(void *sim, int control, int target)
bool GetAmplitude(void *sim, long long int index, std::complex< double > &amplitude) const
void ApplyCRx(void *sim, int control, int target, double angle)
void ApplyTdg(void *sim, int qubit)
int Measure(void *sim, int qubit)
void ApplyCP(void *sim, int control, int target, double angle)
void ApplyCX(void *sim, int control, int target)
void ApplyX(void *sim, int qubit)
void ApplyRz(void *sim, int qubit, double angle)
void DestroySimulator(unsigned long int simHandle)
void ApplyCSxDg(void *sim, int control, int target)
void ApplyK(void *sim, int qubit)
void ApplyH(void *sim, int qubit)
void ApplySx(void *sim, int qubit)
double GetQubitProbability1(void *sim, int qubit) const
long long int MeasureQubits(void *sim, int *qubits, int numQubits)
void ApplyCY(void *sim, int control, int target)
void ApplyCSwap(void *sim, int control, int qubit1, int qubit2)
void ApplyS(void *sim, int qubit)
void ApplyCU(void *sim, int control, int target, double theta, double phi, double lambda, double gamma)
void ApplyZ(void *sim, int qubit)
int GetNumQubits(void *sim) const
double GetQubitProbability0(void *sim, int qubit) const
void ApplySdg(void *sim, int qubit)
double GetExpectationValue(void *sim, const char *pauliStr) const
void ApplySxDg(void *sim, int qubit)
QuestLibSim(const QuestLibSim &)=delete
bool Init(const char *libName) noexcept override
Definition QuestLibSim.h:47
void ApplySwap(void *sim, int qubit1, int qubit2)
void ApplyCSx(void *sim, int control, int target)
unsigned long int CloneSimulator(void *sim)
void ApplyCCX(void *sim, int control1, int control2, int target)
QuestLibSim & operator=(QuestLibSim &&)=default
double GetOutcomeProbability(void *sim, long long int outcome) const
static void CheckFunction(void *func, int line) noexcept
void ApplyP(void *sim, int qubit, double angle)
bool GetAmplitudes(void *sim, std::vector< std::complex< double > > &amplitudes) const
void ApplyT(void *sim, int qubit)
QuestLibSim & operator=(const QuestLibSim &)=delete
void ApplyRx(void *sim, int qubit, double angle)
void * GetSimulator(unsigned long int simHandle)
void ApplyY(void *sim, int qubit)
void ApplyCT(void *sim, int control, int target)
void ApplyCRy(void *sim, int control, int target, double angle)
void * GetFunction(const char *funcName) noexcept
Definition Library.h:112
virtual bool Init(const char *libName) noexcept
Definition Library.h:83
Bounded online routing based on current physical bond dimensions.