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

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

Compil sur MacOSX 10.1 / g++ 2.95 apres passage xxstream.h -> xxstrem et compil g++ 3.2 / Reza 11/02/03

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