| 237 | } |
| 238 | |
| 239 | qindex util_getLocalIndexOfGlobalIndex(Qureg qureg, qindex globalInd) { |
| 240 | |
| 241 | // equivalent to below, but clearer |
| 242 | if (!qureg.isDistributed) |
| 243 | return globalInd; |
| 244 | |
| 245 | // defensive-design integrity check |
| 246 | qindex globalStart = util_getGlobalIndexOfFirstLocalAmp(qureg); |
| 247 | qindex globalEnd = globalStart + qureg.numAmpsPerNode; |
| 248 | if (globalInd < globalStart || globalInd >= globalEnd) |
| 249 | error_utilsGivenGlobalIndexOutsideNode(); |
| 250 | |
| 251 | return globalInd % qureg.numAmpsPerNode; |
| 252 | } |
| 253 | |
| 254 | qindex util_getLocalIndexOfFirstDiagonalAmp(Qureg qureg) { |
| 255 | assert_utilsGivenDensMatr(qureg); |
no test coverage detected