Maestro 0.3.1
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 <atomic>
#include <memory>
#include "../Utils/LogFile.h"
#include "../qasm/QasmCirc.h"
Include dependency graph for Interface.cpp:

Go to the source code of this file.

Functions

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

Variables

static std::atomic_bool isInitialized {false}
static std::unique_ptr< MaestromaestroInstance

Function Documentation

◆ AddOptimizationSimulator()

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

Definition at line 98 of file Interface.cpp.

References maestroInstance.

◆ AllocateQubits()

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

Definition at line 933 of file Interface.cpp.

References Simulators::IState::AllocateQubits().

◆ AllProbabilities()

double * AllProbabilities ( void * sim)

Definition at line 1026 of file Interface.cpp.

References Simulators::IState::AllProbabilities().

◆ Amplitude()

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

Definition at line 1012 of file Interface.cpp.

References Simulators::IState::Amplitude().

◆ ApplyCCX()

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

Definition at line 840 of file Interface.cpp.

References Simulators::ISimulator::ApplyCCX().

◆ ApplyCH()

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

Definition at line 763 of file Interface.cpp.

References Simulators::ISimulator::ApplyCH().

◆ ApplyCP()

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

Definition at line 796 of file Interface.cpp.

References Simulators::ISimulator::ApplyCP().

◆ ApplyCRx()

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

Definition at line 807 of file Interface.cpp.

References Simulators::ISimulator::ApplyCRx().

◆ ApplyCRy()

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

Definition at line 818 of file Interface.cpp.

References Simulators::ISimulator::ApplyCRy().

◆ ApplyCRz()

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

Definition at line 829 of file Interface.cpp.

References Simulators::ISimulator::ApplyCRz().

◆ ApplyCSwap()

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

Definition at line 863 of file Interface.cpp.

References Simulators::ISimulator::ApplyCSwap().

◆ ApplyCSX()

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

Definition at line 774 of file Interface.cpp.

References Simulators::ISimulator::ApplyCSx().

◆ ApplyCSXDG()

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

Definition at line 785 of file Interface.cpp.

References Simulators::ISimulator::ApplyCSxDAG().

◆ ApplyCU()

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

Definition at line 874 of file Interface.cpp.

References Simulators::ISimulator::ApplyCU().

◆ ApplyCX()

◆ ApplyCY()

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

Definition at line 741 of file Interface.cpp.

References Simulators::ISimulator::ApplyCY().

◆ ApplyCZ()

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

Definition at line 752 of file Interface.cpp.

References Simulators::ISimulator::ApplyCZ().

◆ ApplyH()

◆ ApplyK()

int ApplyK ( void * sim,
int qubit )

Definition at line 663 of file Interface.cpp.

References Simulators::ISimulator::ApplyK().

◆ ApplyP()

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

Definition at line 674 of file Interface.cpp.

References Simulators::ISimulator::ApplyP().

◆ ApplyReset()

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

Definition at line 976 of file Interface.cpp.

◆ ApplyRx()

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

Definition at line 685 of file Interface.cpp.

References Simulators::ISimulator::ApplyRx().

◆ ApplyRy()

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

Definition at line 696 of file Interface.cpp.

References Simulators::ISimulator::ApplyRy().

◆ ApplyRz()

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

Definition at line 707 of file Interface.cpp.

References Simulators::ISimulator::ApplyRz().

◆ ApplyS()

int ApplyS ( void * sim,
int qubit )

◆ ApplySDG()

int ApplySDG ( void * sim,
int qubit )

◆ ApplySwap()

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

Definition at line 852 of file Interface.cpp.

References Simulators::ISimulator::ApplySwap().

◆ ApplySX()

int ApplySX ( void * sim,
int qubit )

Definition at line 641 of file Interface.cpp.

References Simulators::ISimulator::ApplySx().

◆ ApplySXDG()

int ApplySXDG ( void * sim,
int qubit )

Definition at line 652 of file Interface.cpp.

References Simulators::ISimulator::ApplySxDAG().

◆ ApplyT()

int ApplyT ( void * sim,
int qubit )

Definition at line 619 of file Interface.cpp.

References Simulators::ISimulator::ApplyT().

◆ ApplyTDG()

int ApplyTDG ( void * sim,
int qubit )

Definition at line 630 of file Interface.cpp.

References Simulators::ISimulator::ApplyTDG().

◆ ApplyU()

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

Definition at line 718 of file Interface.cpp.

References Simulators::ISimulator::ApplyU().

◆ ApplyX()

int ApplyX ( void * sim,
int qubit )

◆ ApplyY()

int ApplyY ( void * sim,
int qubit )

Definition at line 564 of file Interface.cpp.

References Simulators::ISimulator::ApplyY().

◆ ApplyZ()

int ApplyZ ( void * sim,
int qubit )

Definition at line 575 of file Interface.cpp.

References Simulators::ISimulator::ApplyZ().

◆ ClearSimulator()

int ClearSimulator ( void * sim)

Definition at line 954 of file Interface.cpp.

References Simulators::IState::Clear().

◆ ConfigureSimulator()

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

Definition at line 906 of file Interface.cpp.

References Simulators::IState::Configure().

◆ CreateSimpleSimulator()

unsigned long int CreateSimpleSimulator ( int nrQubits)

Definition at line 68 of file Interface.cpp.

References maestroInstance.

◆ CreateSimulator()

unsigned long int CreateSimulator ( int simType,
int simExecType )

Definition at line 525 of file Interface.cpp.

References maestroInstance.

◆ DestroySimpleSimulator()

void DestroySimpleSimulator ( unsigned long int simHandle)

Definition at line 77 of file Interface.cpp.

References maestroInstance.

◆ DestroySimulator()

void DestroySimulator ( unsigned long int simHandle)

Definition at line 544 of file Interface.cpp.

References maestroInstance.

◆ FlushSimulator()

int FlushSimulator ( void * sim)

Definition at line 1097 of file Interface.cpp.

References Simulators::IState::Flush().

◆ FreeDoubleVector()

void FreeDoubleVector ( double * vec)

Definition at line 998 of file Interface.cpp.

◆ FreeResult()

void FreeResult ( char * result)

Definition at line 518 of file Interface.cpp.

◆ FreeULLIVector()

void FreeULLIVector ( unsigned long long int * vec)

Definition at line 1005 of file Interface.cpp.

◆ GetConfiguration()

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

Definition at line 916 of file Interface.cpp.

References Simulators::IState::GetConfiguration().

◆ GetMaestroObject()

void * GetMaestroObject ( )

◆ GetMaestroObjectWithMute()

void * GetMaestroObjectWithMute ( )

◆ GetMultithreading()

int GetMultithreading ( void * sim)

Definition at line 1157 of file Interface.cpp.

References Simulators::IState::GetMultithreading().

◆ GetNumberOfQubits()

unsigned long int GetNumberOfQubits ( void * sim)

Definition at line 944 of file Interface.cpp.

References Simulators::IState::GetNumberOfQubits().

◆ GetSimulationType()

int GetSimulationType ( void * sim)

◆ GetSimulator()

void * GetSimulator ( unsigned long int simHandle)

Definition at line 536 of file Interface.cpp.

References maestroInstance.

◆ GetSimulatorType()

int GetSimulatorType ( void * sim)

Definition at line 1079 of file Interface.cpp.

◆ InitializeSimulator()

int InitializeSimulator ( void * sim)

Definition at line 886 of file Interface.cpp.

References Simulators::IState::Initialize().

◆ IsQcsim()

int IsQcsim ( void * sim)

Definition at line 1166 of file Interface.cpp.

References Simulators::IState::IsQcsim().

◆ Measure()

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

Definition at line 964 of file Interface.cpp.

◆ MeasureNoCollapse()

unsigned long long int MeasureNoCollapse ( void * sim)

Definition at line 1175 of file Interface.cpp.

◆ Probabilities()

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

Definition at line 1039 of file Interface.cpp.

◆ Probability()

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

Definition at line 988 of file Interface.cpp.

References Simulators::IState::Probability().

◆ RemoveAllOptimizationSimulatorsAndAdd()

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

Definition at line 86 of file Interface.cpp.

References maestroInstance.

◆ ResetSimulator()

int ResetSimulator ( void * sim)

Definition at line 896 of file Interface.cpp.

References Simulators::IState::Reset().

◆ RestoreInternalDestructiveSavedState()

int RestoreInternalDestructiveSavedState ( void * sim)

◆ RestoreState()

int RestoreState ( void * sim)

Definition at line 1137 of file Interface.cpp.

References Simulators::IState::RestoreState().

◆ 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 1054 of file Interface.cpp.

◆ SaveState()

int SaveState ( void * sim)

Definition at line 1127 of file Interface.cpp.

References Simulators::IState::SaveState().

◆ SaveStateToInternalDestructive()

int SaveStateToInternalDestructive ( void * sim)

◆ SetMultithreading()

int SetMultithreading ( void * sim,
int multithreading )

Definition at line 1147 of file Interface.cpp.

References Simulators::IState::SetMultithreading().

◆ SimpleEstimate()

◆ SimpleExecute()

Variable Documentation

◆ isInitialized

std::atomic_bool isInitialized {false}
static

Definition at line 27 of file Interface.cpp.

Referenced by GetMaestroObject(), and GetMaestroObjectWithMute().

◆ maestroInstance