auxiliary/hmmer-3.1b1/easel/esl_random.c
/* Function:  esl_randomness_CreateFast()
 * Synopsis:  Create the alternative fast generator.
 *
 * Purpose:   Same as <esl_randomness_Create()>, except that a simple
 *            linear congruential generator will be used.
 *            
 *            This is a $(a=69069, c=1)$ LCG, with a period of
 *            $2^{32}$. Because of the relatively short period, this
 *            generator should not be used for serious simulations
 *            involving large samples.
 *
 *            The properties of this generator are not as good as the
 *            default Mersenne Twister, but it is faster, especially
 *            if you only need a small number of samples from the
 *            generator; it is about 20x faster to initialize the
 *            generator, and about 25\% faster to sample a number, 
 *            compared to the default.
 *
 * Args:      seed $>= 0$.
 *
 * Returns:   an initialized <ESL_RANDOMNESS *> on success.
 *            Caller free's with <esl_randomness_Destroy()>.
 *              
 * Throws:    <NULL> on failure.
 *
 * Xref:      SRE:J5/44: for accidental proof that the period is
 *                       indeed 2^32.
 */
esl_randomness_CreateFast()
Synopsis:  Create the alternative fast generator.

Same as , except that a simple
linear congruential generator will be used.



The properties of this generator are not as good as the
default Mersenne Twister, but it is faster, especially
if you only need a small number of samples from the
generator; it is about 20x faster to initialize the
generator, and about 25\% faster to sample a number,
compared to the default.



an initialized  on success.
Caller free's with .

 on failure.

J5/44: for accidental proof that the period is
indeed 2^32.
esl_randomness_CreateFast () Synopsis : Create the alternative fast generator . Same as except that a simple linear congruential generator will be used . The properties of this generator are not as good as the default Mersenne Twister but it is faster especially if you only need a small number of samples from the generator ; it is about 20x faster to initialize the generator and about 25 \ % faster to sample a number compared to the default . an initialized on success . Caller free ' s with . on failure . J5 / 44 : for accidental proof that the period is indeed 2^32 .
ESL_RANDOMNESS *
esl_randomness_CreateFast(uint32_t seed)
{
  ESL_RANDOMNESS *r      = NULL;
  int             status;
  ESL_ALLOC(r, sizeof(ESL_RANDOMNESS));
  r->type = eslRND_FAST;
  r->mti  = 0;
  r->x    = 0;
  r->seed = 0;
  esl_randomness_Init(r, seed);
  return r;
 ERROR:
  return NULL;
}
ESL_RANDOMNESS * esl_randomness_CreateFast ( uint32_t seed ) { ESL_RANDOMNESS * r = NULL ; int status ; ESL_ALLOC ( r , sizeof ( ESL_RANDOMNESS ) ) ; r -> type = eslRND_FAST ; r -> mti = 0 ; r -> x = 0 ; r -> seed = 0 ; esl_randomness_Init ( r , seed ) ; return r ; ERROR : return NULL ; }
Function:  esl_randomness_CreateFast()
 Synopsis:  Create the alternative fast generator.
Function : esl_randomness_CreateFast () Synopsis : Create the alternative fast generator .