circuit.hpp
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include "type.hpp"
11 #include <vector>
12 #include <string>
13 
14 class QuantumStateBase;
15 class QuantumGateBase;
16 class PauliOperator;
17 class Observable;
18 
26 private:
27  std::vector<QuantumGateBase*> _gate_list;
28  UINT _qubit_count;
29 
30  // prohibit shallow copy
31  QuantumCircuit(const QuantumCircuit&) = default;
32  QuantumCircuit& operator= (const QuantumCircuit&) = default;
33 
34 public:
35  const UINT& qubit_count = _qubit_count;
36  const std::vector<QuantumGateBase*>& gate_list = _gate_list;
44  QuantumCircuit(UINT qubit_count);
45 
55  QuantumCircuit(std::string qasm_path, std::string qasm_loader_script_path = "qasmloader.py");
56 
62  QuantumCircuit* copy() const;
63 
67  virtual ~QuantumCircuit();
68 
69 
71 
79  virtual void add_gate(QuantumGateBase* gate);
80 
89  virtual void add_gate(QuantumGateBase* gate, UINT index);
90 
98  virtual void add_gate_copy(const QuantumGateBase& gate);
99 
107  virtual void add_gate_copy(const QuantumGateBase& gate, UINT index);
108 
115  virtual void remove_gate(UINT index);
116 
117 
119 
126  void update_quantum_state(QuantumStateBase* state);
127 
136  void update_quantum_state(QuantumStateBase* state, UINT start_index, UINT end_index);
137 
138 
140 
149  bool is_Clifford() const;
150 
159  bool is_Gaussian() const;
160 
167  UINT calculate_depth() const;
168 
174  virtual std::string to_string() const;
175 
181  friend DllExport std::ostream& operator<<(std::ostream& os, const QuantumCircuit&);
182 
188  friend DllExport std::ostream& operator<<(std::ostream& os, const QuantumCircuit* gate);
189 
195  virtual void add_X_gate(UINT target_index);
196 
202  virtual void add_Y_gate(UINT target_index);
203 
209  virtual void add_Z_gate(UINT target_index);
210 
216  virtual void add_H_gate(UINT target_index);
217 
223  virtual void add_S_gate(UINT target_index);
224 
230  virtual void add_Sdag_gate(UINT target_index);
231 
237  virtual void add_T_gate(UINT target_index);
238 
244  virtual void add_Tdag_gate(UINT target_index);
245 
251  virtual void add_sqrtX_gate(UINT target_index);
252 
258  virtual void add_sqrtXdag_gate(UINT target_index);
259 
265  virtual void add_sqrtY_gate(UINT target_index);
266 
272  virtual void add_sqrtYdag_gate(UINT target_index);
273 
279  virtual void add_P0_gate(UINT target_index);
280 
286  virtual void add_P1_gate(UINT target_index);
287 
294  virtual void add_CNOT_gate(UINT control_index, UINT target_index);
295 
302  virtual void add_CZ_gate(UINT control_index, UINT target_index);
303 
310  virtual void add_SWAP_gate(UINT target_index1, UINT target_index2);
311 
319  virtual void add_RX_gate(UINT target_index, double angle);
320 
328  virtual void add_RY_gate(UINT target_index, double angle);
329 
337  virtual void add_RZ_gate(UINT target_index, double angle);
338 
346  virtual void add_U1_gate(UINT target_index, double phi);
347 
356  virtual void add_U2_gate(UINT target_index, double phi, double psi);
357 
367  virtual void add_U3_gate(UINT target_index, double phi, double psi, double lambda);
368 
379  virtual void add_multi_Pauli_gate(std::vector<UINT> target_index_list, std::vector<UINT> pauli_id_list);
380 
387  virtual void add_multi_Pauli_gate(const PauliOperator& pauli_operator);
388 
400  virtual void add_multi_Pauli_rotation_gate(std::vector<UINT> target_index_list, std::vector<UINT> pauli_id_list, double angle);
401 
409  virtual void add_multi_Pauli_rotation_gate(const PauliOperator& pauli_operator);
410 
418  virtual void add_diagonal_observable_rotation_gate(const Observable& observable, double angle);
419 
428  virtual void add_observable_rotation_gate(const Observable& observable, double angle, UINT num_repeats = 0);
436  virtual void add_dense_matrix_gate(UINT target_index, const ComplexMatrix& matrix);
437 
446  virtual void add_dense_matrix_gate(std::vector<UINT> target_index_list, const ComplexMatrix& matrix);
447 };
448 
449 
Eigen::Matrix< CPPCTYPE, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ComplexMatrix
Definition: type.hpp:17
#define DllExport
Definition: type.hpp:30
Definition: circuit.hpp:25
Definition: gate_factory.cpp:17
Definition: state.hpp:23
Definition: observable.hpp:23
Definition: observable.cpp:51
Definition: pauli_operator.hpp:63
std::ostream & operator<<(std::ostream &stream, const QuantumCircuit &circuit)
Definition: circuit.cpp:163
Definition: state.cpp:14
Definition: gate.hpp:75