Annotation of researchv10dc/630/man/src/p_man/man3/drand48.3l, revision 1.1.1.1

1.1       root        1: .TH DRAND48 3L "630 MTG"
                      2: .SH NAME
                      3: drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48, lcong48 \- generate uniformly distributed pseudo-random numbers
                      4: .SH SYNOPSIS
                      5: .EQ
                      6: delim $$
                      7: .EN
                      8: .B double drand48 ( )
                      9: .sp
                     10: \f3double erand48 ( xsubi )\f1
                     11: .br
                     12: \f3unsigned short xsubi [3];\f1
                     13: .sp
                     14: .B long lrand48 ( )
                     15: .sp
                     16: \f3long nrand48 ( xsubi )\f1
                     17: .br
                     18: \f3unsigned short xsubi [3];\f1
                     19: .sp
                     20: .B long mrand48 ( )
                     21: .sp
                     22: \f3long jrand48 ( xsubi )\f1
                     23: .br
                     24: \f3unsigned short xsubi [3];\f1
                     25: .sp
                     26: .B void srand48 (seedval)
                     27: .br
                     28: .B long seedval;
                     29: .sp
                     30: .B unsigned short \(**seed48 (seed16v)
                     31: .br
                     32: .B unsigned short seed16v[3];
                     33: .sp
                     34: .B void lcong48 (param)
                     35: .br
                     36: .B unsigned short param[7];
                     37: .SH DESCRIPTION
                     38: .EQ
                     39: delim $$
                     40: .EN
                     41: This family of functions generates pseudo-random numbers using the
                     42: well-known linear congruential algorithm and 48-bit integer arithmetic.
                     43: .PP
                     44: Functions
                     45: .I drand48\^
                     46: and
                     47: .I erand48\^
                     48: return non-negative double-precision floating-point values
                     49: uniformly distributed over the interval $[0.0,~1.0).$
                     50: .PP
                     51: Functions
                     52: .I lrand48\^
                     53: and
                     54: .I nrand48\^
                     55: return non-negative long integers uniformly distributed over the
                     56: interval $[0,~2 sup 31 ).$
                     57: .PP
                     58: Functions
                     59: .I mrand48\^
                     60: and
                     61: .I jrand48\^
                     62: return signed long integers uniformly distributed over the interval
                     63: $[-2 sup 31 ,~2 sup 31 ).$
                     64: .PP
                     65: Functions
                     66: .I srand48, seed48\^
                     67: and
                     68: .I lcong48\^
                     69: are initialization entry points, one of which should be invoked before
                     70: either
                     71: .I drand48, lrand48\^
                     72: or
                     73: .I mrand48\^
                     74: is called.
                     75: (Although it is not recommended practice,
                     76: constant default initializer values will be supplied automatically if
                     77: .I drand48, lrand48\^
                     78: or
                     79: .I mrand48\^
                     80: is called without a prior call to an initialization entry point.)
                     81: Functions
                     82: .I erand48, nrand48\^
                     83: and
                     84: .I jrand48\^
                     85: do not require an initialization entry point to be called first.
                     86: .PP
                     87: All the routines work by generating a sequence of 48-bit integer values,
                     88: $X sub i ,$ according to the linear congruential formula
                     89: .PP
                     90: .ce
                     91: .EQ I
                     92: X sub{n+1}~=~(aX sub n^+^c) sub{roman mod~m}~~~~~~~~n>=0.
                     93: .EN
                     94: .PP
                     95: The parameter $m^=^2 sup 48$; hence 48-bit integer arithmetic is
                     96: performed.
                     97: Unless
                     98: .I lcong48\^
                     99: has been invoked, the multiplier value $a$ and the addend value $c$
                    100: are given by
                    101: .PP
                    102: .RS 6
                    103: .EQ I
                    104: a~mark =~roman 5DEECE66D^sub 16~=~roman 273673163155^sub 8
                    105: .EN
                    106: .br
                    107: .EQ I
                    108: c~lineup =~roman B^sub 16~=~roman 13^sub 8 .
                    109: .EN
                    110: .RE
                    111: .PP
                    112: The value returned by any of the functions
                    113: .I drand48, erand48, lrand48, nrand48, mrand48\^
                    114: or
                    115: .I jrand48\^
                    116: is computed by first generating the next 48-bit $X sub i$ in the sequence.
                    117: Then the appropriate number of bits, according to the type of data item
                    118: to be returned, are copied from the high-order (leftmost) bits of $X sub i$
                    119: and transformed into the returned value.
                    120: .PP
                    121: The functions
                    122: .I drand48, lrand48\^
                    123: and
                    124: .I mrand48\^
                    125: store the last 48-bit $X sub i$ generated in an internal buffer,
                    126: and must be initialized prior to being invoked.
                    127: The functions
                    128: .I erand48, nrand48\^
                    129: and
                    130: .I jrand48\^
                    131: require the calling program to provide storage for the
                    132: successive $X sub i$ values in the array
                    133: specified as an argument when the functions are invoked.
                    134: These routines do not have to be initialized; the calling
                    135: program must place the desired initial value of $X sub i$ into the
                    136: array and pass it as an argument.
                    137: By using different
                    138: arguments, functions
                    139: .I erand48, nrand48\^
                    140: and
                    141: .I jrand48\^
                    142: allow separate modules of a large program to generate several
                    143: .I independent\^
                    144: streams of pseudo-random numbers, i.e., the sequence of numbers
                    145: in each stream will
                    146: .I not\^
                    147: depend upon how many times the routines have been called to generate
                    148: numbers for the other streams.
                    149: .PP
                    150: The initializer function
                    151: .I srand48\^
                    152: sets the high-order 32 bits of $X sub i$ to the 32 bits contained in
                    153: its argument.
                    154: The low-order 16 bits of $X sub i$ are set to the arbitrary value
                    155: $roman 330E sub 16 .$
                    156: .PP
                    157: The initializer function
                    158: .I seed48\^
                    159: sets the value of $X sub i$ to the 48-bit value specified in the
                    160: argument array.
                    161: In addition, the previous value of $X sub i$ is copied into a 48-bit
                    162: internal buffer, used only by
                    163: .I seed48,\^
                    164: and a pointer to this buffer is the value returned by
                    165: .I seed48.\^
                    166: This returned pointer, which can just be ignored if not needed, is useful
                    167: if a program is to be restarted from a given point at some future time
                    168: \(em use the pointer to get at and store the last $X sub i$ value, and
                    169: then use this value to reinitialize via
                    170: .I seed48\^
                    171: when the program is restarted.
                    172: .PP
                    173: The initialization function
                    174: .I lcong48\^
                    175: allows the user to specify the initial $X sub i ,$ the multiplier value
                    176: $a,$ and the addend value $c.$
                    177: Argument array elements
                    178: .I param[0-2]\^
                    179: specify $X sub i ,$
                    180: .I param[3-5]\^
                    181: specify the multiplier $a,$ and
                    182: .I param[6]\^
                    183: specifies the 16-bit addend $c.$
                    184: After
                    185: .I lcong48\^
                    186: has been called, a subsequent call to either
                    187: .I srand48\^
                    188: or
                    189: .I seed48\^
                    190: will restore the ``standard'' multiplier and addend values, $a$ and $c,$
                    191: specified on the previous page.
                    192: .SH "SEE ALSO"
                    193: rand(3L).
                    194: .Ee

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.