#include "cs_defs.h"#include <assert.h>#include <math.h>#include "bft_error.h"#include "cs_random.h" Include dependency graph for cs_random.c:
 Include dependency graph for cs_random.c:| Functions | |
| void | cs_random_seed (int seed) | 
| Initialize random number generator.  More... | |
| void | cs_random_uniform (cs_lnum_t n, cs_real_t a[]) | 
| Uniform distribution random number generator.  More... | |
| void | cs_random_normal (cs_lnum_t n, cs_real_t x[]) | 
| Normal distribution random number generator.  More... | |
| void | cs_random_poisson (cs_lnum_t n, cs_real_t mu, int p[]) | 
| Poisson distribution random number generator.  More... | |
| void | cs_random_save (cs_real_t save_block[1634]) | 
| Save static variables used by random number generator.  More... | |
| void | cs_random_restore (cs_real_t save_block[1634]) | 
| Restore static variables used by random number generator.  More... | |
Random number generation.
Based on the uniform, gaussian, and poisson random number generation code from netlib.org: lagged (-273,-607) Fibonacci; Box-Muller; by W.P. Petersen, IPS, ETH Zuerich.
Normal distribution random number generator.
Box-Muller method for Gaussian random numbers.
| [in] | n | number of values to compute | 
| [out] | x | pseudo-random numbers following normal distribution | 
Poisson distribution random number generator.
q(mu,p) = exp(-mu) mu**p/p!
| [in] | n | number of values to compute | 
| [in] | mu | Poisson distribution parameter | 
| [out] | p | pseudo-random numbers following Poisson distribution | 
| void cs_random_restore | ( | cs_real_t | save_block[1634] | ) | 
Restore static variables used by random number generator.
| [out] | save_block | saved state values | 
| void cs_random_save | ( | cs_real_t | save_block[1634] | ) | 
Save static variables used by random number generator.
| [out] | save_block | saved state values | 
| void cs_random_seed | ( | int | seed | ) | 
Initialize random number generator.
Generates initial seed buffer by linear congruential method. Taken from Marsaglia, FSU report FSU-SCRI-87-50.
| [in] | seed | variable seed, with 0 < seed < 31328 | 
Uniform distribution random number generator.
Portable lagged Fibonacci series uniform random number generator with "lags" -273 und -607: W.P. Petersen, IPS, ETH Zuerich, 19 Mar. 92
| [in] | n | number of values to compute | 
| [out] | a | pseudo-random numbers following uniform distribution |