observable.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include "type.hpp"
10 #include <vector>
11 #include <utility>
12 #include <string>
13 
14 class QuantumStateBase;
15 class PauliOperator;
16 
24 private:
26  std::vector<PauliOperator*> _operator_list;
28  UINT _qubit_count;
29 public:
38  Observable(UINT qubit_count);
39 
44  virtual ~Observable();
45 
52  void add_operator(const PauliOperator* mpt);
53 
61  void add_operator(double coef, std::string pauli_string);
62 
68  UINT get_qubit_count() const { return _qubit_count; }
69 
75  ITYPE get_state_dim() const { return (1ULL) << _qubit_count; }
76 
82  UINT get_term_count() const { return (UINT)_operator_list.size(); }
83 
90  const PauliOperator* get_term(UINT index) const { return _operator_list[index]; }
91 
97  std::vector<PauliOperator*> get_terms() const { return _operator_list;}
98 
106  double get_expectation_value(const QuantumStateBase* state) const ;
107 
116  CPPCTYPE get_transition_amplitude(const QuantumStateBase* state_bra, const QuantumStateBase* state_ket) const;
117 
118 };
119 
120 namespace observable{
130 
140 
147  DllExport std::pair<Observable*, Observable*> create_split_observable(std::string file_path);
148 }
#define DllExport
Definition: type.hpp:30
std::vector< PauliOperator * > get_terms() const
Definition: observable.hpp:97
Observable * create_observable_from_openfermion_file(std::string file_path)
Definition: observable.cpp:52
Observable * create_observable_from_openfermion_text(std::string text)
Definition: observable.cpp:98
std::complex< double > CPPCTYPE
Definition: type.hpp:13
Definition: state.hpp:23
UINT get_term_count() const
Definition: observable.hpp:82
Definition: observable.hpp:23
Definition: observable.cpp:51
Definition: pauli_operator.hpp:63
std::pair< Observable *, Observable * > create_split_observable(std::string file_path)
Definition: observable.cpp:134
Definition: state.cpp:14
const PauliOperator * get_term(UINT index) const
Definition: observable.hpp:90
ITYPE get_state_dim() const
Definition: observable.hpp:75
UINT get_qubit_count() const
Definition: observable.hpp:68