From 55431ec82f1db436938125d9d6169aab79cbd3d3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 4 May 2012 18:44:53 +0000 Subject: 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. --- src/experimental/randombasic.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/experimental/randombasic.cpp') 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 @@ #include "bu/randombasic.h" Bu::RandomBasic::RandomBasic() : - c( 6364136223846793005 ), - m( 1442695040888963407 ) + a( 6364136223846793005 ), + c( 1442695040888963407 ), + x( 0 ) { } +Bu::RandomBasic::~RandomBasic() +{ +} + +void Bu::RandomBasic::seed( int32_t iSeed ) +{ + c = iSeed; +} + +int32_t Bu::RandomBasic::rand() +{ + x = (a*x + c); + return (int32_t)x; +} + -- cgit v1.2.3