core: parallel_for_(): update RNG state of the main thread

This commit is contained in:
Alexander Alekhin
2017-02-28 18:21:44 +03:00
parent ebdd74105a
commit 649bb7ac04
3 changed files with 22 additions and 3 deletions
+2
View File
@@ -2834,6 +2834,8 @@ public:
double gaussian(double sigma);
uint64 state;
bool operator ==(const RNG& other) const;
};
/** @brief Mersenne Twister random number generator
@@ -349,6 +349,8 @@ inline int RNG::uniform(int a, int b) { return a == b ? a : (int)(next(
inline float RNG::uniform(float a, float b) { return ((float)*this)*(b - a) + a; }
inline double RNG::uniform(double a, double b) { return ((double)*this)*(b - a) + a; }
inline bool RNG::operator ==(const RNG& other) const { return state == other.state; }
inline unsigned RNG::next()
{
state = (uint64)(unsigned)state* /*CV_RNG_COEFF*/ 4164903690U + (unsigned)(state >> 32);