Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

/ray/src/lib/numerics/rng/rng.h

Go to the documentation of this file.
00001 /*
00002  * lib/numerics/rng/rng.h
00003  * 
00004  * RNG base class definition. 
00005  * 
00006  * Copyright (c) 2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 
00007  * 
00008  * This file may be distributed and/or modified under the terms of the 
00009  * GNU General Public License version 2 as published by the Free Software 
00010  * Foundation. (See COPYING.GPL for details.)
00011  * 
00012  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014  * 
00015  */
00016 
00017 #ifndef _LIB_NUMERICS_RNG_RandomNumberGenerator_H_
00018 #define _LIB_NUMERICS_RNG_RandomNumberGenerator_H_ 1
00019 
00026 #include <lib/numerics/num_math.h>
00027 
00028 namespace NUM  // numerics
00029 {
00030 
00041 class RandomNumberGenerator_Base
00042 {
00043     public:
00044         // Some useful constants for scaling to the 0..1 range: 
00045         // --> See FPConst<dbl> in num_math.h. 
00046         
00048         RandomNumberGenerator_Base(const RandomNumberGenerator_Base &);
00050         void operator=(const RandomNumberGenerator_Base &);
00051     public:
00052         RandomNumberGenerator_Base() {}
00053         virtual ~RandomNumberGenerator_Base() {}
00054         
00063         virtual void seed(uint32 seed);
00064         
00073         virtual uint32 rand_uint32();
00075         virtual int32 rand_int32()
00076             {  return((int32)(rand_uint32()>>1));  }
00077         
00079         virtual dbl rand_dbl32o()
00080             {  return(rand_uint32()*FPConst<dbl>::div_1_pow_2_32);  }
00082         virtual dbl rand_dbl32()
00083             {  return(rand_uint32()*FPConst<dbl>::div_1_pow_2_32m1);  }
00084         
00086         virtual dbl rand_dbl53o()
00087         {
00088             uint32 a=rand_uint32()>>5, b=rand_uint32()>>6; 
00089             return( (a*67108864.0+b)*FPConst<dbl>::div_1_pow_2_53 );
00090         }
00092         virtual dbl rand_dbl53()
00093         {
00094             uint32 a=rand_uint32()>>5, b=rand_uint32()>>6; 
00095             return( (a*67108864.0+b)*FPConst<dbl>::div_1_pow_2_53m1 );
00096         }
00097 };
00098 
00099 
00109 class RandomNumberGenerator
00110 {
00111     private:
00112     public:
00113 };
00114 
00115 }  // end of namespace NUM
00116 
00117 #endif  /* _LIB_NUMERICS_RNG_RandomNumberGenerator_H_ */

Generated on Sat Feb 19 22:33:46 2005 for Ray by doxygen 1.3.5