gate_matrix_sparse.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "gate.hpp"
4 #include "type.hpp"
5 
10 private:
11  SparseComplexMatrix _matrix_element;
12 public:
21  QuantumGateSparseMatrix(const std::vector<UINT>& target_qubit_index_list, const SparseComplexMatrix& matrix_element, const std::vector<UINT>& control_qubit_index_list = {});
22 
31  QuantumGateSparseMatrix(const std::vector<UINT>& target_qubit_index_list, SparseComplexMatrix* matrix_element, const std::vector<UINT>& control_qubit_index_list = {});
32 
41  QuantumGateSparseMatrix(const std::vector<TargetQubitInfo>& target_qubit_index_list, const SparseComplexMatrix& matrix_element, const std::vector<ControlQubitInfo>& control_qubit_index_list = {});
42 
51  QuantumGateSparseMatrix(const std::vector<TargetQubitInfo>& target_qubit_index_list, SparseComplexMatrix* matrix_element, const std::vector<ControlQubitInfo>& control_qubit_index_list = {});
52 
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 QuantumGateSparseMatrix(*this);
99  };
100 
106  virtual void set_matrix(ComplexMatrix& matrix) const override {
107  matrix = this->_matrix_element.toDense();
108  }
109 
115  virtual std::string to_string() const override;
116 
124  friend DllExport std::ostream& operator<<(std::ostream& os, const QuantumGateSparseMatrix& gate);
125 
133  friend DllExport std::ostream& operator<<(std::ostream& os, QuantumGateSparseMatrix* gate);
134 
135 };
Eigen::Matrix< CPPCTYPE, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ComplexMatrix
Definition: type.hpp:18
virtual void set_gate_property(UINT gate_property_)
Definition: gate_matrix_sparse.hpp:81
virtual std::string to_string() const
Definition: gate.cpp:85
#define DllExport
Definition: type.hpp:38
Definition and basic functions for QuantumGate.
virtual QuantumGateBase * copy() const override
Definition: gate_matrix_sparse.hpp:97
Definition: gate_factory.cpp:22
virtual void set_matrix(ComplexMatrix &matrix) const override
Definition: gate_matrix_sparse.hpp:106
virtual void multiply_scalar(CPPCTYPE value)
Definition: gate_matrix_sparse.hpp:72
virtual ~QuantumGateSparseMatrix()
Definition: gate_matrix_sparse.hpp:56
Definition: gate_matrix_sparse.hpp:9
std::complex< double > CPPCTYPE
Definition: type.hpp:14
Definition: state.hpp:26
Eigen::SparseMatrix< CPPCTYPE > SparseComplexMatrix
Definition: type.hpp:19
Definition: state.cpp:15
virtual void update_quantum_state(QuantumStateBase *state)=0
friend DllExport std::ostream & operator<<(std::ostream &os, const QuantumGateBase &)
Definition: gate.cpp:113
Definition: gate.hpp:76