Skip to content

Commit

Permalink
Change CMath::init_random to use CRandom's set_seed
Browse files Browse the repository at this point in the history
  • Loading branch information
vigsterkr committed May 8, 2013
1 parent e270af7 commit 43af113
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
6 changes: 0 additions & 6 deletions src/shogun/mathematics/Math.cpp
Expand Up @@ -44,15 +44,11 @@ const float64_t CMath::MIN_REAL_NUMBER=1E-300;
#ifdef USE_LOGCACHE
float64_t* CMath::logtable = NULL;
#endif
char* CMath::rand_state = NULL;
uint32_t CMath::seed = 0;

CMath::CMath()
: CSGObject()
{
CMath::rand_state=SG_MALLOC(char, RNG_SEED_SIZE);
init_random();

#ifdef USE_LOGCACHE
LOGRANGE=CMath::determine_logrange();
LOGACCURACY=CMath::determine_logaccuracy(LOGRANGE);
Expand All @@ -69,8 +65,6 @@ CMath::CMath()

CMath::~CMath()
{
SG_FREE(CMath::rand_state);
CMath::rand_state=NULL;
#ifdef USE_LOGCACHE
SG_FREE(CMath::logtable);
CMath::logtable=NULL;
Expand Down
8 changes: 2 additions & 6 deletions src/shogun/mathematics/Math.h
Expand Up @@ -454,11 +454,8 @@ class CMath : public CSGObject
}
else
seed=initseed;
#if !defined(CYGWIN) && !defined(__INTERIX)
//seed=42
//SG_SPRINT("initializing random number generator with %d (seed size %d)\n", seed, RNG_SEED_SIZE)
initstate(seed, CMath::rand_state, RNG_SEED_SIZE);
#endif

sg_rand->set_seed(seed);
}

static inline uint64_t random()
Expand Down Expand Up @@ -1167,7 +1164,6 @@ class CMath : public CSGObject

/// random generator seed
static uint32_t seed;
static char* rand_state;

#ifdef USE_LOGCACHE

Expand Down

0 comments on commit 43af113

Please sign in to comment.