| 583 | } |
| 584 | |
| 585 | vector<qreal> getRandomProbabilities(int numProbs) { |
| 586 | |
| 587 | // generate random unnormalised scalars |
| 588 | vector<qreal> probs; |
| 589 | qreal total = 0; |
| 590 | for (int i=0; i<numProbs; i++) { |
| 591 | qreal prob = getRandomReal(0, 1); |
| 592 | probs.push_back(prob); |
| 593 | total += prob; |
| 594 | } |
| 595 | |
| 596 | // normalise |
| 597 | for (int i=0; i<numProbs; i++) |
| 598 | probs[i] /= total; |
| 599 | |
| 600 | return probs; |
| 601 | } |
| 602 | |
| 603 | QMatrix getRandomDensityMatrix(int numQb) { |
| 604 | DEMAND( numQb > 0 ); |
no test coverage detected