Maestro 0.1.0
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Interface.cpp File Reference
#include "Interface.h"
#include "../Simulators/Factory.h"
#include "Maestro.h"
#include "Json.h"
#include <boost/json/src.hpp>
#include <atomic>
#include <memory>
#include "../Utils/LogFile.h"
#include "../qasm/QasmCirc.h"

Go to the source code of this file.

Functions

void * GetMaestroObject ()
void * GetMaestroObjectWithMute ()
unsigned long int CreateSimpleSimulator (int nrQubits)
void DestroySimpleSimulator (unsigned long int simHandle)
int RemoveAllOptimizationSimulatorsAndAdd (unsigned long int simHandle, int simType, int simExecType)
int AddOptimizationSimulator (unsigned long int simHandle, int simType, int simExecType)
char * SimpleExecute (unsigned long int simpleSim, const char *circuitStr, const char *jsonConfig)
void FreeResult (char *result)
unsigned long int CreateSimulator (int simType, int simExecType)
void * GetSimulator (unsigned long int simHandle)
void DestroySimulator (unsigned long int simHandle)
int ApplyX (void *sim, int qubit)
int ApplyY (void *sim, int qubit)
int ApplyZ (void *sim, int qubit)
int ApplyH (void *sim, int qubit)
int ApplyS (void *sim, int qubit)
int ApplySDG (void *sim, int qubit)
int ApplyT (void *sim, int qubit)
int ApplyTDG (void *sim, int qubit)
int ApplySX (void *sim, int qubit)
int ApplySXDG (void *sim, int qubit)
int ApplyK (void *sim, int qubit)
int ApplyP (void *sim, int qubit, double theta)
int ApplyRx (void *sim, int qubit, double theta)
int ApplyRy (void *sim, int qubit, double theta)
int ApplyRz (void *sim, int qubit, double theta)
int ApplyU (void *sim, int qubit, double theta, double phi, double lambda, double gamma)
int ApplyCX (void *sim, int controlQubit, int targetQubit)
int ApplyCY (void *sim, int controlQubit, int targetQubit)
int ApplyCZ (void *sim, int controlQubit, int targetQubit)
int ApplyCH (void *sim, int controlQubit, int targetQubit)
int ApplyCSX (void *sim, int controlQubit, int targetQubit)
int ApplyCSXDG (void *sim, int controlQubit, int targetQubit)
int ApplyCP (void *sim, int controlQubit, int targetQubit, double theta)
int ApplyCRx (void *sim, int controlQubit, int targetQubit, double theta)
int ApplyCRy (void *sim, int controlQubit, int targetQubit, double theta)
int ApplyCRz (void *sim, int controlQubit, int targetQubit, double theta)
int ApplyCCX (void *sim, int controlQubit1, int controlQubit2, int targetQubit)
int ApplySwap (void *sim, int qubit1, int qubit2)
int ApplyCSwap (void *sim, int controlQubit, int qubit1, int qubit2)
int ApplyCU (void *sim, int controlQubit, int targetQubit, double theta, double phi, double lambda, double gamma)
int InitializeSimulator (void *sim)
int ResetSimulator (void *sim)
int ConfigureSimulator (void *sim, const char *key, const char *value)
char * GetConfiguration (void *sim, const char *key)
unsigned long int AllocateQubits (void *sim, unsigned long int nrQubits)
unsigned long int GetNumberOfQubits (void *sim)
int ClearSimulator (void *sim)
unsigned long long int Measure (void *sim, const unsigned long int *qubits, unsigned long int nrQubits)
int ApplyReset (void *sim, const unsigned long int *qubits, unsigned long int nrQubits)
double Probability (void *sim, unsigned long long int outcome)
void FreeDoubleVector (double *vec)
void FreeULLIVector (unsigned long long int *vec)
double * Amplitude (void *sim, unsigned long long int outcome)
double * AllProbabilities (void *sim)
double * Probabilities (void *sim, const unsigned long long int *qubits, unsigned long int nrQubits)
unsigned long long int * SampleCounts (void *sim, const unsigned long long int *qubits, unsigned long int nrQubits, unsigned long int shots)
int GetSimulatorType (void *sim)
int GetSimulationType (void *sim)
int FlushSimulator (void *sim)
int SaveStateToInternalDestructive (void *sim)
int RestoreInternalDestructiveSavedState (void *sim)
int SaveState (void *sim)
int RestoreState (void *sim)
int SetMultithreading (void *sim, int multithreading)
int GetMultithreading (void *sim)
int IsQcsim (void *sim)
unsigned long long int MeasureNoCollapse (void *sim)

Variables

static std::atomic_bool isInitialized = false
static std::unique_ptr< MaestromaestroInstance = nullptr

Function Documentation

◆ AddOptimizationSimulator()

int AddOptimizationSimulator ( unsigned long int simHandle,
int simType,
int simExecType )

Definition at line 89 of file Interface.cpp.

◆ AllocateQubits()

unsigned long int AllocateQubits ( void * sim,
unsigned long int nrQubits )

Definition at line 630 of file Interface.cpp.

◆ AllProbabilities()

double * AllProbabilities ( void * sim)

Definition at line 707 of file Interface.cpp.

◆ Amplitude()

double * Amplitude ( void * sim,
unsigned long long int outcome )

Definition at line 695 of file Interface.cpp.

◆ ApplyCCX()

int ApplyCCX ( void * sim,
int controlQubit1,
int controlQubit2,
int targetQubit )

Definition at line 551 of file Interface.cpp.

◆ ApplyCH()

int ApplyCH ( void * sim,
int controlQubit,
int targetQubit )

Definition at line 484 of file Interface.cpp.

◆ ApplyCP()

int ApplyCP ( void * sim,
int controlQubit,
int targetQubit,
double theta )

Definition at line 511 of file Interface.cpp.

◆ ApplyCRx()

int ApplyCRx ( void * sim,
int controlQubit,
int targetQubit,
double theta )

Definition at line 521 of file Interface.cpp.

◆ ApplyCRy()

int ApplyCRy ( void * sim,
int controlQubit,
int targetQubit,
double theta )

Definition at line 531 of file Interface.cpp.

◆ ApplyCRz()

int ApplyCRz ( void * sim,
int controlQubit,
int targetQubit,
double theta )

Definition at line 541 of file Interface.cpp.

◆ ApplyCSwap()

int ApplyCSwap ( void * sim,
int controlQubit,
int qubit1,
int qubit2 )

Definition at line 570 of file Interface.cpp.

◆ ApplyCSX()

int ApplyCSX ( void * sim,
int controlQubit,
int targetQubit )

Definition at line 493 of file Interface.cpp.

◆ ApplyCSXDG()

int ApplyCSXDG ( void * sim,
int controlQubit,
int targetQubit )

Definition at line 502 of file Interface.cpp.

◆ ApplyCU()

int ApplyCU ( void * sim,
int controlQubit,
int targetQubit,
double theta,
double phi,
double lambda,
double gamma )

Definition at line 579 of file Interface.cpp.

◆ ApplyCX()

int ApplyCX ( void * sim,
int controlQubit,
int targetQubit )

Definition at line 457 of file Interface.cpp.

◆ ApplyCY()

int ApplyCY ( void * sim,
int controlQubit,
int targetQubit )

Definition at line 466 of file Interface.cpp.

◆ ApplyCZ()

int ApplyCZ ( void * sim,
int controlQubit,
int targetQubit )

Definition at line 475 of file Interface.cpp.

◆ ApplyH()

int ApplyH ( void * sim,
int qubit )

Definition at line 339 of file Interface.cpp.

◆ ApplyK()

int ApplyK ( void * sim,
int qubit )

Definition at line 402 of file Interface.cpp.

◆ ApplyP()

int ApplyP ( void * sim,
int qubit,
double theta )

Definition at line 411 of file Interface.cpp.

◆ ApplyReset()

int ApplyReset ( void * sim,
const unsigned long int * qubits,
unsigned long int nrQubits )

Definition at line 667 of file Interface.cpp.

◆ ApplyRx()

int ApplyRx ( void * sim,
int qubit,
double theta )

Definition at line 420 of file Interface.cpp.

◆ ApplyRy()

int ApplyRy ( void * sim,
int qubit,
double theta )

Definition at line 429 of file Interface.cpp.

◆ ApplyRz()

int ApplyRz ( void * sim,
int qubit,
double theta )

Definition at line 438 of file Interface.cpp.

◆ ApplyS()

int ApplyS ( void * sim,
int qubit )

Definition at line 348 of file Interface.cpp.

◆ ApplySDG()

int ApplySDG ( void * sim,
int qubit )

Definition at line 357 of file Interface.cpp.

◆ ApplySwap()

int ApplySwap ( void * sim,
int qubit1,
int qubit2 )

Definition at line 561 of file Interface.cpp.

◆ ApplySX()

int ApplySX ( void * sim,
int qubit )

Definition at line 384 of file Interface.cpp.

◆ ApplySXDG()

int ApplySXDG ( void * sim,
int qubit )

Definition at line 393 of file Interface.cpp.

◆ ApplyT()

int ApplyT ( void * sim,
int qubit )

Definition at line 366 of file Interface.cpp.

◆ ApplyTDG()

int ApplyTDG ( void * sim,
int qubit )

Definition at line 375 of file Interface.cpp.

◆ ApplyU()

int ApplyU ( void * sim,
int qubit,
double theta,
double phi,
double lambda,
double gamma )

Definition at line 447 of file Interface.cpp.

◆ ApplyX()

int ApplyX ( void * sim,
int qubit )

Definition at line 311 of file Interface.cpp.

◆ ApplyY()

int ApplyY ( void * sim,
int qubit )

Definition at line 321 of file Interface.cpp.

◆ ApplyZ()

int ApplyZ ( void * sim,
int qubit )

Definition at line 330 of file Interface.cpp.

◆ ClearSimulator()

int ClearSimulator ( void * sim)

Definition at line 648 of file Interface.cpp.

◆ ConfigureSimulator()

int ConfigureSimulator ( void * sim,
const char * key,
const char * value )

Definition at line 605 of file Interface.cpp.

◆ CreateSimpleSimulator()

unsigned long int CreateSimpleSimulator ( int nrQubits)

Definition at line 64 of file Interface.cpp.

◆ CreateSimulator()

unsigned long int CreateSimulator ( int simType,
int simExecType )

Definition at line 290 of file Interface.cpp.

◆ DestroySimpleSimulator()

void DestroySimpleSimulator ( unsigned long int simHandle)

Definition at line 71 of file Interface.cpp.

◆ DestroySimulator()

void DestroySimulator ( unsigned long int simHandle)

Definition at line 305 of file Interface.cpp.

◆ FlushSimulator()

int FlushSimulator ( void * sim)

Definition at line 768 of file Interface.cpp.

◆ FreeDoubleVector()

void FreeDoubleVector ( double * vec)

Definition at line 685 of file Interface.cpp.

◆ FreeResult()

void FreeResult ( char * result)

Definition at line 285 of file Interface.cpp.

◆ FreeULLIVector()

void FreeULLIVector ( unsigned long long int * vec)

Definition at line 690 of file Interface.cpp.

◆ GetConfiguration()

char * GetConfiguration ( void * sim,
const char * key )

Definition at line 614 of file Interface.cpp.

◆ GetMaestroObject()

void * GetMaestroObject ( )

Definition at line 32 of file Interface.cpp.

◆ GetMaestroObjectWithMute()

void * GetMaestroObjectWithMute ( )

Definition at line 48 of file Interface.cpp.

◆ GetMultithreading()

int GetMultithreading ( void * sim)

Definition at line 816 of file Interface.cpp.

◆ GetNumberOfQubits()

unsigned long int GetNumberOfQubits ( void * sim)

Definition at line 640 of file Interface.cpp.

◆ GetSimulationType()

int GetSimulationType ( void * sim)

Definition at line 761 of file Interface.cpp.

◆ GetSimulator()

void * GetSimulator ( unsigned long int simHandle)

Definition at line 299 of file Interface.cpp.

◆ GetSimulatorType()

int GetSimulatorType ( void * sim)

Definition at line 754 of file Interface.cpp.

◆ InitializeSimulator()

int InitializeSimulator ( void * sim)

Definition at line 589 of file Interface.cpp.

◆ IsQcsim()

int IsQcsim ( void * sim)

Definition at line 823 of file Interface.cpp.

◆ Measure()

unsigned long long int Measure ( void * sim,
const unsigned long int * qubits,
unsigned long int nrQubits )

Definition at line 656 of file Interface.cpp.

◆ MeasureNoCollapse()

unsigned long long int MeasureNoCollapse ( void * sim)

Definition at line 830 of file Interface.cpp.

◆ Probabilities()

double * Probabilities ( void * sim,
const unsigned long long int * qubits,
unsigned long int nrQubits )

Definition at line 718 of file Interface.cpp.

◆ Probability()

double Probability ( void * sim,
unsigned long long int outcome )

Definition at line 677 of file Interface.cpp.

◆ RemoveAllOptimizationSimulatorsAndAdd()

int RemoveAllOptimizationSimulatorsAndAdd ( unsigned long int simHandle,
int simType,
int simExecType )

Definition at line 79 of file Interface.cpp.

◆ ResetSimulator()

int ResetSimulator ( void * sim)

Definition at line 597 of file Interface.cpp.

◆ RestoreInternalDestructiveSavedState()

int RestoreInternalDestructiveSavedState ( void * sim)

Definition at line 784 of file Interface.cpp.

◆ RestoreState()

int RestoreState ( void * sim)

Definition at line 800 of file Interface.cpp.

◆ SampleCounts()

unsigned long long int * SampleCounts ( void * sim,
const unsigned long long int * qubits,
unsigned long int nrQubits,
unsigned long int shots )

Definition at line 733 of file Interface.cpp.

◆ SaveState()

int SaveState ( void * sim)

Definition at line 792 of file Interface.cpp.

◆ SaveStateToInternalDestructive()

int SaveStateToInternalDestructive ( void * sim)

Definition at line 776 of file Interface.cpp.

◆ SetMultithreading()

int SetMultithreading ( void * sim,
int multithreading )

Definition at line 808 of file Interface.cpp.

◆ SimpleExecute()

char * SimpleExecute ( unsigned long int simpleSim,
const char * circuitStr,
const char * jsonConfig )

Definition at line 99 of file Interface.cpp.

Variable Documentation

◆ isInitialized

std::atomic_bool isInitialized = false
static

Definition at line 29 of file Interface.cpp.

◆ maestroInstance

std::unique_ptr<Maestro> maestroInstance = nullptr
static

Definition at line 30 of file Interface.cpp.