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.

sparse.h 1.8 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_SPARSE_H_
  17. #define MINDQUANTUM_ENGINE_SPARSE_H_
  18. #include <Eigen/Dense>
  19. #include <Eigen/Sparse>
  20. #include <unsupported/Eigen/KroneckerProduct>
  21. #include <deque>
  22. #include <complex>
  23. #include <utility>
  24. #include <iostream>
  25. #include <vector>
  26. #include "mindquantum/utils.h"
  27. namespace mindspore {
  28. namespace mindquantum {
  29. namespace sparse {
  30. using PauliWord = std::pair<Index, char>;
  31. using PauliTerm = std::pair<std::vector<PauliWord>, int>;
  32. using GoodTerm = std::pair<std::pair<CalcType, std::pair<Index, Index>>, std::vector<PauliTerm>>;
  33. using GoodHamilt = std::vector<GoodTerm>;
  34. typedef Eigen::VectorXcd EigenComplexVector;
  35. using Eigen::VectorXi;
  36. typedef Eigen::SparseMatrix<ComplexType, Eigen::RowMajor, int64_t> SparseMatrix;
  37. using DequeSparseHam = std::deque<SparseMatrix>;
  38. using KroneckerProductSparse = Eigen::KroneckerProductSparse<SparseMatrix, SparseMatrix>;
  39. SparseMatrix BasiGateSparse(char);
  40. SparseMatrix IdentitySparse(int);
  41. SparseMatrix PauliTerm2Sparse(const PauliTerm &, Index, Index);
  42. SparseMatrix GoodTerm2Sparse(const GoodTerm &, Index);
  43. } // namespace sparse
  44. } // namespace mindquantum
  45. } // namespace mindspore
  46. #endif // MINDQUANTUM_ENGINE_SPARSE_H_