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

Function getRandomRemainingArgs

tests/unit/operations.cpp:480–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

478
479template <NumQubitsFlag Targs, ArgsFlag Args>
480auto getRandomRemainingArgs(vector<int> targs) {
481
482 if constexpr (Args == none)
483 return tuple{ };
484
485 if constexpr (Args == scalar) {
486 qreal angle = getRandomPhase();
487 return tuple{ angle };
488 }
489
490 if constexpr (Args == axisrots) {
491 qreal angle = getRandomPhase();
492 qreal x = getRandomReal(-1, 1);
493 qreal y = getRandomReal(-1, 1);
494 qreal z = getRandomReal(-1, 1);
495 return tuple{ angle, x, y, z };
496 }
497
498 if constexpr (Args == compmatr || Args == diagmatr) {
499 auto matrix = getRandomApiMatrix<Targs,Args>(targs.size()); // allocates heap mem
500 return tuple{ matrix };
501 }
502
503 if constexpr (Args == diagpower) {
504 DiagMatr matrix = getRandomApiMatrix<Targs,Args>(targs.size()); // allocates heap mem
505 qcomp exponent = qcomp(getRandomReal(-3, 3), 0); // real for unitarity
506 return tuple{ matrix, exponent };
507 }
508
509 if constexpr (Args == paulistr) {
510 PauliStr str = getRandomPauliStr(targs);
511 return tuple{ str };
512 }
513
514 if constexpr (Args == pauligad) {
515 PauliStr str = getRandomPauliStr(targs);
516 qreal angle = getRandomPhase();
517 return tuple{ str, angle };
518 }
519}
520
521
522template <NumQubitsFlag Targs, ArgsFlag Args>

Callers

nothing calls this directly

Calls 3

getRandomPhaseFunction · 0.85
getRandomRealFunction · 0.50
getRandomPauliStrFunction · 0.50

Tested by

no test coverage detected