gate_reflect.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "gate.hpp"
4 #include "state.hpp"
5 #ifndef _MSC_VER
6 extern "C" {
7 #include <csim/update_ops.h>
8 }
9 #else
10 #include <csim/update_ops.h>
11 #endif
12 #include <csim/update_ops_cpp.hpp>
13 
14 #include <cmath>
15 
16 #ifdef _USE_GPU
17 #include <gpusim/update_ops_cuda.h>
18 #endif
19 #include <iostream>
20 
25 private:
26  QuantumStateBase* reflection_state;
27 public:
28  ClsStateReflectionGate(const QuantumStateBase* _reflection_state) {
29  reflection_state = _reflection_state->copy();
30  UINT qubit_count = _reflection_state->qubit_count;
31  for (UINT qubit_index = 0; qubit_index < qubit_count; ++qubit_index) {
32  this->_target_qubit_list.push_back(TargetQubitInfo(qubit_index, 0));
33  }
34  this->_name = "Reflection";
35  };
37  delete reflection_state;
38  }
39 
45  virtual void update_quantum_state(QuantumStateBase* state) override {
46 #ifdef _USE_GPU
47  if (state->get_device_name() != reflection_state->get_device_name()) {
48  std::cerr << "Quantum state on CPU (GPU) cannot be reflected using quantum state on GPU (CPU)" << std::endl;
49  return;
50  }
51  if (state->get_device_name() == "gpu") {
52  std::cerr << "Not Implemented" << std::endl;
53  exit(0);
54  //reversible_boolean_gate_gpu(target_index.data(), target_index.size(), function_ptr, state->data_c(), state->dim);
55  }
56  else {
57  reflection_gate(reflection_state->data_c(), state->data_c(), state->dim);
58  }
59 #else
60  reflection_gate(reflection_state->data_c(), state->data_c(), state->dim);
61 #endif
62  };
68  virtual QuantumGateBase* copy() const override {
69  return new ClsStateReflectionGate(this->reflection_state);
70  };
76  virtual void set_matrix(ComplexMatrix& matrix) const override {
77  std::cerr << "ReflectionGate::set_matrix is not implemented" << std::endl;
78  exit(0);
79  }
80 };
81 
82 
Eigen::Matrix< CPPCTYPE, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ComplexMatrix
Definition: type.hpp:18
std::vector< TargetQubitInfo > _target_qubit_list
Definition: gate.hpp:78
std::string _name
Definition: gate.hpp:81
Definition and basic functions for QuantumGate.
virtual CTYPE * data_c() const =0
virtual ~ClsStateReflectionGate()
Definition: gate_reflect.hpp:36
virtual const std::string get_device_name() const =0
ClsStateReflectionGate(const QuantumStateBase *_reflection_state)
Definition: gate_reflect.hpp:28
Definition: qubit_info.hpp:86
virtual void update_quantum_state(QuantumStateBase *state) override
Definition: gate_reflect.hpp:45
Definition: state.hpp:24
virtual QuantumGateBase * copy() const override
Definition: gate_reflect.hpp:68
virtual void set_matrix(ComplexMatrix &matrix) const override
Definition: gate_reflect.hpp:76
virtual QuantumStateBase * copy() const =0
Definition: state.cpp:15
const UINT & qubit_count
Definition: state.hpp:30
Definition: gate_reflect.hpp:24
Definition: gate.hpp:76