Functions for seeding QuEST's random generators.
More...
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.
◆ getNumSeeds()
- Note
- Documentation for this function or struct is under construction!
Definition at line 52 of file debug.cpp.
52 {
53 validate_envIsInit(__func__);
54
55 return rand_getNumSeeds();
56}
Referenced by getSeeds().
◆ getSeeds() [1/2]
std::vector< unsigned > getSeeds |
( |
| ) |
|
- Warning
- This function has not yet been unit tested and may contain bugs. Please use with caution!
- Note
- Documentation for this function or struct is under construction!
Definition at line 197 of file debug.cpp.
197 {
198 validate_envIsInit(__func__);
199
200
201 vector<unsigned> out;
203 auto callback = [&]() { validate_tempAllocSucceeded(false, numSeeds, sizeof(unsigned), __func__); };
204 util_tryAllocVector(out, numSeeds, callback);
205
207 return out;
208}
vector< unsigned > getSeeds()
Referenced by getSeeds(), and setRandomTestStateSeeds().
◆ getSeeds() [2/2]
void getSeeds |
( |
unsigned * | seeds | ) |
|
- Note
- Documentation for this function or struct is under construction!
Definition at line 58 of file debug.cpp.
58 {
59 validate_envIsInit(__func__);
60
61 auto vec = rand_getSeeds();
62 auto num = rand_getNumSeeds();
63
64 for (int i=0; i<num; i++)
65 seeds[i] = vec[i];
66}
◆ setSeeds() [1/2]
void setSeeds |
( |
std::vector< unsigned > | seeds | ) |
|
- Warning
- This function has not yet been unit tested and may contain bugs. Please use with caution!
- Note
- Documentation for this function or struct is under construction!
◆ setSeeds() [2/2]
void setSeeds |
( |
unsigned * | seeds, |
|
|
int | numSeeds ) |
- Note
- Documentation for this function or struct is under construction!
Definition at line 37 of file debug.cpp.
37 {
38 validate_envIsInit(__func__);
39 validate_randomSeeds(seeds, numSeeds, __func__);
40
41
42 rand_setSeeds(vector<unsigned>(seeds, seeds+numSeeds));
43}
Referenced by setRandomTestStateSeeds().
◆ setSeedsToDefault()
void setSeedsToDefault |
( |
| ) |
|
- Note
- Documentation for this function or struct is under construction!
Definition at line 45 of file debug.cpp.
45 {
46 validate_envIsInit(__func__);
47
48 rand_setSeedsToDefault();
49}