diff --git a/tracy/tracy/src/mathlib.cc b/tracy/tracy/src/mathlib.cc index 86e318c4c5ece423d75c05cb71e744779982b4ed..d84458e98206e691db1afc1938bdfd824f3ccc44 100644 --- a/tracy/tracy/src/mathlib.cc +++ b/tracy/tracy/src/mathlib.cc @@ -39,15 +39,68 @@ void iniranf(const long i) rseed0 = i; rseed = i; } + #define k 19 #define c 656329L #define m 100000001 +/****************************************************************************/ +/* void newseed(void) + + Purpose: define a new seed + + input: + none + + output: + none + + return: + none + + global variables: + rseed0 + rseed + k, c, m + + specific functions: + none + + comments + none + +****************************************************************************/ void newseed(void) { rseed0 = (k*rseed0+c) % m; rseed = (rseed0+54321) % m; } +/****************************************************************************/ +/* double ranf(void) + + Purpose: Generate a random number with rectangular distribution/uniform + distribution between the value [0, m] + + input: + none + + output: + none + + return: + random number of type double + + global variables: + rseed0 + rseed + k, c, m + + specific functions: + none + + comments + none +****************************************************************************/ double ranf(void) { /* Generate random number with rectangular distribution */ @@ -58,7 +111,30 @@ double ranf(void) #undef c #undef m +/****************************************************************************/ +/* void setrancut(double cut) + + Purpose: Set a cut for normal distribution + + input: + cut : number of sigma for cutting the distribution + + output: + none + + return: + none + + global variables: + normcut_ + + specific functions: + none + comments + none + +****************************************************************************/ void setrancut(const double cut) { @@ -68,7 +144,34 @@ void setrancut(const double cut) normcut_ = cut; } +/****************************************************************************/ +/* double normranf(void) + + Purpose: + Generate random numbers with Gaussian/normal distribution (m=0, sigma=1) + and cut normcut_ + + input: + none + + output: + none + return: + random number + + global variables: + normcut_ + maxiter + + specific functions: + ranf + + comments + none + +****************************************************************************/ +/* maximum number of iteration to generate the random number */ #define maxiter 100 double normranf(void) {