qubit_info.hpp
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "type.hpp"
5 
7 #define FLAG_X_COMMUTE ((UINT)(0x01))
8 #define FLAG_Y_COMMUTE ((UINT)(0x02))
10 #define FLAG_Z_COMMUTE ((UINT)(0x04))
12 
17 protected:
18  UINT _index;
19 public:
25  UINT index() const { return _index; }
26 
32  QubitInfo(UINT index_): _index(index_) {};
33 };
34 
35 class TargetQubitInfo;
36 class ControlQubitInfo;
37 
42 private:
43  UINT _control_value;
44 public:
50  UINT control_value() const { return _control_value; }
56  ControlQubitInfo(UINT index_) : QubitInfo(index_), _control_value(1) {};
63  ControlQubitInfo(UINT index_, UINT control_value_) : QubitInfo(index_), _control_value(control_value_) {};
64 
72  virtual bool is_commute_with(const TargetQubitInfo& info) const;
80  virtual bool is_commute_with(const ControlQubitInfo& info) const;
81 };
82 
87 private:
88  UINT _commutation_property;
89 public:
95  TargetQubitInfo(UINT index_) : QubitInfo(index_), _commutation_property(0) {};
102  TargetQubitInfo(UINT index_, UINT commutation_property_) : QubitInfo(index_), _commutation_property(commutation_property_) {};
109  bool is_commute_X() const { return (_commutation_property & FLAG_X_COMMUTE) != 0; }
116  bool is_commute_Y() const { return (_commutation_property & FLAG_Y_COMMUTE) != 0; }
123  bool is_commute_Z() const { return (_commutation_property & FLAG_Z_COMMUTE) != 0; }
131  virtual bool is_commute_with(const TargetQubitInfo& info) const;
139  virtual bool is_commute_with(const ControlQubitInfo& info) const;
140 
147  virtual UINT get_merged_property(UINT property) const { return _commutation_property & property; }
154  virtual UINT get_merged_property(const TargetQubitInfo& target) const { return _commutation_property & target._commutation_property; }
161  virtual UINT get_merged_property(const ControlQubitInfo& control) const { (void)control; return _commutation_property & FLAG_Z_COMMUTE; }
162 };
virtual UINT get_merged_property(const ControlQubitInfo &control) const
Definition: qubit_info.hpp:161
Definition: qubit_info.hpp:41
UINT _index
Definition: qubit_info.hpp:18
UINT control_value() const
Definition: qubit_info.hpp:50
#define DllExport
Definition: type.hpp:30
#define FLAG_X_COMMUTE
Flags for bit property: diagonal in X-basis.
Definition: qubit_info.hpp:7
UINT index() const
Definition: qubit_info.hpp:25
virtual UINT get_merged_property(UINT property) const
Definition: qubit_info.hpp:147
virtual UINT get_merged_property(const TargetQubitInfo &target) const
Definition: qubit_info.hpp:154
bool is_commute_Y() const
Definition: qubit_info.hpp:116
bool is_commute_Z() const
Definition: qubit_info.hpp:123
Definition: qubit_info.hpp:86
QubitInfo(UINT index_)
Definition: qubit_info.hpp:32
#define FLAG_Y_COMMUTE
Flags for bit property: diagonal in Y-basis.
Definition: qubit_info.hpp:9
ControlQubitInfo(UINT index_)
Definition: qubit_info.hpp:56
#define FLAG_Z_COMMUTE
Flags for bit property: diagonal in Z-basis.
Definition: qubit_info.hpp:11
bool is_commute_X() const
Definition: qubit_info.hpp:109
ControlQubitInfo(UINT index_, UINT control_value_)
Definition: qubit_info.hpp:63
TargetQubitInfo(UINT index_)
Definition: qubit_info.hpp:95
Definition: qubit_info.hpp:16
TargetQubitInfo(UINT index_, UINT commutation_property_)
Definition: qubit_info.hpp:102