Maestro 0.1.0
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
QiskitAerState.h
Go to the documentation of this file.
1
12
13#pragma once
14
15#ifndef _QISKIT_AER_STATE_H_
16#define _QISKIT_AER_STATE_H_
17
18#ifndef NO_QISKIT_AER
19
20#ifdef INCLUDED_BY_FACTORY
21
22#include "controllers/state_controller.hpp"
23
24namespace AER {
25
26class AerStateFake {
27public:
28 virtual ~AerStateFake() = default;
29
30 bool initialized_;
31 uint_t num_of_qubits_;
32 RngEngine rng_;
33 int seed_ = std::random_device()();
34 std::shared_ptr<QuantumState::Base> state_;
35};
36
37} // namespace AER
38
39namespace Simulators {
40// TODO: Maybe use the pimpl idiom
41// https://en.cppreference.com/w/cpp/language/pimpl to hide the implementation
42// for good but during development this should be good enough
43namespace Private {
44
53class QiskitAerState : public AER::AerState {
54public:
55 const std::shared_ptr<AER::QuantumState::Base> &get_state() const {
56 const AER::AerStateFake *fakeState = (AER::AerStateFake *)(void *)this;
57 return fakeState->state_;
58 }
59
60 double expval_pauli(const reg_t &qubits, const std::string &pauli) {
61 if (qubits.empty() || pauli.empty())
62 return 1.;
63
64 const auto &state = get_state();
65 if (!state)
66 return 0.;
67
68 flush_ops();
69
70 return state->expval_pauli(qubits, pauli);
71 }
72};
73
74} // namespace Private
75} // namespace Simulators
76
77#endif
78#endif
79#endif