Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)

seed48(3) Guardian Native C Library Calls Reference Manual
NAME
seed48 - Sets rule to generate uniformly distributed pseudorandom number sequences
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
SYNOPSIS
#include <stdlib.h>
unsigned short *seed48(
unsigned short seed_16v[3]);
PARAMETERS
seed_16v Species a new seed value; an array of three unsigned short integers that form a
48-bit seed value.
DESCRIPTION
The srand48(), seed48(), and lcong48() functions initialize the random-number generator. Pro-
grams should invoke one of them before calling the drand48( ), lrand48(),ormrand48() func-
tions. (Although it is not recommended practice, constant default initializer values are supplied
automatically if the drand48( ), lrand48(),ormrand48() functions are called without rst cal-
ling an initialization function.)
All the functions work by generating a sequence of 48-bit integer values, X
i
, according to the
linear congruential formula:
X
n+1
= (aX
n
+c)
mod m
n 0
The value of m equals 2 to the power 48; hence 48-bit integer arithmetic is performed. Unless
lcong48() has been invoked, the multiplier value a and the addend value c are given by
a = 5DEECE66D
16
= 273673163155
8
c = B
16
= 13
8
The initializer function seed48() sets the value of X
i
to the 48-bit value specied in the array
pointed to by the seed_16v parameter. In addition, seed48() returns a pointer to a 48-bit internal
buffer that contains the previous value of X
i
which is used only by seed48(). The returned
pointer allows you to restart the pseudorandom sequence at a given point. Use the pointer to
copy the previous X
i
value into a temporary array. To resume where the original sequence left
off, you can call seed48() with a pointer to this array.
NOTES
This function supports both IEEE Std 754-1985 oating-point and Tandem oating-point values
in the native environment. IEEE values can include NaN and innity, and the sign of 0.0 (zero)
can be either positive or negative. Refer to the fp_class(3) reference page for a description of
IEEE value classes.
Guardian functions are available to convert between oating-point formats. Refer to the Guar-
dian Programmers Guide for a discussion of oating-point conversions.
RETURN VALUES
The seed48() function returns a pointer to a 48-bit internal buffer.
610 Hewlett-Packard Company 527192-005