home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume28 / mrandom-3.0 / part01 / src / bentley.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-06  |  2.1 KB  |  58 lines

  1. /* bentley.h 3.1 5/28/93 */
  2. /*  Original Author: Jon Bentley                    */
  3. /*    (Source code obtained from DIMACS shared account, March 1992.)*/
  4. /*                                    */
  5. /*  Header file/mrandom interface by Clark Thomborson, May 1992     */
  6. /*  Vectorized interface by Clark Thomborson, June 1992            */
  7. /*  Updated mrandom interface by Robert Plotkin, Feb/March 1993     */
  8. /*                                                                  */
  9. /*  This file contains a set of c-language functions for generating */
  10. /*  uniform integers.   This is a COMPLETELY PORTABLE generator.    */
  11. /*  It will give IDENTICAL sequences of random numbers for any      */
  12. /*  architecture with at least 30-bit integers, regardless of the   */
  13. /*  integer representation, MAXINT value, or roundoff/truncation    */
  14. /*  method, etc.                                                    */
  15.  
  16. /*  This Truly Remarkable RNG is described more fully in            */
  17. /*  J. Bentley's column, ``The Software Exploratorium ''            */
  18. /*  to appear in Unix Review in 1991.                               */ 
  19. /*  It is based on one in Knuth, Vol 2, Section 3.2.2 (Algorithm A) */ 
  20.  
  21. #ifndef MRANDOM
  22. #include "mrandom.h"
  23. #endif
  24.  
  25. #define PRANDMAX          1000000000
  26.  
  27. /* Information for mrandom */
  28. #define RNGstatesize_2    57
  29. #define RNGseedsize_2     1
  30. #define RNGrange_2        (double)PRANDMAX
  31. #define RNGname_2         "(Knuth/Bentley prand: lagged Fibbonacci)\n"
  32. #define RNGreturns_2      RET_LONG
  33. #define RNGstatetype_2    STATE_LONG
  34. #define RNGdgen_2        0
  35. #define RNGlgen_2        _lprand
  36. #define RNGseed_2         _lprand_seed
  37. #define RNGcheck_2        _lprand_check
  38.  
  39. /*----RNG Initializer------------*/
  40. /* Call once before using lprand */ 
  41.  
  42. void sprand (/* long seed, rngstate[RNGstatesize_2] */);
  43.  
  44. /*---------RNG---------------------*/
  45. /* Returns a long integer in the range 0...PRANDMAX-1 */ 
  46.  
  47. long lprand(/* long rngstate[RNGstatesize_2] */);
  48.  
  49. /*---------CKRAND---------------------*/
  50. /* Returns 0 if rngstate is corrupted */
  51.  
  52. int ckrand(/* long rngstate */);
  53.  
  54. /* mrandom interface routines */
  55. long _lprand(/*RNGdata **/);
  56. void _lprand_seed(/*RNGdata *, long **/);
  57. int _lprand_check(/*RNGdata **/);
  58.