/* fonctions pour generateurs aleatoires */ /* cmv 23/06/94 */ /* R.Ansari 04/2000 Copie de nbrand.h .c */ #ifndef SRANDGEN_H_SEEN #define SRANDGEN_H_SEEN #include "machdefs.h" #include #ifdef __MWERKS__ #include "unixmac.h" #endif #if defined(Darwin) && defined(__GNUC__) && (__GNUC__ < 3) /* Declaration de drand48 et srand48 etc , mis ds SysSpec Reza 11/02/2003 */ unsigned short int * seed48 (unsigned short int seed16v[3]); void srand48 (long seedval); /* Faute de mieux pour le moment : */ double drand48() { return ((double)(random())/LONG_MAX) ; } #endif #define frand01() ( (float) drand48() ) #define drand01() ( drand48() ) #define ranf01() drand01() #define frandpm1() ( 2. * frand01() - 1.) #define drandpm1() ( 2. * drand01() - 1.) #define ranfpm1() drandpm1() struct tirage_alea { int Nbin; double Min,Max,Lbin; double *Tab; }; typedef struct tirage_alea TIREALEA; #ifdef __cplusplus extern "C" { #endif void Ini_Ranf_Quick(long seed_val, int lp); void Ini_Ranf(unsigned short seed_16v[3], int lp); void Get_Ranf(unsigned short seed_16v[3], int lp); void Auto_Ini_Ranf(int lp); void SetGauRange(double range); float NorRand1(void); double GauRnd1(double am, double s); float NorRand(void); double GauRnd(double am, double s); int NormCo(double *a,double *b ,double mx,double my,double sx,double sy,double ro); void NormGau(double *x,double *y ,double mx,double my,double sa,double sb,double teta); TIREALEA *init_tirage_alea(int nbin,double xmin,double xmax,double (*fonc) (double)); double tirage_alea(TIREALEA *alea); int end_tirage_alea(TIREALEA *alea); #ifdef __cplusplus } #endif #endif