diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-05-04 18:44:53 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-05-04 18:44:53 +0000 |
commit | 55431ec82f1db436938125d9d6169aab79cbd3d3 (patch) | |
tree | af9c31eff2a44efacded45dca5bcb027ffbe743d /src/experimental/randombasic.cpp | |
parent | 3e3f79bc35d94fab81cb31e42d8699a7eee102a4 (diff) | |
download | libbu++-55431ec82f1db436938125d9d6169aab79cbd3d3.tar.gz libbu++-55431ec82f1db436938125d9d6169aab79cbd3d3.tar.bz2 libbu++-55431ec82f1db436938125d9d6169aab79cbd3d3.tar.xz libbu++-55431ec82f1db436938125d9d6169aab79cbd3d3.zip |
Two basic random number generators, Cmwc is supposed to be a pretty good one.
I need to get the base class and singleton interface in place.
Diffstat (limited to '')
-rw-r--r-- | src/experimental/randombasic.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/experimental/randombasic.cpp b/src/experimental/randombasic.cpp index 03bf7fe..ac591be 100644 --- a/src/experimental/randombasic.cpp +++ b/src/experimental/randombasic.cpp | |||
@@ -8,8 +8,24 @@ | |||
8 | #include "bu/randombasic.h" | 8 | #include "bu/randombasic.h" |
9 | 9 | ||
10 | Bu::RandomBasic::RandomBasic() : | 10 | Bu::RandomBasic::RandomBasic() : |
11 | c( 6364136223846793005 ), | 11 | a( 6364136223846793005 ), |
12 | m( 1442695040888963407 ) | 12 | c( 1442695040888963407 ), |
13 | x( 0 ) | ||
13 | { | 14 | { |
14 | } | 15 | } |
15 | 16 | ||
17 | Bu::RandomBasic::~RandomBasic() | ||
18 | { | ||
19 | } | ||
20 | |||
21 | void Bu::RandomBasic::seed( int32_t iSeed ) | ||
22 | { | ||
23 | c = iSeed; | ||
24 | } | ||
25 | |||
26 | int32_t Bu::RandomBasic::rand() | ||
27 | { | ||
28 | x = (a*x + c); | ||
29 | return (int32_t)x; | ||
30 | } | ||
31 | |||