Statistics for MySQL  0.9
sqlrand.h
Go to the documentation of this file.
00001 /* sqlrand.h (Random numbers) */
00002 
00003 /***********************************************************************
00004 *  This code is part of Statistics for MySQL.
00005 *
00006 *  Copyright (C) 2011 Heinrich Schuchardt (xypron.glpk@gmx.de)
00007 *
00008 *  Licensed under the Apache License, Version 2.0 (the "License");
00009 *  you may not use this file except in compliance with the License.
00010 *  You may obtain a copy of the License at
00011 *
00012 *      http://www.apache.org/licenses/LICENSE-2.0
00013 *
00014 *  Unless required by applicable law or agreed to in writing, software
00015 *  distributed under the License is distributed on an "AS IS" BASIS,
00016 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00017 *  See the License for the specific language governing permissions and
00018 *  limitations under the License.
00019 ***********************************************************************/
00020 
00026 #ifndef SQLRAND_H
00027 
00028 #define SQLRAND_H 1
00029 
00030 #define MT_LEN          624 
00031 #define MT_IA           397 
00032 #define MT_IB           (MT_LEN - MT_IA) 
00033 #define UPPER_MASK      0x80000000       
00034 #define LOWER_MASK      0x7FFFFFFF       
00035 #define MATRIX_A        0x9908B0DF       
00039 #define TWIST(b,i,j)    ((b)[i] & UPPER_MASK) | ((b)[j] & LOWER_MASK)
00040 
00041 #define MAGIC(s)        (((s)&1)*MATRIX_A)
00042 
00043 namespace sqlstat{
00044   
00060   class MersenneTwister {
00061 
00062   private:
00063   public:
00071     static void deinit();
00079     static void init();
00086     static double nextDouble();
00094     static unsigned long random();
00103     static double gaussian();
00104   };
00105 }
00106 #endif // SQLRAND_H
 All Classes Files Functions Variables Typedefs Defines