"Fossies" - the Fresh Open Source Software Archive

Member "cfitsio-4.0.0/simplerng.h" (20 May 2021, 1078 Bytes) of package /linux/misc/cfitsio-4.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "simplerng.h" see the Fossies "Dox" file reference documentation.

    1 /* 
    2    Simple Random Number Generators
    3        - getuniform - uniform deviate [0,1]
    4        - getnorm    - gaussian (normal) deviate (mean=0, stddev=1)
    5        - getpoisson - poisson deviate for given expected mean lambda
    6 
    7    This code is adapted from SimpleRNG by John D Cook, which is
    8    provided in the public domain.
    9 
   10    The original C++ code is found here:
   11    http://www.johndcook.com/cpp_random_number_generation.html
   12 
   13    This code has been modified in the following ways compared to the
   14    original.
   15      1. convert to C from C++
   16      2. keep only uniform, gaussian and poisson deviates
   17      3. state variables are module static instead of class variables
   18      4. provide an srand() equivalent to initialize the state
   19 */
   20 
   21 extern void simplerng_setstate(unsigned int u, unsigned int v);
   22 extern void simplerng_getstate(unsigned int *u, unsigned int *v);
   23 extern void simplerng_srand(unsigned int seed);
   24 extern double simplerng_getuniform(void);
   25 extern double simplerng_getnorm(void);
   26 extern int simplerng_getpoisson(double lambda);
   27 extern double simplerng_logfactorial(int n);