00001 /* The original code included the following notice: */ 00002 /* 00003 A C-program for MT19937, with initialization improved 2002/1/26. 00004 Coded by Takuji Nishimura and Makoto Matsumoto. 00005 00006 Before using, initialize the state by using init_genrand(seed) 00007 or init_by_array(init_key, key_length). 00008 00009 Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, 00010 All rights reserved. 00011 00012 Redistribution and use in source and binary forms, with or without 00013 modification, are permitted provided that the following conditions 00014 are met: 00015 00016 1. Redistributions of source code must retain the above copyright 00017 notice, this list of conditions and the following disclaimer. 00018 00019 2. Redistributions in binary form must reproduce the above copyright 00020 notice, this list of conditions and the following disclaimer in the 00021 documentation and/or other materials provided with the distribution. 00022 00023 3. The names of its contributors may not be used to endorse or promote 00024 products derived from this software without specific prior written 00025 permission. 00026 00027 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00028 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00029 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00030 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 00031 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00032 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00033 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00034 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00035 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00036 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00037 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00038 00039 00040 Any feedback is very welcome. 00041 http://www.math.keio.ac.jp/matumoto/emt.html 00042 email: matumoto@math.keio.ac.jp 00043 */ 00044 00045 #ifndef INCLUDE__RANDOM_H__FILE 00046 #define INCLUDE__RANDOM_H__FILE 00047 00052 class EGRandom { 00053 public: 00054 static unsigned long NextInt(); 00055 static int NextInt(int from, int to); 00056 static double NextReal(); 00057 static void SetSeed(unsigned); 00058 static void SaveSeed(const char*); 00059 static void LoadSeed(const char*); 00060 00061 private: 00062 enum { N = 624 }; 00063 enum { M = 397 }; 00064 static const unsigned long MATRIX_A; 00065 static const unsigned long UPPER_MASK; 00066 static const unsigned long LOWER_MASK; 00068 static unsigned long mt[N]; 00070 static int mti; 00071 00072 static void init_genrand(unsigned long seed); 00073 static unsigned long genrand_int32(); 00074 static double genrand_real2(); 00075 }; 00076 00077 #endif //INCLUDE__RANDOM_H__FILE