00001 #ifndef RANDOM_CLASS
00002 #define RANDOM_CLASS
00003
00004
00005
00017
00018
00019 namespace RazorBack {
00020
00022 class Randombase_
00023 {
00024 private:
00025
00026
00027 mutable int Seed1, Seed2;
00028
00029
00030 public:
00031
00037 explicit Randombase_(int S1=0, int S2=0)
00038 {
00039 reset(S1, S2);
00040 }
00041
00043 virtual ~Randombase_() {}
00044
00050 void reset(int S1=0, int S2=0);
00051
00056 virtual double operator()(void) const =0;
00057
00058
00059 protected:
00060
00061 int int_rand(void) const;
00062 double dbl_rand(void) const;
00063 };
00064
00065
00067 class Randomuni_: public Randombase_
00068 {
00069
00070 public:
00071
00077 explicit Randomuni_(int S1=0, int S2=0):
00078 Randombase_(S1, S2) {}
00079
00081 double operator()(void) const { return dbl_rand(); }
00082
00084 double rnd_lim(double L, double U) const
00085 {
00086 return((L-U)*dbl_rand()+U);
00087 }
00088 };
00089
00090
00095 class Randomnorm_: public Randombase_
00096 {
00097
00098 public:
00099
00105 explicit Randomnorm_(int S1=0, int S2=0):
00106 Randombase_(S1, S2) {}
00107
00112 double operator()(void) const;
00113
00118 double rnd_msd(double M, double S) const
00119 {
00120 return( S*operator()()+M );
00121 }
00122 };
00123
00124
00125 }
00126
00127
00128
00129 #endif // RANDOM_CLASS