seed48

Initializes a 48-bit random number generator.

Format

#include  <stdlib.h>

unsigned short *seed48  (unsigned short seed_16v[3]);

Arguments

seed_16v
An array of three unsigned short int that form a 48-bit seed value.

Description

The seed48 function initializes the random number generator. You can use this function in your program before calling the drand48, lrand48, or mrand48 functions. (Although it is not recommended practice, constant default initializer values are supplied automatically if you call drand48, lrand48, or mrand48 without calling an initialization function).

The function works by generating a sequence of 48-bit integer values, Xi, according to the linear congruential formula:

       Xn+1 = (aXn+c)mod m        n > 0

The argument m equals 248 , so 48-bit integer arithmetic is performed. Unless you invoke the lcong48 function, the multiplier value a and the addend value c are:

      a = 5DEECE66D16 = 2736731631558

      c = B16 = 138

The initializer function seed48:

The returned pointer allows you to restart the pseudorandom sequence at a given point. Use the pointer to copy the previous Xi value into a temporary array. To resume where the original sequence left off, you can call seed48 with a pointer to this array.

See also drand48, lrand48, and mrand48 in this section.

Return Values
A pointer to a 48-bit internal buffer. 


Previous Page | Next Page | Table of Contents | Index