| 195 | } |
| 196 | |
| 197 | void setRandomTestStateSeeds() { |
| 198 | |
| 199 | // must seed both rand() and this C++ generator (used for shuffling) |
| 200 | |
| 201 | // obtain a seed from hardware |
| 202 | std::random_device cspnrg; |
| 203 | unsigned seed = cspnrg(); |
| 204 | |
| 205 | // broadcast to ensure node consensus |
| 206 | #if COMPILE_MPI |
| 207 | int sendRank = 0; |
| 208 | MPI_Bcast(&seed, 1, MPI_UNSIGNED, sendRank, MPI_COMM_WORLD); |
| 209 | #endif |
| 210 | |
| 211 | // initilise both C (rand()) and C++ (randomGenerator) RNGs |
| 212 | srand(seed); |
| 213 | randomGenerator.seed(seed); |
| 214 | } |
| 215 | |
| 216 | void assertQuregAndRefInDebugState(Qureg qureg, QVector ref) { |
| 217 | DEMAND( qureg.isDensityMatrix == 0 ); |