Maestro 0.1.0
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Simulators::ISimulator Class Referenceabstract

Interface class for a quantum computing simulator. More...

#include <Simulator.h>

Inheritance diagram for Simulators::ISimulator:
Simulators::IState

Public Member Functions

virtual void ApplyP (Types::qubit_t qubit, double lambda)=0
 Applies a phase shift gate to the qubit.
virtual void ApplyX (Types::qubit_t qubit)=0
 Applies a not gate to the qubit.
virtual void ApplyY (Types::qubit_t qubit)=0
 Applies a Y gate to the qubit.
virtual void ApplyZ (Types::qubit_t qubit)=0
 Applies a Z gate to the qubit.
virtual void ApplyH (Types::qubit_t qubit)=0
 Applies a Hadamard gate to the qubit.
virtual void ApplyS (Types::qubit_t qubit)=0
 Applies a S gate to the qubit.
virtual void ApplySDG (Types::qubit_t qubit)=0
 Applies a S dagger gate to the qubit.
virtual void ApplyT (Types::qubit_t qubit)=0
 Applies a T gate to the qubit.
virtual void ApplyTDG (Types::qubit_t qubit)=0
 Applies a T dagger gate to the qubit.
virtual void ApplySx (Types::qubit_t qubit)=0
 Applies a Sx gate to the qubit.
virtual void ApplySxDAG (Types::qubit_t qubit)=0
 Applies a Sx dagger gate to the qubit.
virtual void ApplyK (Types::qubit_t qubit)=0
 Applies a K gate to the qubit.
virtual void ApplyRx (Types::qubit_t qubit, double theta)=0
 Applies a Rx gate to the qubit.
virtual void ApplyRy (Types::qubit_t qubit, double theta)=0
 Applies a Ry gate to the qubit.
virtual void ApplyRz (Types::qubit_t qubit, double theta)=0
 Applies a Rz gate to the qubit.
virtual void ApplyU (Types::qubit_t qubit, double theta, double phi, double lambda, double gamma)=0
 Applies a U gate to the qubit.
virtual void ApplyCX (Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit)=0
 Applies a CX gate to the qubits.
virtual void ApplyCY (Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit)=0
 Applies a CY gate to the qubits.
virtual void ApplyCZ (Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit)=0
 Applies a CZ gate to the qubits.
virtual void ApplyCP (Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit, double lambda)=0
 Applies a CP gate to the qubits.
virtual void ApplyCRx (Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit, double theta)=0
 Applies a CRx gate to the qubits.
virtual void ApplyCRy (Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit, double theta)=0
 Applies a CRy gate to the qubits.
virtual void ApplyCRz (Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit, double theta)=0
 Applies a CRz gate to the qubits.
virtual void ApplyCH (Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit)=0
 Applies a CH gate to the qubits.
virtual void ApplyCSx (Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit)=0
 Applies a CSx gate to the qubits.
virtual void ApplyCSxDAG (Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit)=0
 Applies a CSx dagger gate to the qubits.
virtual void ApplySwap (Types::qubit_t qubit0, Types::qubit_t qubit1)=0
 Applies a swap gate to the qubits.
virtual void ApplyCCX (Types::qubit_t qubit0, Types::qubit_t qubit1, Types::qubit_t qubit2)=0
 Applies a controlled controlled not gate to the qubits.
virtual void ApplyCSwap (Types::qubit_t ctrl_qubit, Types::qubit_t qubit0, Types::qubit_t qubit1)=0
 Applies a controlled swap gate to the qubits.
virtual void ApplyCU (Types::qubit_t ctrl_qubit, Types::qubit_t tgt_qubit, double theta, double phi, double lambda, double gamma)=0
 Applies a controlled U gate to the qubits.
virtual void ApplyNop ()=0
 Applies a nop.
virtual std::unique_ptr< ISimulatorClone ()=0
 Clones the simulator.
std::shared_ptr< ISimulatorgetptr ()
 Get a shared pointer to this object.
Public Member Functions inherited from Simulators::IState
virtual ~IState ()=default
 Virtual destructor.
virtual void Initialize ()=0
 Initializes the state.
virtual void InitializeState (size_t num_qubits, std::vector< std::complex< double > > &amplitudes)=0
 Initializes the state.
virtual void InitializeState (size_t num_qubits, AER::Vector< std::complex< double > > &amplitudes)=0
 Initializes the state.
virtual void InitializeState (size_t num_qubits, Eigen::VectorXcd &amplitudes)=0
 Initializes the state.
virtual void Reset ()=0
 Just resets the state to 0.
virtual void Configure (const char *key, const char *value)=0
 Configures the state.
virtual std::string GetConfiguration (const char *key) const =0
 Returns configuration value.
virtual size_t AllocateQubits (size_t num_qubits)=0
 Allocates qubits.
virtual size_t GetNumberOfQubits () const =0
 Returns the number of qubits.
virtual void Clear ()=0
 Clears the state.
virtual size_t Measure (const Types::qubits_vector &qubits)=0
 Performs a measurement on the specified qubits.
virtual void ApplyReset (const Types::qubits_vector &qubits)=0
 Performs a reset of the specified qubits.
virtual double Probability (Types::qubit_t outcome)=0
 Returns the probability of the specified outcome.
virtual std::complex< double > Amplitude (Types::qubit_t outcome)=0
 Returns the amplitude of the specified state.
virtual std::vector< double > AllProbabilities ()=0
 Returns the probabilities of all possible outcomes.
virtual std::vector< double > Probabilities (const Types::qubits_vector &qubits)=0
 Returns the probabilities of the specified outcomes.
virtual std::unordered_map< Types::qubit_t, Types::qubit_tSampleCounts (const Types::qubits_vector &qubits, size_t shots=1000)=0
 Returns the counts of the outcomes of measurement of the specified qubits, for repeated measurements.
virtual double ExpectationValue (const std::string &pauliString)=0
 Returns the expected value of a Pauli string.
void RegisterObserver (const std::shared_ptr< ISimulatorObserver > &observer)
 Registers an observer.
void UnregisterObserver (const std::shared_ptr< ISimulatorObserver > &observer)
 Unregisters an observer.
void ClearObservers ()
 Clears all observers.
virtual SimulatorType GetType () const =0
 Returns the type of simulator.
virtual SimulationType GetSimulationType () const =0
 Returns the type of simulation.
virtual void Flush ()=0
 Flushes the applied operations.
virtual void SaveStateToInternalDestructive ()=0
 Saves the state to internal storage.
virtual void RestoreInternalDestructiveSavedState ()=0
 Restores the state from the internally saved state.
virtual void SaveState ()=0
 Saves the state to internal storage.
virtual void RestoreState ()=0
 Restores the state from the internally saved state.
virtual std::complex< double > AmplitudeRaw (Types::qubit_t outcome)=0
 Gets the amplitude.
virtual void SetMultithreading (bool multithreading=true)=0
 Enable/disable multithreading.
virtual bool GetMultithreading () const =0
 Get the multithreading flag.
virtual bool IsQcsim () const =0
 Returns if the simulator is a qcsim simulator.
virtual Types::qubit_t MeasureNoCollapse ()=0
 Measures all the qubits without collapsing the state.

Additional Inherited Members

Protected Member Functions inherited from Simulators::IState
void DontNotify ()
 Stops notifying observers.
void Notify ()
 Starts notifying observers.
void NotifyObservers (const Types::qubits_vector &affectedQubits)
 Notifies observers.

Detailed Description

Interface class for a quantum computing simulator.

This is the interface that exposes the functionality of the quantum computing simulators. Use them wrapped in shared pointers.

See also
IState
AerSimulator
QCSimSimulator

Definition at line 32 of file Simulator.h.

Member Function Documentation

◆ ApplyCCX()

virtual void Simulators::ISimulator::ApplyCCX ( Types::qubit_t qubit0,
Types::qubit_t qubit1,
Types::qubit_t qubit2 )
pure virtual

Applies a controlled controlled not gate to the qubits.

Applies a controlled controlled not gate to the specified qubits

Parameters
qubit0The first control qubit
qubit1The second control qubit
qubit2The target qubit

◆ ApplyCH()

virtual void Simulators::ISimulator::ApplyCH ( Types::qubit_t ctrl_qubit,
Types::qubit_t tgt_qubit )
pure virtual

Applies a CH gate to the qubits.

Applies a controlled Hadamard gate to the specified qubits

Parameters
ctrl_qubitThe control qubit
tgt_qubitThe target qubit

◆ ApplyCP()

virtual void Simulators::ISimulator::ApplyCP ( Types::qubit_t ctrl_qubit,
Types::qubit_t tgt_qubit,
double lambda )
pure virtual

Applies a CP gate to the qubits.

Applies a controlled phase gate to the specified qubits

Parameters
ctrl_qubitThe control qubit
tgt_qubitThe target qubit
lambdaThe phase shift angle.

◆ ApplyCRx()

virtual void Simulators::ISimulator::ApplyCRx ( Types::qubit_t ctrl_qubit,
Types::qubit_t tgt_qubit,
double theta )
pure virtual

Applies a CRx gate to the qubits.

Applies a controlled x rotation gate to the specified qubits

Parameters
ctrl_qubitThe control qubit
tgt_qubitThe target qubit
thetaThe rotation angle.

◆ ApplyCRy()

virtual void Simulators::ISimulator::ApplyCRy ( Types::qubit_t ctrl_qubit,
Types::qubit_t tgt_qubit,
double theta )
pure virtual

Applies a CRy gate to the qubits.

Applies a controlled y rotation gate to the specified qubits

Parameters
ctrl_qubitThe control qubit
tgt_qubitThe target qubit
thetaThe rotation angle.

◆ ApplyCRz()

virtual void Simulators::ISimulator::ApplyCRz ( Types::qubit_t ctrl_qubit,
Types::qubit_t tgt_qubit,
double theta )
pure virtual

Applies a CRz gate to the qubits.

Applies a controlled z rotation gate to the specified qubits

Parameters
ctrl_qubitThe control qubit
tgt_qubitThe target qubit
thetaThe rotation angle.

◆ ApplyCSwap()

virtual void Simulators::ISimulator::ApplyCSwap ( Types::qubit_t ctrl_qubit,
Types::qubit_t qubit0,
Types::qubit_t qubit1 )
pure virtual

Applies a controlled swap gate to the qubits.

Applies a controlled swap gate to the specified qubits

Parameters
ctrl_qubitThe control qubit
qubit0The first qubit
qubit1The second qubit

◆ ApplyCSx()

virtual void Simulators::ISimulator::ApplyCSx ( Types::qubit_t ctrl_qubit,
Types::qubit_t tgt_qubit )
pure virtual

Applies a CSx gate to the qubits.

Applies a controlled squared root not gate to the specified qubits

Parameters
ctrl_qubitThe control qubit
tgt_qubitThe target qubit

◆ ApplyCSxDAG()

virtual void Simulators::ISimulator::ApplyCSxDAG ( Types::qubit_t ctrl_qubit,
Types::qubit_t tgt_qubit )
pure virtual

Applies a CSx dagger gate to the qubits.

Applies a controlled squared root not dagger gate to the specified qubits

Parameters
ctrl_qubitThe control qubit
tgt_qubitThe target qubit

◆ ApplyCU()

virtual void Simulators::ISimulator::ApplyCU ( Types::qubit_t ctrl_qubit,
Types::qubit_t tgt_qubit,
double theta,
double phi,
double lambda,
double gamma )
pure virtual

Applies a controlled U gate to the qubits.

Applies a controlled U gate to the specified qubits

Parameters
ctrl_qubitThe control qubit
tgt_qubitThe target qubit
thetaTheta parameter for the U gate
phiPhi parameter for the U gate
lambdaLambda parameter for the U gate
gammaGamma parameter for the U gate

◆ ApplyCX()

virtual void Simulators::ISimulator::ApplyCX ( Types::qubit_t ctrl_qubit,
Types::qubit_t tgt_qubit )
pure virtual

Applies a CX gate to the qubits.

Applies a controlled X gate to the specified qubits

Parameters
ctrl_qubitThe control qubit
tgt_qubitThe target qubit

◆ ApplyCY()

virtual void Simulators::ISimulator::ApplyCY ( Types::qubit_t ctrl_qubit,
Types::qubit_t tgt_qubit )
pure virtual

Applies a CY gate to the qubits.

Applies a controlled Y gate to the specified qubits

Parameters
ctrl_qubitThe control qubit
tgt_qubitThe target qubit

◆ ApplyCZ()

virtual void Simulators::ISimulator::ApplyCZ ( Types::qubit_t ctrl_qubit,
Types::qubit_t tgt_qubit )
pure virtual

Applies a CZ gate to the qubits.

Applies a controlled Z gate to the specified qubits

Parameters
ctrl_qubitThe control qubit
tgt_qubitThe target qubit

◆ ApplyH()

virtual void Simulators::ISimulator::ApplyH ( Types::qubit_t qubit)
pure virtual

Applies a Hadamard gate to the qubit.

Applies a Hadamard gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.

◆ ApplyK()

virtual void Simulators::ISimulator::ApplyK ( Types::qubit_t qubit)
pure virtual

Applies a K gate to the qubit.

Applies a K (Hy) gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.

◆ ApplyNop()

virtual void Simulators::ISimulator::ApplyNop ( )
pure virtual

Applies a nop.

Applies a nop (no operation). Typically does (almost) nothing. Equivalent to an identity. For qiskit aer it will send the 'nop' to the qiskit aer simulator.

◆ ApplyP()

virtual void Simulators::ISimulator::ApplyP ( Types::qubit_t qubit,
double lambda )
pure virtual

Applies a phase shift gate to the qubit.

Applies a specified phase shift gate to the qubit

Parameters
qubitThe qubit to apply the gate to.
lambdaThe phase shift angle.

◆ ApplyRx()

virtual void Simulators::ISimulator::ApplyRx ( Types::qubit_t qubit,
double theta )
pure virtual

Applies a Rx gate to the qubit.

Applies an x rotation gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.
thetaThe rotation angle.

◆ ApplyRy()

virtual void Simulators::ISimulator::ApplyRy ( Types::qubit_t qubit,
double theta )
pure virtual

Applies a Ry gate to the qubit.

Applies a y rotation gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.
thetaThe rotation angle.

◆ ApplyRz()

virtual void Simulators::ISimulator::ApplyRz ( Types::qubit_t qubit,
double theta )
pure virtual

Applies a Rz gate to the qubit.

Applies a z rotation gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.
thetaThe rotation angle.

◆ ApplyS()

virtual void Simulators::ISimulator::ApplyS ( Types::qubit_t qubit)
pure virtual

Applies a S gate to the qubit.

Applies a S gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.

◆ ApplySDG()

virtual void Simulators::ISimulator::ApplySDG ( Types::qubit_t qubit)
pure virtual

Applies a S dagger gate to the qubit.

Applies a S dagger gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.

◆ ApplySwap()

virtual void Simulators::ISimulator::ApplySwap ( Types::qubit_t qubit0,
Types::qubit_t qubit1 )
pure virtual

Applies a swap gate to the qubits.

Applies a swap gate to the specified qubits

Parameters
qubit0The first qubit
qubit1The second qubit

◆ ApplySx()

virtual void Simulators::ISimulator::ApplySx ( Types::qubit_t qubit)
pure virtual

Applies a Sx gate to the qubit.

Applies a Sx gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.

◆ ApplySxDAG()

virtual void Simulators::ISimulator::ApplySxDAG ( Types::qubit_t qubit)
pure virtual

Applies a Sx dagger gate to the qubit.

Applies a Sx dagger gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.

◆ ApplyT()

virtual void Simulators::ISimulator::ApplyT ( Types::qubit_t qubit)
pure virtual

Applies a T gate to the qubit.

Applies a T gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.

◆ ApplyTDG()

virtual void Simulators::ISimulator::ApplyTDG ( Types::qubit_t qubit)
pure virtual

Applies a T dagger gate to the qubit.

Applies a T dagger gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.

◆ ApplyU()

virtual void Simulators::ISimulator::ApplyU ( Types::qubit_t qubit,
double theta,
double phi,
double lambda,
double gamma )
pure virtual

Applies a U gate to the qubit.

Applies a U gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.
thetaThe first parameter.
phiThe second parameter.
lambdaThe third parameter.
gammaThe fourth parameter.

◆ ApplyX()

virtual void Simulators::ISimulator::ApplyX ( Types::qubit_t qubit)
pure virtual

Applies a not gate to the qubit.

Applies a not (X) gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.

◆ ApplyY()

virtual void Simulators::ISimulator::ApplyY ( Types::qubit_t qubit)
pure virtual

Applies a Y gate to the qubit.

Applies a not (Y) gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.

◆ ApplyZ()

virtual void Simulators::ISimulator::ApplyZ ( Types::qubit_t qubit)
pure virtual

Applies a Z gate to the qubit.

Applies a not (Z) gate to the specified qubit

Parameters
qubitThe qubit to apply the gate to.

◆ Clone()

virtual std::unique_ptr< ISimulator > Simulators::ISimulator::Clone ( )
pure virtual

Clones the simulator.

Clones the simulator, including the state, the configuration and the internally saved state, if any. Does not copy the observers. Should be used mainly internally, to optimise multiple shots execution, copying the state from the simulator used for timing.

Returns
A unique pointer to the cloned simulator.

◆ getptr()

std::shared_ptr< ISimulator > Simulators::ISimulator::getptr ( )
inline

Get a shared pointer to this object.

Returns a shared pointer to this object. The object needs to be already wrapped in a shared pointer.

Returns
A shared pointer to this object.

Definition at line 345 of file Simulator.h.


The documentation for this class was generated from the following file: