| 1 | --- rand48.3.orig 2010-02-08 16:26:16.000000000 -0800 |
| 2 | +++ rand48.3 2010-02-13 19:48:39.000000000 -0800 |
| 3 | @@ -18,51 +18,68 @@ |
| 4 | .Sh NAME |
| 5 | .Nm drand48 , |
| 6 | .Nm erand48 , |
| 7 | +.Nm jrand48 , |
| 8 | +.Nm lcong48 , |
| 9 | .Nm lrand48 , |
| 10 | -.Nm nrand48 , |
| 11 | .Nm mrand48 , |
| 12 | -.Nm jrand48 , |
| 13 | -.Nm srand48 , |
| 14 | +.Nm nrand48 , |
| 15 | .Nm seed48 , |
| 16 | -.Nm lcong48 |
| 17 | +.Nm srand48 |
| 18 | .Nd pseudo random number generators and initialization routines |
| 19 | .Sh LIBRARY |
| 20 | .Lb libc |
| 21 | .Sh SYNOPSIS |
| 22 | .In stdlib.h |
| 23 | .Ft double |
| 24 | -.Fn drand48 void |
| 25 | +.Fo drand48 |
| 26 | +.Fa void |
| 27 | +.Fc |
| 28 | .Ft double |
| 29 | -.Fn erand48 "unsigned short xseed[3]" |
| 30 | +.Fo erand48 |
| 31 | +.Fa "unsigned short xsubi[3]" |
| 32 | +.Fc |
| 33 | .Ft long |
| 34 | -.Fn lrand48 void |
| 35 | +.Fo jrand48 |
| 36 | +.Fa "unsigned short xsubi[3]" |
| 37 | +.Fc |
| 38 | +.Ft void |
| 39 | +.Fo lcong48 |
| 40 | +.Fa "unsigned short param[7]" |
| 41 | +.Fc |
| 42 | .Ft long |
| 43 | -.Fn nrand48 "unsigned short xseed[3]" |
| 44 | +.Fo lrand48 |
| 45 | +.Fa void |
| 46 | +.Fc |
| 47 | .Ft long |
| 48 | -.Fn mrand48 void |
| 49 | +.Fo mrand48 |
| 50 | +.Fa void |
| 51 | +.Fc |
| 52 | .Ft long |
| 53 | -.Fn jrand48 "unsigned short xseed[3]" |
| 54 | -.Ft void |
| 55 | -.Fn srand48 "long seed" |
| 56 | +.Fo nrand48 |
| 57 | +.Fa "unsigned short xsubi[3]" |
| 58 | +.Fc |
| 59 | .Ft "unsigned short *" |
| 60 | -.Fn seed48 "unsigned short xseed[3]" |
| 61 | +.Fo seed48 |
| 62 | +.Fa "unsigned short seed16v[3]" |
| 63 | +.Fc |
| 64 | .Ft void |
| 65 | -.Fn lcong48 "unsigned short p[7]" |
| 66 | +.Fo srand48 |
| 67 | +.Fa "long seedval" |
| 68 | +.Fc |
| 69 | .Sh DESCRIPTION |
| 70 | The |
| 71 | .Fn rand48 |
| 72 | -family of functions generates pseudo-random numbers using a linear |
| 73 | +family of functions generates pseudo-random numbers, using a linear |
| 74 | congruential algorithm working on integers 48 bits in size. |
| 75 | The |
| 76 | particular formula employed is |
| 77 | -r(n+1) = (a * r(n) + c) mod m |
| 78 | -where the default values are |
| 79 | -for the multiplicand a = 0xfdeece66d = 25214903917 and |
| 80 | -the addend c = 0xb = 11. |
| 81 | +r(n+1) = (a * r(n) + c) mod m. |
| 82 | +The default value for the multiplicand `a' is 0x5deece66d (25214903917). |
| 83 | +The default value for the the addend `c' is 0xb (11). |
| 84 | The modulo is always fixed at m = 2 ** 48. |
| 85 | r(n) is called the seed of the random number generator. |
| 86 | .Pp |
| 87 | -For all the six generator routines described next, the first |
| 88 | +For the six generator routines described next, the first |
| 89 | computational step is to perform a single iteration of the algorithm. |
| 90 | .Pp |
| 91 | The |
| 92 | @@ -124,7 +141,7 @@ is used to initialize the internal buffe |
| 93 | .Fn drand48 , |
| 94 | .Fn lrand48 , |
| 95 | and |
| 96 | -.Fn mrand48 |
| 97 | +.Fn mrand48 , |
| 98 | such that the 32 bits of the seed value are copied into the upper 32 bits |
| 99 | of r(n), with the lower 16 bits of r(n) arbitrarily being set to 0x330e. |
| 100 | Additionally, the constant multiplicand and addend of the algorithm are |
| 101 | @@ -147,7 +164,7 @@ The |
| 102 | .Fn seed48 |
| 103 | function |
| 104 | returns a pointer to an array of 3 shorts which contains the old seed. |
| 105 | -This array is statically allocated, thus its contents are lost after |
| 106 | +This array is statically allocated; thus, its contents are lost after |
| 107 | each new call to |
| 108 | .Fn seed48 . |
| 109 | .Pp |