13 #ifndef VQE_TRANSFORMATION_COMMUTINGSETGENERATOR_HPP_ 14 #define VQE_TRANSFORMATION_COMMUTINGSETGENERATOR_HPP_ 16 #include "PauliOperator.hpp" 29 std::pair<Eigen::VectorXi, Eigen::VectorXi> bv(
Term& op,
int nQubits) {
30 Eigen::VectorXi vx = Eigen::VectorXi::Zero(nQubits);
31 Eigen::VectorXi vz = Eigen::VectorXi::Zero(nQubits);
33 for (
auto term : op.ops()) {
34 if (term.second ==
"X") {
36 }
else if (term.second ==
"Z") {
38 }
else if (term.second ==
"Y") {
44 return std::make_pair(vx, vz);
47 int bv_commutator(
Term& term1,
Term& term2,
int nQubits) {
48 auto pair1 = bv(term1, nQubits);
49 auto pair2 = bv(term2, nQubits);
50 auto scalar = pair1.first.dot(pair2.second) + pair1.second.dot(pair2.first);
56 std::vector<std::vector<Term>> getCommutingSet(
59 std::vector<std::vector<Term>> commuting_ops;
60 std::vector<Term> allTerms;
61 for (
auto& kv : composite.getTerms()) {
62 allTerms.push_back(kv.second);
65 for (
int i = 0; i < allTerms.size(); i++) {
67 auto t_i = allTerms[i];
70 commuting_ops.push_back({t_i});
73 for (
int j = 0; j < commuting_ops.size(); j++) {
74 auto j_op_list = commuting_ops[j];
77 for (
auto j_op : j_op_list) {
78 auto t_jopPtr = allTerms[innerCounter];
79 sum += bv_commutator(t_i, t_jopPtr,
85 commuting_ops[j].push_back(t_i);
91 if (comm_ticker == 0) {
92 commuting_ops.push_back({t_i});
Definition: commuting_set_generator.hpp:25
Definition: Accelerator.hpp:25
Definition: PauliOperator.hpp:213
Definition: PauliOperator.hpp:51
Definition: DefaultParameterSetter.cpp:17