Maestro 0.1.0
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
QiskitAerState.h
Go to the documentation of this file.
1
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 {
27 public:
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 {
54 public:
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()) return 1.;
62
63 const auto &state = get_state();
64 if (!state) return 0.;
65
66 flush_ops();
67
68 return state->expval_pauli(qubits, pauli);
69 }
70};
71
72} // namespace Private
73} // namespace Simulators
74
75#endif
76#endif
77#endif