You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

basic_gates.h 1.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Copyright 2021 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MINDQUANTUM_ENGINE_BASIC_GATES_H_
  17. #define MINDQUANTUM_ENGINE_BASIC_GATES_H_
  18. #include <string>
  19. #include "mindquantum/parameter_resolver.h"
  20. #include "mindquantum/utils.h"
  21. namespace mindspore {
  22. namespace mindquantum {
  23. class BasicGate {
  24. private:
  25. std::string name_;
  26. bool is_parameter_;
  27. Matrix gate_matrix_base_;
  28. Indexes obj_qubits_;
  29. Indexes ctrl_qubits_;
  30. ParameterResolver paras_;
  31. public:
  32. BasicGate();
  33. BasicGate(const std::string &, bool, const Indexes &, const Indexes &,
  34. const ParameterResolver &paras = ParameterResolver());
  35. virtual Matrix GetMatrix(const ParameterResolver &);
  36. virtual Matrix GetDiffMatrix(const ParameterResolver &);
  37. virtual Matrix &GetBaseMatrix();
  38. const ParameterResolver &GetParameterResolver() const;
  39. bool IsParameterGate();
  40. Indexes GetObjQubits();
  41. Indexes GetCtrlQubits();
  42. };
  43. } // namespace mindquantum
  44. } // namespace mindspore
  45. #endif // MINDQUANTUM_ENGINE_BASIC_GATES_H_