gate_named.hpp
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "gate.hpp"
5 #include "state.hpp"
6 #include "utility.hpp"
7 
8 
13 protected:
14  typedef void (T_UPDATE_FUNC)(UINT, CTYPE*, ITYPE);
17 
19 public:
25  virtual void update_quantum_state(QuantumStateBase* state) override{
26  _update_func(this->_target_qubit_list[0].index(), state->data_c(), state->dim);
27  };
33  virtual QuantumGateBase* copy() const override{
34  return new QuantumGate_OneQubit(*this);
35  };
41  virtual void set_matrix(ComplexMatrix& matrix) const override{
42  matrix = this->_matrix_element;
43  }
44 };
45 
50 protected:
51  typedef void (T_UPDATE_FUNC)(UINT, UINT, CTYPE*, ITYPE);
54 
56 public:
62  virtual void update_quantum_state(QuantumStateBase* state) override{
63  _update_func(this->_target_qubit_list[0].index(), this->_target_qubit_list[1].index(), state->data_c(), state->dim);
64  };
70  virtual QuantumGateBase* copy() const override{
71  return new QuantumGate_TwoQubit(*this);
72  };
78  virtual void set_matrix(ComplexMatrix& matrix) const override {
79  matrix = this->_matrix_element;
80  }
81 };
82 
87 protected:
88  typedef void (T_UPDATE_FUNC)(UINT, UINT, CTYPE*, ITYPE);
91 
93 public:
99  virtual void update_quantum_state(QuantumStateBase* state) override {
100  _update_func(this->_control_qubit_list[0].index(), this->_target_qubit_list[0].index(), state->data_c(), state->dim);
101  };
107  virtual QuantumGateBase* copy() const override {
108  return new QuantumGate_OneControlOneTarget(*this);
109  };
115  virtual void set_matrix(ComplexMatrix& matrix) const override {
116  matrix = this->_matrix_element;
117  }
118 };
119 
124 protected:
125  typedef void (T_UPDATE_FUNC)(UINT, double, CTYPE*, ITYPE);
128  double _angle;
129 
130  QuantumGate_OneQubitRotation(double angle) : _angle(angle) {};
131 public:
137  virtual void update_quantum_state(QuantumStateBase* state) override{
138  _update_func(this->_target_qubit_list[0].index(), _angle, state->data_c(), state->dim);
139  };
145  virtual QuantumGateBase* copy() const override{
146  return new QuantumGate_OneQubitRotation(*this);
147  };
153  virtual void set_matrix(ComplexMatrix& matrix) const override {
154  matrix = this->_matrix_element;
155  }
156 };
157 
158 
Eigen::Matrix< CPPCTYPE, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ComplexMatrix
Definition: type.hpp:17
void() T_UPDATE_FUNC(UINT, double, CTYPE *, ITYPE)
Definition: gate_named.hpp:125
std::vector< TargetQubitInfo > _target_qubit_list
Definition: gate.hpp:77
std::vector< ControlQubitInfo > _control_qubit_list
Definition: gate.hpp:78
Definition and basic functions for QuantumGate.
virtual QuantumGateBase * copy() const override
Definition: gate_named.hpp:33
virtual QuantumGateBase * copy() const override
Definition: gate_named.hpp:145
virtual void update_quantum_state(QuantumStateBase *state) override
Definition: gate_named.hpp:99
ComplexMatrix _matrix_element
Definition: gate_named.hpp:16
virtual void set_matrix(ComplexMatrix &matrix) const override
Definition: gate_named.hpp:41
QuantumGate_OneQubitRotation(double angle)
Definition: gate_named.hpp:130
void() T_UPDATE_FUNC(UINT, UINT, CTYPE *, ITYPE)
Definition: gate_named.hpp:88
ComplexMatrix _matrix_element
Definition: gate_named.hpp:90
Definition: gate_named.hpp:12
virtual void update_quantum_state(QuantumStateBase *state) override
Definition: gate_named.hpp:62
T_UPDATE_FUNC * _update_func
Definition: gate_named.hpp:89
virtual void set_matrix(ComplexMatrix &matrix) const override
Definition: gate_named.hpp:153
virtual QuantumGateBase * copy() const override
Definition: gate_named.hpp:107
Definition: state.hpp:23
virtual void set_matrix(ComplexMatrix &matrix) const override
Definition: gate_named.hpp:78
Definition: gate_named.hpp:123
double _angle
Definition: gate_named.hpp:128
virtual void update_quantum_state(QuantumStateBase *state) override
Definition: gate_named.hpp:25
ComplexMatrix _matrix_element
Definition: gate_named.hpp:127
T_UPDATE_FUNC * _update_func
Definition: gate_named.hpp:15
ComplexMatrix _matrix_element
Definition: gate_named.hpp:53
void() T_UPDATE_FUNC(UINT, UINT, CTYPE *, ITYPE)
Definition: gate_named.hpp:51
virtual void set_matrix(ComplexMatrix &matrix) const override
Definition: gate_named.hpp:115
QuantumGate_TwoQubit()
Definition: gate_named.hpp:55
QuantumGate_OneControlOneTarget()
Definition: gate_named.hpp:92
T_UPDATE_FUNC * _update_func
Definition: gate_named.hpp:126
void() T_UPDATE_FUNC(UINT, CTYPE *, ITYPE)
Definition: gate_named.hpp:14
Definition: gate_named.hpp:49
Definition: state.cpp:14
virtual void update_quantum_state(QuantumStateBase *state) override
Definition: gate_named.hpp:137
T_UPDATE_FUNC * _update_func
Definition: gate_named.hpp:52
Definition: gate_named.hpp:86
virtual QuantumGateBase * copy() const override
Definition: gate_named.hpp:70
QuantumGate_OneQubit()
Definition: gate_named.hpp:18
Definition: gate.hpp:75