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

Function validate_newPauliStrSumParams

quest/src/core/validation.cpp:3242–3263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3240 */
3241
3242void validate_newPauliStrSumParams(qindex numTerms, const char* caller) {
3243
3244 assertThat(numTerms > 0, report::NEW_PAULI_STR_SUM_NON_POSITIVE_NUM_STRINGS, {{"${NUM_TERMS}", numTerms}}, caller);
3245
3246 // attempt to fetch RAM, and simply return if we fail; if we unknowingly
3247 // didn't have enough RAM, then alloc validation will trigger later
3248 size_t memPerNode = 0;
3249 try {
3250 memPerNode = mem_tryGetLocalRamCapacityInBytes();
3251 } catch(mem::COULD_NOT_QUERY_RAM e) {
3252 return;
3253 }
3254
3255 // pedantically check whether the PauliStrSum fits in memory. This seems
3256 // ridiculous/pointless because the user is expected to have already prepared
3257 // data of an equivalent size (which is passed), but checking means we catch
3258 // when the user has passed an erroneous 'numTerms' which is way too large,
3259 // avoiding a seg fault
3260
3261 bool fits = mem_canPauliStrSumFitInMemory(numTerms, memPerNode);
3262 assertThat(fits, report::NEW_PAULI_STR_SUM_CANNOT_FIT_INTO_CPU_MEM, {{"${NUM_TERMS}", numTerms}, {"${NUM_BYTES}", memPerNode}}, caller);
3263}
3264
3265void validate_newPauliStrSumMatchingListLens(qindex numStrs, qindex numCoeffs, const char* caller) {
3266

Callers 1

createPauliStrSumFunction · 0.85

Calls 3

assertThatFunction · 0.85

Tested by

no test coverage detected