MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / createMyObservable

Function createMyObservable

examples/extended/dynamics.cpp:76–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74 */
75
76PauliStrSum 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

Callers 1

mainFunction · 0.70

Calls 3

getPauliStrFunction · 0.85
getQcompFunction · 0.85
createPauliStrSumFunction · 0.85

Tested by

no test coverage detected