![]() |
The Quantum Exact Simulation Toolkit v4.3.0
|
Functions for seeding QuEST's random generators. More...
Functions | |
| int | getQuESTNumSeeds () |
| void | getQuESTSeeds (unsigned *seeds) |
| void | setQuESTSeeds (unsigned *seeds, int numSeeds) |
| void | setQuESTSeedsToDefault () |
Functions for seeding QuEST's random generators.
Re-seeding with identical seeds will determine all of QuEST's subsequent random outputs (such as measurement and random state preparation), and can be done at any stage of execution. When seeding is not explicitly performed, QuEST will attempt to use a cryptographically secure pseudorandom number generator (CSPRNG) if locally available, else fall back to a standard PRNG, via using the standard C++ random_device class.
| int getQuESTNumSeeds | ( | ) |
Returns the number of seeds used by QuEST in its latest round of random number generator seeding.
This is the length of the list output by getQuESTSeeds().
| error |
|
Definition at line 52 of file debug.cpp.
| void getQuESTSeeds | ( | unsigned * | seeds | ) |
Populates seeds with those which last seeded QuEST's random number generation.
This will return the last seeds passed to setQuESTSeeds(), or those internally chosen within setQuESTSeedsToDefault() (and equivalently, those initially chosen during the QuEST environment initialisation). The number of seeds, which informs the necessary capacity of seeds, is obtained by getQuESTNumSeeds().
may output
See setQuESTSeedsToDefault() for an example of how getQuESTSeeds() interacts with other seeding calls.
| [out] | seeds | the list of seeds |
| error |
|
| seg-fault |
|
Definition at line 58 of file debug.cpp.
Referenced by setRandomTestStateSeeds().
| void setQuESTSeeds | ( | unsigned * | seeds, |
| int | numSeeds ) |
Sets the seeds used by QuEST's random number generation.
This affects and determines all pseudorandom decisions made the QuEST library, such as qubit measurement outcomes and random state preparation. The seeds are passed without modification to QuEST's 19,937-bit Mersenne Twister generator. As such, fully specifying the generator's initial state requires 19,937 seed bits, or 623 unsigned integers, although this is rarely necessary.
Seeding can be performed at any time before a random decision (such as measurement); no random outcomes/state is stored on any object beforehand.
| [in] | seeds | a list of seeds. |
| [in] | numSeeds | the length of seeds. |
| error |
|
Definition at line 37 of file debug.cpp.
Referenced by setRandomTestStateSeeds().
| void setQuESTSeedsToDefault | ( | ) |
Re-randomizes QuEST, seeding its random number generator with new seeds as pseudorandomly produced by the C++ std::random_device @a function, potentially using a hardware RNG. Similar to setQuESTSeeds(), this affects all pseudorandom decisions made the QuEST library, such as qubit measurement outcomes and random state preparation. Unlike setQuESTSeeds() however, repeated calls will not guarantee identical random generation; the internally processed seeds may differ at each invocation. This is, in fact, the function first internally called during QuEST environment initialisation. Seeding can be performed at any time after QuEST library initialisation, before a random decision (such as measurement); no random outcomes/state is stored on any object beforehand. This function consults std::random_device to produce DEFAULT_NUM_RNG_SEEDS=4 seeds, which is infact insufficient to fully specify an initial state of QuEST's 19,937-bit Mersenne Twister generator. Presently, DEFAULT_NUM_RNG_SEEDS cannot be changed except through manual modification and recompilation.
Note that many data structures (e.g. CompMatr, DiagMatr, KrausMap) will assess epsilon-dependent validation properties such as unitarity once, recording the result in a persistent heap field (like KrausMap.isApproxCPTP) to avoid superfluous re-calculation. Updating the global validation epsilon via this function will update all persistent heap fields, marking epsilon-dependent properties as "unknown", which will be lazily re-evaluated when validation is next performed. Ergo, calling this function can cause later additional function overheads.
| error |
|
Definition at line 45 of file debug.cpp.