mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 20:59:36 +08:00
Fix linear congruential random number generator
Fixes: #4146, #4148, #4270
Fixes: 2252936fc8
("Use linear congruential random number generator [...]")
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
5c78037bd3
commit
32fee19447
@ -68,7 +68,9 @@ inline const std::vector<std::string> split(const std::string &s, char c) {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A simple linear congruential random number generator.
|
// A simple linear congruential random number generator,
|
||||||
|
// using Knuth's constants from:
|
||||||
|
// http://en.wikipedia.org/wiki/Linear_congruential_generator.
|
||||||
class TRand {
|
class TRand {
|
||||||
public:
|
public:
|
||||||
// Sets the seed to the given value.
|
// Sets the seed to the given value.
|
||||||
@ -95,7 +97,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::minstd_rand e;
|
std::linear_congruential_engine<std::uint_fast32_t,
|
||||||
|
6364136223846793005ULL,
|
||||||
|
1442695040888963407ULL,
|
||||||
|
UINT64_MAX> e;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remove newline (if any) at the end of the string.
|
// Remove newline (if any) at the end of the string.
|
||||||
|
Loading…
Reference in New Issue
Block a user