pauli_operator.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include "type.hpp"
10 #include <vector>
11 #include <cassert>
12 
14 
22 protected:
23  UINT _index;
24  UINT _pauli_id;
25 public:
36  SinglePauliOperator(UINT index_, UINT pauli_id_) : _index(index_), _pauli_id(pauli_id_) {
37  assert(pauli_id_ <= 3);
38  };
39 
46  UINT index() const { return _index; }
47 
54  UINT pauli_id() const { return _pauli_id; }
55 };
56 
64 private:
65  std::vector<SinglePauliOperator> _pauli_list;
66  double _coef;
67 public:
76  std::vector<UINT> get_index_list() const {
77  std::vector<UINT> res;
78  for (auto val : _pauli_list) res.push_back(val.index());
79  return res;
80  }
81 
90  std::vector<UINT> get_pauli_id_list() const {
91  std::vector<UINT> res;
92  for (auto val : _pauli_list) res.push_back(val.pauli_id());
93  return res;
94  }
95 
105  PauliOperator(double coef=1.0): _coef(coef){};
106 
117  PauliOperator(std::string strings, double coef=1.0);
118 
131  PauliOperator(const std::vector<UINT>& target_qubit_index_list, std::string Pauli_operator_type_list, double coef = 1.);
132 
142  PauliOperator(const std::vector<UINT>& pauli_list, double coef = 1.);
143 
156  PauliOperator(const std::vector<UINT>& target_qubit_index_list, const std::vector<UINT>& target_qubit_pauli_list, double coef=1.);
157 
158 
165  virtual double get_coef() const { return _coef; }
166 
167  virtual ~PauliOperator(){};
168 
176  virtual void add_single_Pauli(UINT qubit_index, UINT pauli_type);
177 
185  virtual double get_expectation_value(const QuantumStateBase* state) const;
186 
195  virtual CPPCTYPE get_transition_amplitude(const QuantumStateBase* state_bra, const QuantumStateBase* state_ket) const;
196 
203  virtual PauliOperator* copy() const;
204 
205 };
std::vector< UINT > get_index_list() const
Definition: pauli_operator.hpp:76
#define DllExport
Definition: type.hpp:30
Definition: pauli_operator.hpp:21
UINT _pauli_id
Definition: pauli_operator.hpp:24
std::vector< UINT > get_pauli_id_list() const
Definition: pauli_operator.hpp:90
std::complex< double > CPPCTYPE
Definition: type.hpp:13
Definition: state.hpp:23
Definition: pauli_operator.hpp:63
virtual double get_coef() const
Definition: pauli_operator.hpp:165
virtual ~PauliOperator()
Definition: pauli_operator.hpp:167
UINT pauli_id() const
Definition: pauli_operator.hpp:54
UINT index() const
Definition: pauli_operator.hpp:46
Definition: state.cpp:14
SinglePauliOperator(UINT index_, UINT pauli_id_)
Definition: pauli_operator.hpp:36
UINT _index
Definition: pauli_operator.hpp:23
PauliOperator(double coef=1.0)
Definition: pauli_operator.hpp:105