| 3504 | } |
| 3505 | |
| 3506 | void validate_localAmpIndices(Qureg qureg, qindex localStartInd, qindex numInds, const char* caller) { |
| 3507 | |
| 3508 | // note that localStartInd and numInds can validly DIFFER between nodes, |
| 3509 | // so we use assertAllNodesAgreeThat() in lieu of assertThat() |
| 3510 | |
| 3511 | tokenSubs baseVars = { |
| 3512 | {"${NUM_QB}", qureg.numQubits}, |
| 3513 | {"${NUM_AMPS_TOTAL}", qureg.numAmps}, |
| 3514 | {"${MAX_IND_EXCL}", qureg.numAmpsPerNode}, |
| 3515 | {"${NUM_NODES}", qureg.numNodes} |
| 3516 | }; |
| 3517 | |
| 3518 | // when numInds=0, we permit startInd to be anything (even something invalid) |
| 3519 | if (numInds == 0) |
| 3520 | return; |
| 3521 | |
| 3522 | // unlike validate_basisStateIndices(), we limit to #amps per node |
| 3523 | tokenSubs firstVars = baseVars; |
| 3524 | firstVars["${START_IND}"] = localStartInd; |
| 3525 | assertAllNodesAgreeThat(localStartInd >= 0 && localStartInd < qureg.numAmpsPerNode, report::INVALID_STARTING_LOCAL_AMP_INDEX, firstVars, caller); |
| 3526 | |
| 3527 | // unlike validate_basisStateIndices(), we permit numInds == 0 |
| 3528 | tokenSubs secondVars = baseVars; |
| 3529 | secondVars["${NUM_INDS}"] = numInds; |
| 3530 | assertAllNodesAgreeThat(numInds >= 0 && numInds <= qureg.numAmps, report::INVALID_NUM_LOCAL_AMP_INDICES, secondVars, caller); |
| 3531 | |
| 3532 | qindex endIndExcl = localStartInd + numInds; |
| 3533 | baseVars["${START_IND}"] = localStartInd; |
| 3534 | baseVars["${NUM_INDS}"] = numInds; |
| 3535 | baseVars["${END_IND_EXCL}"] = endIndExcl; |
| 3536 | assertAllNodesAgreeThat(endIndExcl <= qureg.numAmpsPerNode, report::INVALID_ENDING_LOCAL_AMP_INDEX, baseVars, caller); |
| 3537 | } |
| 3538 | |
| 3539 | |
| 3540 |
no test coverage detected