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

Function getRandomDensityMatrix

tests/deprecated/test_utilities.cpp:603–618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601}
602
603QMatrix getRandomDensityMatrix(int numQb) {
604 DEMAND( numQb > 0 );
605
606 // generate random probabilities to weight random pure states
607 int dim = 1<<numQb;
608 vector<qreal> probs = getRandomProbabilities(dim);
609
610 // add random pure states
611 QMatrix dens = getZeroMatrix(dim);
612 for (int i=0; i<dim; i++) {
613 QVector pure = getRandomStateVector(numQb);
614 dens += probs[i] * getKetBra(pure, pure);
615 }
616
617 return dens;
618}
619
620QMatrix getPureDensityMatrix(QVector state) {
621 return getKetBra(state, state);

Callers 3

test_operators.cppFile · 0.70
test_gates.cppFile · 0.70

Calls 4

getKetBraFunction · 0.85
getRandomProbabilitiesFunction · 0.70
getZeroMatrixFunction · 0.70
getRandomStateVectorFunction · 0.70

Tested by

no test coverage detected