1 | /* fonctions pour generateurs aleatoires */
|
---|
2 | /* cmv 23/06/94 */
|
---|
3 | /* R.Ansari 04/2000 Copie de nbrand.h .c */
|
---|
4 |
|
---|
5 | #ifndef SRANDGEN_H_SEEN
|
---|
6 | #define SRANDGEN_H_SEEN
|
---|
7 |
|
---|
8 | #include "machdefs.h"
|
---|
9 | #include <stdlib.h>
|
---|
10 | #ifdef __MWERKS__
|
---|
11 | #include "unixmac.h"
|
---|
12 | #endif
|
---|
13 |
|
---|
14 | #if defined(Darwin) && defined(__GNUC__) && (__GNUC__ < 3)
|
---|
15 | #include "osx_values.h"
|
---|
16 | /* Declaration de drand48 et srand48 etc , mis ds SysSpec
|
---|
17 | Reza 11/02/2003 */
|
---|
18 | #ifdef __cplusplus
|
---|
19 | extern "C" {
|
---|
20 | #endif
|
---|
21 | unsigned short int * seed48(unsigned short int seed16v[3]);
|
---|
22 | void srand48(long seedval);
|
---|
23 | /* Faute de mieux pour le moment : */
|
---|
24 | #ifdef __cplusplus
|
---|
25 | }
|
---|
26 | #endif
|
---|
27 | #define drand48() ((double)(random())/LONG_MAX)
|
---|
28 | #endif
|
---|
29 |
|
---|
30 | #define frand01() ( (float) drand48() )
|
---|
31 | #define drand01() ( drand48() )
|
---|
32 | #define ranf01() drand01()
|
---|
33 |
|
---|
34 | #define frandpm1() ( 2. * frand01() - 1.)
|
---|
35 | #define drandpm1() ( 2. * drand01() - 1.)
|
---|
36 | #define ranfpm1() drandpm1()
|
---|
37 |
|
---|
38 | struct tirage_alea {
|
---|
39 | int Nbin;
|
---|
40 | double Min,Max,Lbin;
|
---|
41 | double *Tab;
|
---|
42 | };
|
---|
43 | typedef struct tirage_alea TIREALEA;
|
---|
44 |
|
---|
45 | #ifdef __cplusplus
|
---|
46 | extern "C" {
|
---|
47 | #endif
|
---|
48 |
|
---|
49 | void Ini_Ranf_Quick(long seed_val, int lp);
|
---|
50 | void Ini_Ranf(unsigned short seed_16v[3], int lp);
|
---|
51 | void Get_Ranf(unsigned short seed_16v[3], int lp);
|
---|
52 | void Auto_Ini_Ranf(int lp);
|
---|
53 |
|
---|
54 | void SetGauRange(double range);
|
---|
55 | float NorRand1(void);
|
---|
56 | double GauRnd1(double am, double s);
|
---|
57 | float NorRand(void);
|
---|
58 | double GauRnd(double am, double s);
|
---|
59 | int NormCo(double *a,double *b
|
---|
60 | ,double mx,double my,double sx,double sy,double ro);
|
---|
61 | void NormGau(double *x,double *y
|
---|
62 | ,double mx,double my,double sa,double sb,double teta);
|
---|
63 |
|
---|
64 | TIREALEA *init_tirage_alea(int nbin,double xmin,double xmax,double (*fonc) (double));
|
---|
65 | double tirage_alea(TIREALEA *alea);
|
---|
66 | int end_tirage_alea(TIREALEA *alea);
|
---|
67 |
|
---|
68 | #ifdef __cplusplus
|
---|
69 | }
|
---|
70 | #endif
|
---|
71 |
|
---|
72 | #endif
|
---|
73 |
|
---|