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

Function demo_setFullStateDiagMatr

examples/isolated/initialising_matrices.cpp:373–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371
372
373void demo_setFullStateDiagMatr() {
374
375 // force use of available hardware acceleration
376 QuESTEnv env = getQuESTEnv();
377 FullStateDiagMatr matr = createCustomFullStateDiagMatr(5, env.isDistributed, env.isGpuAccelerated, env.isMultithreaded);
378
379 // inline literal (C++ only)
380 setFullStateDiagMatr(matr, 0, {1,2,3,4});
381 setFullStateDiagMatr(matr, 4, {5,6,7,8});
382
383 // vector (C++ only)
384 vector<qcomp> vec {11, 22, 33, 44};
385 setFullStateDiagMatr(matr, 7, vec);
386
387 // compile-time array must pass size
388 qcomp arr[4] = {7_i, 8_i, 8, 7};
389 setFullStateDiagMatr(matr, 15, arr, 4);
390
391 // heap pointer
392 int dim = 6;
393 qcomp* ptr = (qcomp*) malloc(dim * sizeof *ptr);
394 for (int i=0; i<dim; i++)
395 ptr[i] = -i*.5_i;
396 setFullStateDiagMatr(matr, 25, ptr, 6);
397
398 reportFullStateDiagMatr(matr);
399 destroyFullStateDiagMatr(matr);
400}
401
402
403void demo_syncFullStateDiagMatr() {

Callers 2

mainFunction · 0.85
mainFunction · 0.85

Calls 5

getQuESTEnvFunction · 0.85
setFullStateDiagMatrFunction · 0.85
reportFullStateDiagMatrFunction · 0.85
destroyFullStateDiagMatrFunction · 0.85

Tested by

no test coverage detected