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

Function toQVector

tests/deprecated/test_utilities.cpp:1250–1283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1248}
1249
1250QVector toQVector(Qureg qureg) {
1251 DEMAND( !qureg.isDensityMatrix );
1252#if COMPILE_MPI
1253 DEMAND( qureg.numAmps < MPI_MAX_AMPS_IN_MSG );
1254#endif
1255
1256 // ensure local qureg amps are up to date
1257 copyStateFromGPU(qureg);
1258 syncQuESTEnv();
1259
1260 qcomp* allAmps = qureg.cpuAmps;
1261
1262 // in distributed mode, give every node the full state vector
1263#if COMPILE_MPI
1264 if (qureg.isDistributed) {
1265 allAmps = (qcomp*) malloc(qureg.numAmps * sizeof *allAmps);
1266
1267 MPI_Allgather(
1268 qureg.cpuAmps, qureg.numAmpsPerNode, MPI_QCOMP,
1269 allAmps, qureg.numAmpsPerNode, MPI_QCOMP, MPI_COMM_WORLD);
1270 }
1271#endif
1272
1273 // copy full state vector into a QVector
1274 QVector vec = QVector(qureg.numAmps);
1275 for (long long int i=0; i<qureg.numAmps; i++)
1276 vec[i] = allAmps[i];
1277
1278 // clean up if we malloc'd distrib array
1279 if (qureg.isDistributed)
1280 free(allAmps);
1281
1282 return vec;
1283}
1284
1285QVector toQVector(DiagMatr matr) {
1286

Callers 4

toQMatrixFunction · 0.85

Calls 1

syncQuESTEnvFunction · 0.85

Tested by

no test coverage detected