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

Function validate_densMatrExpecDiagMatrValueIsReal

quest/src/core/validation.cpp:4262–4281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4260}
4261
4262void validate_densMatrExpecDiagMatrValueIsReal(qcomp value, qcomp exponent, const char* caller) {
4263
4264 // this function is only ever called to validate the output of
4265 // expected value calculations of hermitian diagonal matrices
4266 // upon density matrices (NOT statevectors) because errors in
4267 // the latter (due to state unnormalisation, or exponent doma-
4268 // in, or unintended imaginary components of the diagonal)
4269 // never damage the real component, which we always safely return
4270
4271 if (isNumericalValidationDisabled())
4272 return;
4273
4274 // precise comparison since non-power overload passes epxonent=1
4275 string msg = (exponent == qcomp(1,0))?
4276 report::CALC_DENSMATR_EXPECTED_DIAG_MATR_VALUE_WAS_NOT_APPROX_REAL:
4277 report::CALC_DENSMATR_EXPECTED_DIAG_MATR_POWER_VALUE_WAS_NOT_APPROX_REAL;
4278
4279 qreal eps = REDUCTION_EPSILON_FACTOR * global_validationEpsilon;
4280 assertThat(util_isApproxReal(value, eps), msg, caller);
4281}
4282
4283
4284

Callers 2

Calls 3

assertThatFunction · 0.85
util_isApproxRealFunction · 0.85

Tested by

no test coverage detected