source: Sophya/trunk/SophyaLib/BaseTools/srandgen.h@ 2323

Last change on this file since 2323 was 2323, checked in by ansari, 23 years ago

Compil sous MacOSX/Darwin g++ 2.95 et MAJ numero de version - Reza 11/02/2003

File size: 1.7 KB
RevLine 
[851]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
[2323]14#if defined(Darwin) && defined(__GNUC__) && (__GNUC__ < 3)
15/* Declaration de drand48 et srand48 etc , mis ds SysSpec
16 Reza 11/02/2003 */
17unsigned short int * seed48 (unsigned short int seed16v[3]);
18void srand48 (long seedval);
19/* Faute de mieux pour le moment : */
20double drand48() { return ((double)(random())/LONG_MAX) ; }
21#endif
22
[851]23#define frand01() ( (float) drand48() )
24#define drand01() ( drand48() )
25#define ranf01() drand01()
26
27#define frandpm1() ( 2. * frand01() - 1.)
28#define drandpm1() ( 2. * drand01() - 1.)
29#define ranfpm1() drandpm1()
30
31struct tirage_alea {
32 int Nbin;
33 double Min,Max,Lbin;
34 double *Tab;
35};
36typedef struct tirage_alea TIREALEA;
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42void Ini_Ranf_Quick(long seed_val, int lp);
43void Ini_Ranf(unsigned short seed_16v[3], int lp);
44void Get_Ranf(unsigned short seed_16v[3], int lp);
45void Auto_Ini_Ranf(int lp);
46
47void SetGauRange(double range);
48float NorRand1(void);
49double GauRnd1(double am, double s);
50float NorRand(void);
51double GauRnd(double am, double s);
52int NormCo(double *a,double *b
53 ,double mx,double my,double sx,double sy,double ro);
54void NormGau(double *x,double *y
55 ,double mx,double my,double sa,double sb,double teta);
56
57TIREALEA *init_tirage_alea(int nbin,double xmin,double xmax,double (*fonc) (double));
58double tirage_alea(TIREALEA *alea);
59int end_tirage_alea(TIREALEA *alea);
60
61#ifdef __cplusplus
62}
63#endif
64
65#endif
66
Note: See TracBrowser for help on using the repository browser.