HG-MD  1
RNG.h
Go to the documentation of this file.
00001 #ifndef RNG_H
00002 #define RNG_H
00003 
00004 //Used by the randomise function
00005 #include <time.h>
00006 #include <cmath>
00007 #include "ExtendedMath.h"
00008 
00013 class RNG
00014 {
00015 public:
00016 
00017         RNG(){random_seed_LCG=0; a=1103515245; c=12345;m=1024*1024*1024;type=1;p=607;q=273;random_seed_LFG.resize(p); seed_LFG();}
00018 
00020         // (note the call to seed_LFG is only required really if using that type of generator, but the other one is always required
00021         void set_RandomSeed(Mdouble new_seed){random_seed_LCG=new_seed; seed_LFG();}
00022 
00024         Mdouble get_RN(Mdouble min, Mdouble max);
00025         
00027         Mdouble test();
00028         
00030         void set_LCGParms(int new_a,int new_c,int new_m)
00031         {a=new_a;c=new_c;m=new_m;}
00032         
00034         void randomise() {set_RandomSeed(time(NULL));}
00035         
00037         void set_LFGParms(int new_p, int new_q);
00038         
00040         void set_RNtypeLCG(){type=0;}
00041         
00043         void set_RNtypeLFG(){type=1;}
00044         
00045 private:
00046 
00048         Mdouble get_LCG(Mdouble min, Mdouble max);
00049 
00051         Mdouble get_LFG(Mdouble min, Mdouble max);
00052         
00054         void seed_LFG();
00055 
00057         unsigned long int random_seed_LCG;
00058         
00060         vector<Mdouble> random_seed_LFG;
00061         
00063         long int a,c,m;
00064         
00066         long int p,q;
00067         
00069         int type;
00070         
00071 };
00072 
00073 
00074 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines