gate_matrix.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "gate.hpp"
4 #include "type.hpp"
5 
10 private:
11  ComplexMatrix _matrix_element;
12 public:
21  QuantumGateMatrix(const std::vector<UINT>& target_qubit_index_list, const ComplexMatrix& matrix_element, const std::vector<UINT>& control_qubit_index_list = {});
22 
31  QuantumGateMatrix(const std::vector<UINT>& target_qubit_index_list, ComplexMatrix* matrix_element, const std::vector<UINT>& control_qubit_index_list = {});
32 
41  QuantumGateMatrix(const std::vector<TargetQubitInfo>& target_qubit_index_list, const ComplexMatrix& matrix_element, const std::vector<ControlQubitInfo>& control_qubit_index_list = {});
42 
51  QuantumGateMatrix(const std::vector<TargetQubitInfo>& target_qubit_index_list, ComplexMatrix* matrix_element, const std::vector<ControlQubitInfo>& control_qubit_index_list = {});
52 
56  virtual ~QuantumGateMatrix() {};
57 
65  virtual void add_control_qubit(UINT qubit_index, UINT control_value);
66 
72  virtual void multiply_scalar(CPPCTYPE value) {
73  _matrix_element *= value;
74  }
75 
81  virtual void set_gate_property(UINT gate_property_) {
82  _gate_property = gate_property_;
83  }
84 
90  virtual void update_quantum_state(QuantumStateBase* state) override;
91 
97  virtual QuantumGateBase* copy() const override{
98  return new QuantumGateMatrix(*this);
99  };
100 
106  virtual void set_matrix(ComplexMatrix& matrix) const override{
107  matrix = this->_matrix_element;
108  }
109 
115  virtual std::string to_string() const override;
116 
124  friend DllExport std::ostream& operator<<(std::ostream& os, const QuantumGateMatrix& gate);
125 
133  friend DllExport std::ostream& operator<<(std::ostream& os, QuantumGateMatrix* gate);
134 
135 };
Eigen::Matrix< CPPCTYPE, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ComplexMatrix
Definition: type.hpp:17
virtual std::string to_string() const
Definition: gate.cpp:85
#define DllExport
Definition: type.hpp:30
Definition and basic functions for QuantumGate.
Definition: gate_matrix.hpp:9
Definition: gate_factory.cpp:17
std::complex< double > CPPCTYPE
Definition: type.hpp:13
Definition: state.hpp:23
virtual void set_matrix(ComplexMatrix &matrix) const override
Definition: gate_matrix.hpp:106
virtual ~QuantumGateMatrix()
Definition: gate_matrix.hpp:56
virtual void set_gate_property(UINT gate_property_)
Definition: gate_matrix.hpp:81
virtual QuantumGateBase * copy() const override
Definition: gate_matrix.hpp:97
Definition: state.cpp:14
virtual void update_quantum_state(QuantumStateBase *state)=0
virtual void multiply_scalar(CPPCTYPE value)
Definition: gate_matrix.hpp:72
friend DllExport std::ostream & operator<<(std::ostream &os, const QuantumGateBase &)
Definition: gate.cpp:109
Definition: gate.hpp:75