20#ifndef _SIMULATOR_STATE_H_
21#define _SIMULATOR_STATE_H_
25#include <unordered_map>
26#include <unordered_set>
30#include "framework/linalg/vector.hpp"
131 std::vector<std::complex<double>> &litudes) = 0;
148 AER::Vector<std::complex<double>> &litudes) = 0;
164 Eigen::VectorXcd &litudes) = 0;
183 virtual void Configure(
const char *key,
const char *value) = 0;
285 virtual std::vector<double>
301 virtual std::unordered_map<Types::qubit_t, Types::qubit_t>
326 observers.insert(observer);
338 observers.erase(observer);
485 void Notify() { notifyObservers =
true; }
495 if (!notifyObservers)
498 for (
auto &observer : observers) {
499 observer->Update(affectedQubits);
504 std::unordered_set<std::shared_ptr<ISimulatorObserver>>
506 bool notifyObservers =
Interface class for a quantum computing simulator state.
virtual void ApplyReset(const Types::qubits_vector &qubits)=0
Performs a reset of the specified qubits.
virtual bool IsQcsim() const =0
Returns if the simulator is a qcsim simulator.
virtual void SaveStateToInternalDestructive()=0
Saves the state to internal storage.
void Notify()
Starts notifying observers.
virtual std::vector< double > Probabilities(const Types::qubits_vector &qubits)=0
Returns the probabilities of the specified outcomes.
void UnregisterObserver(const std::shared_ptr< ISimulatorObserver > &observer)
Unregisters an observer.
virtual void RestoreState()=0
Restores the state from the internally saved state.
virtual void SaveState()=0
Saves the state to internal storage.
virtual double Probability(Types::qubit_t outcome)=0
Returns the probability of the specified outcome.
virtual void Initialize()=0
Initializes the state.
virtual size_t AllocateQubits(size_t num_qubits)=0
Allocates qubits.
void DontNotify()
Stops notifying observers.
virtual void InitializeState(size_t num_qubits, std::vector< std::complex< double > > &litudes)=0
Initializes the state.
virtual std::vector< double > AllProbabilities()=0
Returns the probabilities of all possible outcomes.
virtual void InitializeState(size_t num_qubits, AER::Vector< std::complex< double > > &litudes)=0
Initializes the state.
virtual SimulationType GetSimulationType() const =0
Returns the type of simulation.
void RegisterObserver(const std::shared_ptr< ISimulatorObserver > &observer)
Registers an observer.
virtual void RestoreInternalDestructiveSavedState()=0
Restores the state from the internally saved state.
virtual void SetMultithreading(bool multithreading=true)=0
Enable/disable multithreading.
virtual double ExpectationValue(const std::string &pauliString)=0
Returns the expected value of a Pauli string.
virtual std::complex< double > Amplitude(Types::qubit_t outcome)=0
Returns the amplitude of the specified state.
virtual size_t GetNumberOfQubits() const =0
Returns the number of qubits.
virtual SimulatorType GetType() const =0
Returns the type of simulator.
virtual std::complex< double > AmplitudeRaw(Types::qubit_t outcome)=0
Gets the amplitude.
virtual void Flush()=0
Flushes the applied operations.
virtual void Configure(const char *key, const char *value)=0
Configures the state.
virtual void Clear()=0
Clears the state.
void ClearObservers()
Clears all observers.
void NotifyObservers(const Types::qubits_vector &affectedQubits)
Notifies observers.
virtual bool GetMultithreading() const =0
Get the multithreading flag.
virtual size_t Measure(const Types::qubits_vector &qubits)=0
Performs a measurement on the specified qubits.
virtual ~IState()=default
Virtual destructor.
virtual void InitializeState(size_t num_qubits, Eigen::VectorXcd &litudes)=0
Initializes the state.
virtual void Reset()=0
Just resets the state to 0.
virtual std::string GetConfiguration(const char *key) const =0
Returns configuration value.
virtual std::unordered_map< Types::qubit_t, Types::qubit_t > SampleCounts(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 Types::qubit_t MeasureNoCollapse()=0
Measures all the qubits without collapsing the state.
SimulationType
The type of simulation.
@ kOther
other simulation type, could occur for the aer simulator, which also has density matrix,...
@ kStatevector
statevector simulation type
@ kMatrixProductState
matrix product state simulation type
@ kStabilizer
Clifford gates simulation type.
@ kTensorNetwork
Tensor network simulation type.
SimulatorType
The type of simulator.
@ kCompositeQCSim
composite qcsim simulator type
@ kQCSim
qcsim simulator type
@ kQiskitAer
qiskit aer simulator type
@ kCompositeQiskitAer
composite qiskit aer simulator type
std::vector< qubit_t > qubits_vector
The type of a vector of qubits.
uint_fast64_t qubit_t
The type of a qubit.