| 74 | */ |
| 75 | |
| 76 | PauliStrSum createMyObservable(int numQubits) { |
| 77 | |
| 78 | // we prepare a weighted sum of alternating Paulis |
| 79 | // upon each qubit, i.e. 1 X0 + 2 Y1 + 3 Z2 + 1 X3 + ... |
| 80 | // where the coefficients are real such that the |
| 81 | // output observable is Hermitian. |
| 82 | |
| 83 | vector<PauliStr> strings(numQubits); |
| 84 | vector<qcomp> coeffs(numQubits); |
| 85 | |
| 86 | for (int i=0; i<numQubits; i++) { |
| 87 | strings[i] = getPauliStr({"XYZ"[i%3]}, {i}); |
| 88 | coeffs[i] = getQcomp(i%4 + 1, 0); |
| 89 | } |
| 90 | |
| 91 | // must be freed by caller |
| 92 | return createPauliStrSum(strings, coeffs); |
| 93 | } |
| 94 | |
| 95 | |
| 96 |
no test coverage detected