1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
2 | // Nombres aleatoires pour Peida.
|
---|
3 | // NON CE N'EST PAS MON CODE ... C. Magneville 1996-2000
|
---|
4 | // DAPNIA/SPP (Saclay) / CEA LAL - IN2P3/CNRS (Orsay)
|
---|
5 |
|
---|
6 | #ifndef PERANDOM_SEEN
|
---|
7 | #define PERANDOM_SEEN
|
---|
8 |
|
---|
9 | #include "machdefs.h"
|
---|
10 | #include <stdlib.h>
|
---|
11 | #include "histos.h"
|
---|
12 | #include "srandgen.h"
|
---|
13 | #include <complex>
|
---|
14 |
|
---|
15 | namespace SOPHYA {
|
---|
16 |
|
---|
17 | class FunRan : public Histo {
|
---|
18 | public:
|
---|
19 | typedef r_8 (*Func)(r_8);
|
---|
20 | FunRan(Func f, r_8 xMin=0.0, r_8 xMax=1.0, int_4 nBin=100);
|
---|
21 | FunRan(r_8 *tab, int_4 nBin);
|
---|
22 | FunRan(r_8 *tab, int_4 nBin, r_8 xMin, r_8 xMax);
|
---|
23 | FunRan(Histo &h, bool pdf=true);
|
---|
24 | r_8 Random(void);
|
---|
25 | int_4 BinRandom(void);
|
---|
26 | };
|
---|
27 |
|
---|
28 | class FunRan2D {
|
---|
29 | public:
|
---|
30 | // typedef r_8 (*Func)(r_8, r_8);
|
---|
31 | // FunRan2D(Func f, r_8 xMin=0.0, r_8 xMax=1.0, int_4 nBinX=100,
|
---|
32 | // r_8 yMin=0.0, r_8 yMax=1.0, int_4 nBinY=100);
|
---|
33 | FunRan2D(r_8 *tab, int_4 nBinX, int_4 nBinY);
|
---|
34 | FunRan2D(r_8 **tab, int_4 nBinX, int_4 nBinY);
|
---|
35 | ~FunRan2D();
|
---|
36 | void Random(r_8& x, r_8& y);
|
---|
37 | void BinRandom(int_4& x, int_4& y);
|
---|
38 | private:
|
---|
39 | FunRan* ranX;
|
---|
40 | FunRan** ranY;
|
---|
41 | int_4 nx;
|
---|
42 | };
|
---|
43 |
|
---|
44 | //! Returns a random gaussian complex number with variance sig^2
|
---|
45 | inline complex< r_8 > ComplexGaussRan(double sig=1.)
|
---|
46 | {return complex< r_8 >(GauRnd(0.,sig),GauRnd(0.,sig));}
|
---|
47 |
|
---|
48 | } // namespace SOPHYA
|
---|
49 |
|
---|
50 | #endif
|
---|