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

Function validate_quregCanBeReduced

quest/src/core/validation.cpp:4289–4313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4287 */
4288
4289void validate_quregCanBeReduced(Qureg qureg, int numTraceQubits, const char* caller) {
4290
4291 // 0 < numTraceQubits <= numQubits is assured by validate_targets(), but
4292 // numTraceQubits == numQubtis is permitted there though forbidden here
4293 assertThat(numTraceQubits < qureg.numQubits, report::NUM_TRACE_QUBITS_EQUALS_QUREG_SIZE, caller);
4294
4295 // when not distributed, there are no further restrictions
4296 if (!qureg.isDistributed)
4297 return;
4298
4299 // if the reduced qureg were hypothetically permitted to be non-distributed
4300 // despite qureg being distributed, then maxTr <= numQb - ceil(logNumNodes/2).
4301 // we presently do not support this however, and insist the reduced qureg
4302 // matches the input qureg's distribution, such that the maximum traced qubits
4303 // is simply that which still retains at least one column per node
4304 int maxNumTraceQubits = qureg.numQubits - qureg.logNumNodes;
4305
4306 tokenSubs vars = {
4307 {"${NUM_TRACE_QUBITS}", numTraceQubits},
4308 {"${MAX_TRACE_QUBITS}", maxNumTraceQubits},
4309 {"${NUM_QUREG_QUBITS}", qureg.numQubits},
4310 {"${NUM_NODES}", qureg.numNodes}};
4311
4312 assertThat(numTraceQubits <= maxNumTraceQubits, report::NUM_TRACE_QUBITS_EXCEEDS_DISTRIBUTED_MAX, vars, caller);
4313}
4314
4315void validate_quregCanBeSetToReducedDensMatr(Qureg out, Qureg in, int numTraceQubits, const char* caller) {
4316

Callers 2

calcPartialTraceFunction · 0.85
calcReducedDensityMatrixFunction · 0.85

Calls 1

assertThatFunction · 0.85

Tested by

no test coverage detected