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

Function getRandomReal

tests/utils/random.cpp:63–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62
63qreal getRandomReal(qreal min, qreal maxExcl) {
64 DEMAND( min < maxExcl );
65
66 // advance RNG on every node, identically
67 std::uniform_real_distribution<qreal> dist(min,maxExcl);
68 qreal out = dist(RNG);
69
70 // note despite the doc asserting maxExcl is exclusive,
71 // uniform_real_distribution() can indeed return it! In that
72 // case, we substract machine-eps for caller integrity
73 if (out >= maxExcl)
74 out = std::nextafter(maxExcl, min);
75
76 DEMAND( out >= min );
77 DEMAND( out < maxExcl );
78 return out;
79}
80
81
82qreal getRandomPhase() {

Callers 13

getRandomPhaseFunction · 0.70
getRandomIntFunction · 0.70
getRandomComplexFunction · 0.70
getRandomProbabilitiesFunction · 0.70
getRandomKrausMapFunction · 0.70
getRandomRemainingArgsFunction · 0.50
SECTIONFunction · 0.50
SECTIONFunction · 0.50
SECTIONFunction · 0.50
SECTIONFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected