Statistics for MySQL  1.1
 All Classes Files Functions Variables Typedefs Macros Pages
sqlrand.h
Go to the documentation of this file.
1 /* sqlrand.h (Random numbers) */
2 
3 /***********************************************************************
4 * This code is part of Statistics for MySQL.
5 *
6 * Copyright (C) 2011 Heinrich Schuchardt (xypron.glpk@gmx.de)
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 ***********************************************************************/
20 
26 #ifndef SQLRAND_H
27 
28 #define SQLRAND_H 1
29 
30 #define MT_LEN 624
31 #define MT_IA 397
32 #define MT_IB (MT_LEN - MT_IA)
33 #define UPPER_MASK 0x80000000
34 #define LOWER_MASK 0x7FFFFFFF
35 #define MATRIX_A 0x9908B0DF
39 #define TWIST(b,i,j) ((b)[i] & UPPER_MASK) | ((b)[j] & LOWER_MASK)
40 
41 #define MAGIC(s) (((s)&1)*MATRIX_A)
42 
43 namespace sqlstat {
44 
61 
62 private:
63 public:
71  static void deinit();
79  static void init();
86  static double nextDouble();
94  static unsigned long random();
103  static double gaussian();
104 };
105 }
106 #endif // SQLRAND_H
static void deinit()
Deinitialize the class.
Definition: sqlrand.cc:45
static double nextDouble()
Returns random double number.
Definition: sqlrand.cc:104
static double gaussian()
Returns variate of the normal distribution.
Definition: sqlrand.cc:111
static void init()
Initialize the class.
Definition: sqlrand.cc:51
Mersenne Twister random number generator.
Definition: sqlrand.h:60
Definition: gini.cc:34
static unsigned long random()
Returns random integer number.
Definition: sqlrand.cc:69