hmmer-3.3/easel/esl_random.c
/* Function:  esl_randomness_Init()
 * Synopsis:  Reinitialize a RNG.           
 *
 * Purpose:   Reset and reinitialize an existing <ESL_RANDOMNESS>
 *            object with a new seed. 
 *            
 *            Sometimes it's useful to reseed an RNG to guarantee a
 *            particular reproducible series of pseudorandom numbers
 *            at an arbitrary point in a program; HMMER does this, for
 *            example, to guarantee the same results from the same
 *            HMM/sequence comparison regardless of where in a search
 *            the HMM or sequence occurs.
 *
 * Args:      r     - randomness object
 *            seed  - new seed to use; >=0.
 *
 * Returns:   <eslOK> on success.
 *
 * Xref:      SRE:STL8/p57.
 */
esl_randomness_Init()
Synopsis:  Reinitialize a RNG.

Reset and reinitialize an existing 
object with a new seed.

Sometimes it's useful to reseed an RNG to guarantee a
particular reproducible series of pseudorandom numbers
at an arbitrary point in a program; HMMER does this, for
example, to guarantee the same results from the same
HMM/sequence comparison regardless of where in a search
the HMM or sequence occurs.

r     - randomness object
seed  - new seed to use; >=0.

 on success.


esl_randomness_Init () Synopsis : Reinitialize a RNG . Reset and reinitialize an existing object with a new seed . Sometimes it ' s useful to reseed an RNG to guarantee a particular reproducible series of pseudorandom numbers at an arbitrary point in a program ; HMMER does this for example to guarantee the same results from the same HMM / sequence comparison regardless of where in a search the HMM or sequence occurs . r - randomness object seed - new seed to use ; > = 0 . on success .
int
esl_randomness_Init(ESL_RANDOMNESS *r, uint32_t seed)
{
  if (seed == 0) seed = choose_arbitrary_seed();
  if (r->type == eslRND_MERSENNE)
    {
      mersenne_seed_table(r, seed);
      mersenne_fill_table(r);
    }
  else 
    {
      r->seed = seed;
      r->x    = esl_rnd_mix3(seed, 87654321, 12345678);	
      if (r->x == 0) r->x = 42;                         
    }
  return eslOK;
}
int esl_randomness_Init ( ESL_RANDOMNESS * r , uint32_t seed ) { if ( seed == 0 ) seed = choose_arbitrary_seed ( ) ; if ( r -> type == eslRND_MERSENNE ) { mersenne_seed_table ( r , seed ) ; mersenne_fill_table ( r ) ; } else { r -> seed = seed ; r -> x = esl_rnd_mix3 ( seed , 87654321 , 12345678 ) ; if ( r -> x == 0 ) r -> x = 42 ; } return eslOK ; }
Function:  esl_randomness_Init()
 Synopsis:  Reinitialize a RNG.
Function : esl_randomness_Init () Synopsis : Reinitialize a RNG .
/* arbitrary dispersion of the seed */ /* make sure we don't have a zero */