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

Function calcExpecFullStateDiagMatr

quest/src/api/calculations.cpp:161–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159
160
161qreal calcExpecFullStateDiagMatr(Qureg qureg, FullStateDiagMatr matrix) {
162 validate_quregFields(qureg, __func__);
163 validate_matrixFields(matrix, __func__);
164 validate_matrixAndQuregAreCompatible(matrix, qureg, true, __func__);
165 validate_matrixIsHermitian(matrix, __func__);
166
167 // unused parameters; see calcExpecFullStateDiagMatrPower() for explanation
168 qcomp exponent = qcomp(1,0);
169 bool useRealPow = false;
170
171 qcomp value = (qureg.isDensityMatrix)?
172 localiser_densmatr_calcExpecFullStateDiagMatr(qureg, matrix, exponent, useRealPow):
173 localiser_statevec_calcExpecFullStateDiagMatr(qureg, matrix, exponent, useRealPow);
174
175 // the sub-epsilon imaginary components in matrix never damage the real
176 // component of the statevector expectation value, so we do not validate
177 // imag(value)~0; we can always safely discard it, and only validate for densmatr:
178 if (qureg.isDensityMatrix)
179 validate_densMatrExpecDiagMatrValueIsReal(value, exponent, __func__);
180
181 return std::real(value);
182}
183
184
185qreal calcExpecFullStateDiagMatrPower(Qureg qureg, FullStateDiagMatr matrix, qreal exponent) {

Callers

nothing calls this directly

Tested by

no test coverage detected