gate_named_one.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #ifndef _MSC_VER
4 extern "C"{
5 #include <csim/update_ops.h>
6 }
7 #else
8 #include <csim/update_ops.h>
9 #endif
10 
11 #include "gate_named.hpp"
12 #include <cmath>
13 
18  static void idling(UINT,CTYPE*,ITYPE){};
19 public:
25  ClsIGate(UINT target_qubit_index) {
26  this->_update_func = ClsIGate::idling;
27  this->_name = "I";
28  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, FLAG_X_COMMUTE | FLAG_Y_COMMUTE | FLAG_Z_COMMUTE ));
30  this->_matrix_element = ComplexMatrix::Zero(2,2);
31  this->_matrix_element << 1,0,0,1;
32  }
33 };
34 
39 public:
45  ClsXGate(UINT target_qubit_index) {
46  this->_update_func = X_gate;
47  this->_name = "X";
48  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, FLAG_X_COMMUTE ));
50  this->_matrix_element = ComplexMatrix::Zero(2,2);
51  this->_matrix_element << 0,1,1,0;
52  }
53 };
54 
59 public:
65  ClsYGate(UINT target_qubit_index) {
66  this->_update_func = Y_gate;
67  this->_name = "Y";
68  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, FLAG_Y_COMMUTE ));
70  this->_matrix_element = ComplexMatrix::Zero(2,2);
71  this->_matrix_element << 0,-1.i,1.i,0;
72  }
73 };
74 
79 public:
85  ClsZGate(UINT target_qubit_index){
86  this->_update_func = Z_gate;
87  this->_name = "Z";
88  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, FLAG_Z_COMMUTE ));
90  this->_matrix_element = ComplexMatrix::Zero(2,2);
91  this->_matrix_element << 1,0,0,-1;
92  }
93 };
94 
99 public:
105  ClsHGate(UINT target_qubit_index) {
106  this->_update_func = H_gate;
107  this->_name = "H";
108  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, 0));
110  this->_matrix_element = ComplexMatrix::Zero(2, 2);
111  this->_matrix_element << 1, 1, 1, -1;
112  this->_matrix_element /= sqrt(2.);
113  }
114 };
115 
120 public:
126  ClsSGate(UINT target_qubit_index){
127  this->_update_func = S_gate;
128  this->_name = "S";
129  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, 0));
131  this->_matrix_element = ComplexMatrix::Zero(2, 2);
132  this->_matrix_element << 1, 0, 0, 1.i;
133  }
134 };
135 
140 public:
146  ClsSdagGate(UINT target_qubit_index){
147  this->_update_func = Sdag_gate;
148  this->_name = "Sdag";
149  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, 0));
151  this->_matrix_element = ComplexMatrix::Zero(2, 2);
152  this->_matrix_element << 1, 0, 0, -1.i;
153  }
154 };
155 
160 public:
166  ClsTGate(UINT target_qubit_index){
167  this->_update_func = T_gate;
168  this->_name = "T";
169  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, 0));
171  this->_matrix_element = ComplexMatrix::Zero(2, 2);
172  this->_matrix_element << 1, 0, 0, (1.+1.i)/sqrt(2.);
173  }
174 };
175 
180 public:
186  ClsTdagGate(UINT target_qubit_index){
187  this->_update_func = Tdag_gate;
188  this->_name = "Tdag";
189  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, 0));
191  this->_matrix_element = ComplexMatrix::Zero(2, 2);
192  this->_matrix_element << 1, 0, 0, (1. - 1.i) / sqrt(2.);
193  }
194 };
195 
200 public:
206  ClsSqrtXGate(UINT target_qubit_index) {
207  this->_update_func = sqrtX_gate;
208  this->_name = "sqrtX";
209  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, FLAG_X_COMMUTE));
211  this->_matrix_element = ComplexMatrix::Zero(2, 2);
212  this->_matrix_element << 0.5 + 0.5i, 0.5 - 0.5i, 0.5 - 0.5i, 0.5 + 0.5i;
213  }
214 };
215 
220 public:
226  ClsSqrtXdagGate(UINT target_qubit_index) {
227  this->_update_func = sqrtXdag_gate;
228  this->_name = "sqrtXdag";
229  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, FLAG_X_COMMUTE));
231  this->_matrix_element = ComplexMatrix::Zero(2, 2);
232  this->_matrix_element << 0.5-0.5i, 0.5+0.5i, 0.5+0.5i, 0.5-0.5i;
233  }
234 };
235 
240 public:
246  ClsSqrtYGate(UINT target_qubit_index) {
247  this->_update_func = sqrtY_gate;
248  this->_name = "sqrtY";
249  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, FLAG_Y_COMMUTE));
251  this->_matrix_element = ComplexMatrix::Zero(2, 2);
252  this->_matrix_element << 0.5+0.5i, -0.5-0.5i, 0.5+0.5i, 0.5+0.5i;
253  }
254 };
255 
260 public:
266  ClsSqrtYdagGate(UINT target_qubit_index) {
267  this->_update_func = sqrtYdag_gate;
268  this->_name = "sqrtYdag";
269  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, FLAG_Y_COMMUTE));
271  this->_matrix_element = ComplexMatrix::Zero(2, 2);
272  this->_matrix_element << 0.5-0.5i, 0.5-0.5i, -0.5+0.5i, 0.5-0.5i;
273  }
274 };
275 
280 public:
286  ClsP0Gate(UINT target_qubit_index){
287  this->_update_func = P0_gate;
288  this->_name = "Projection-0";
289  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, 0));
291  this->_matrix_element = ComplexMatrix::Zero(2, 2);
292  this->_matrix_element << 1, 0, 0, 0;
293  }
294 };
295 
300 public:
306  ClsP1Gate(UINT target_qubit_index){
307  this->_update_func = P1_gate;
308  this->_name = "Projection-1";
309  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, 0));
311  this->_matrix_element = ComplexMatrix::Zero(2, 2);
312  this->_matrix_element << 0, 0, 0, 1;
313  }
314 };
315 
320 public:
327  ClsRXGate(UINT target_qubit_index, double angle) : QuantumGate_OneQubitRotation(angle) {
328  this->_update_func = RX_gate;
329  this->_name = "X-rotation";
330  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, FLAG_X_COMMUTE ));
331  this->_matrix_element = ComplexMatrix::Zero(2,2);
332  this->_matrix_element << cos(_angle), sin(_angle) * 1.i, sin(_angle) * 1.i, cos(_angle);
333  }
334 };
335 
340 public:
347  ClsRYGate(UINT target_qubit_index, double angle): QuantumGate_OneQubitRotation(angle){
348  this->_update_func = RY_gate;
349  this->_name = "Y-rotation";
350  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, FLAG_Y_COMMUTE));
351  this->_matrix_element = ComplexMatrix::Zero(2, 2);
352  this->_matrix_element << cos(_angle), sin(_angle), -sin(_angle), cos(_angle);
353  }
354 };
355 
360 public:
367  ClsRZGate(UINT target_qubit_index, double angle): QuantumGate_OneQubitRotation(angle){
368  this->_update_func = RZ_gate;
369  this->_name = "Z-rotation";
370  this->_target_qubit_list.push_back(TargetQubitInfo(target_qubit_index, FLAG_Z_COMMUTE));
371  this->_matrix_element = ComplexMatrix::Zero(2, 2);
372  this->_matrix_element << cos(_angle)+1.i*sin(_angle), 0, 0, cos(_angle) - 1.i * sin(_angle);
373  }
374 };
std::vector< TargetQubitInfo > _target_qubit_list
Definition: gate.hpp:77
std::string _name
Definition: gate.hpp:80
ClsTGate(UINT target_qubit_index)
Definition: gate_named_one.hpp:166
Definition: gate_named_one.hpp:279
ClsSGate(UINT target_qubit_index)
Definition: gate_named_one.hpp:126
#define FLAG_X_COMMUTE
Flags for bit property: diagonal in X-basis.
Definition: qubit_info.hpp:7
ClsRYGate(UINT target_qubit_index, double angle)
Definition: gate_named_one.hpp:347
Definition: gate_named_one.hpp:119
ComplexMatrix _matrix_element
Definition: gate_named.hpp:16
Definition: gate_named_one.hpp:319
Definition: gate_named_one.hpp:259
Definition: gate_named_one.hpp:219
Definition: qubit_info.hpp:86
Definition: gate_named_one.hpp:38
#define FLAG_Y_COMMUTE
Flags for bit property: diagonal in Y-basis.
Definition: qubit_info.hpp:9
Definition: gate_named_one.hpp:179
ClsP1Gate(UINT target_qubit_index)
Definition: gate_named_one.hpp:306
Definition: gate_named.hpp:12
Definition: gate_named_one.hpp:139
ClsP0Gate(UINT target_qubit_index)
Definition: gate_named_one.hpp:286
ClsIGate(UINT target_qubit_index)
Definition: gate_named_one.hpp:25
#define FLAG_Z_COMMUTE
Flags for bit property: diagonal in Z-basis.
Definition: qubit_info.hpp:11
Definition: gate_named_one.hpp:78
Definition: gate_named_one.hpp:58
Definition: gate_named_one.hpp:199
ClsHGate(UINT target_qubit_index)
Definition: gate_named_one.hpp:105
Definition: gate_named_one.hpp:159
#define FLAG_GAUSSIAN
Flgas for gate property: gate is Gaussian.
Definition: gate.hpp:65
Definition: gate_named_one.hpp:98
ClsZGate(UINT target_qubit_index)
Definition: gate_named_one.hpp:85
ClsXGate(UINT target_qubit_index)
Definition: gate_named_one.hpp:45
Definition: gate_named.hpp:123
ClsRZGate(UINT target_qubit_index, double angle)
Definition: gate_named_one.hpp:367
ClsSqrtYGate(UINT target_qubit_index)
Definition: gate_named_one.hpp:246
double _angle
Definition: gate_named.hpp:128
ClsRXGate(UINT target_qubit_index, double angle)
Definition: gate_named_one.hpp:327
Definition: gate_named_one.hpp:299
ClsTdagGate(UINT target_qubit_index)
Definition: gate_named_one.hpp:186
Definition: gate_named_one.hpp:339
ClsYGate(UINT target_qubit_index)
Definition: gate_named_one.hpp:65
Definition: gate_named_one.hpp:17
ComplexMatrix _matrix_element
Definition: gate_named.hpp:127
T_UPDATE_FUNC * _update_func
Definition: gate_named.hpp:15
ClsSqrtXGate(UINT target_qubit_index)
Definition: gate_named_one.hpp:206
T_UPDATE_FUNC * _update_func
Definition: gate_named.hpp:126
#define FLAG_PAULI
Flgas for gate property: gate is Pauli.
Definition: gate.hpp:61
ClsSdagGate(UINT target_qubit_index)
Definition: gate_named_one.hpp:146
#define FLAG_CLIFFORD
Flgas for gate property: gate is Clifford.
Definition: gate.hpp:63
ClsSqrtYdagGate(UINT target_qubit_index)
Definition: gate_named_one.hpp:266
UINT _gate_property
Definition: gate.hpp:79
Definition: gate_named_one.hpp:359
Definition: gate_named_one.hpp:239
ClsSqrtXdagGate(UINT target_qubit_index)
Definition: gate_named_one.hpp:226