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

Function getRandomDensityMatrix

tests/utils/random.cpp:308–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306
307
308qmatrix getRandomDensityMatrix(int numQb) {
309 DEMAND( numQb > 0 );
310
311 // generate random probabilities to weight random pure states
312 int dim = getPow2(numQb);
313 vector<qreal> probs = getRandomProbabilities(dim);
314
315 // add random pure states
316 qmatrix dens = getZeroMatrix(dim);
317 for (int i=0; i<dim; i++) {
318 qvector pure = getRandomStateVector(numQb);
319 dens += probs[i] * getOuterProduct(pure, pure);
320 }
321
322 return dens;
323}
324
325
326qmatrix getRandomPureDensityMatrix(int numQb) {

Callers 2

setToRandomStateFunction · 0.70

Calls 5

getPow2Function · 0.85
getOuterProductFunction · 0.85
getRandomProbabilitiesFunction · 0.70
getZeroMatrixFunction · 0.70
getRandomStateVectorFunction · 0.70

Tested by

no test coverage detected