Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4 |
both |
#define _XOPEN_SOURCE
#include <stdlib.h>
void lcong48(unsigned short int param[7]);
The drand48(), erand48(), jrand48(), lrand48(), mrand48() and nrand48() functions generate uniformly distributed pseudo-random numbers using a linear congruential algorithm and 48-bit integer arithmetic.
The lcong48(), seed48(), and srand48() functions are initialization functions, one of which should be invoked before either the drand48(), lrand48() or mrand48() function is called.
X(n+1) = (aX(n) + c)mod(2**48) n>=0
X(0)= 1
a = 5deece66d (base 16)
c = b (base 16)
C/370™ provides storage to save the most recent 48-bit integer value of the sequence, X(i). This storage is shared by the drand48(), lrand48() and mrand48() functions. The lcong48() function is used to reinitialize the most recent 48-bit value in this storage. The lcong48() function replaces the low-order (rightmost) 16 bits of this storage with param[0], the middle-order 16 bits with param[1], and the high-order 16 bits with param[2].
The values a and c, may also be changed by calling the lcong48() function. The lcong48() function replaces the low-order (rightmost) 16 bits of a with param[3], the middle-order 16 bits with param[4], and the high-order 16 bits with param[5]. The lcong48() function replaces c with param[6].
Special behavior for z/OS® UNIX Services: You can make the lcong48() function and other functions in the drand48 family thread-specific by setting the environment variable _RAND48 to the value THREAD before calling any function in the drand48 family.
If you do not request thread-specific behavior for the drand48 family, C/370 serializes access to the storage for X(n), a and c by functions in the drand48 family when they are called by a multithreaded application.
X(t,n+1) = (a(t)X(t,n) + c(t))mod(2**48) n>=0
C/370 provides thread-specific storage to save the most recent 48-bit integer value of the sequence, X(t,i). When the lcong48() function is called from thread t, it reinitializes the most recent 48-bit value in this storage. The lcong48() function replaces the low-order (rightmost) 16 bits of this storage with param[0], the middle-order 16 bits with param[1], and the high-order 16 bits with param[2].
The lcong48() function may also be used to change values of a(t) and c(t) for the thread t. The lcong48() function replaces the low-order (rightmost) 16 bits of a(t) with param[3], the middle-order 16 bits with param[4], and the high-order 16 bits with param[5]. The lcong48() function replaces c(t) with param[6].
After lcong48() has used values from the argument array, param[7], to change the values of a and c and to reinitialized storage for the most recent 48-bit integer value in the sequence, X(i), it returns.
Special behavior for z/OS UNIX Services: If thread-specific behavior is requested for the drand48 family and lcong48() is called on thread t, it uses the argument array, param[7], to change the values of a(t) and c(t) and to reinitialize storage for the most recent 48-bit integer value in the sequence, X(t,i), for the thread. Then it returns.