tensor-0.1.0
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
mt.h
1 // -*- mode: c++; fill-column: 80; c-basic-offset: 2; indent-tabs-mode: nil -*-
2 /*
3  Copyright (c) 2010 Juan Jose Garcia Ripoll
4 
5  Tensor is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published
7  by the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Library General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 #ifndef TENSOR_RAND_MT_H
20 #define TENSOR_RAND_MT_H
21 
22 #include "tensor/config.h"
23 #include <inttypes.h>
24 
25 namespace tensor {
26 
27 #if !defined(TENSOR_64BITS)
28 
29 /*
30  * 32 bits
31  */
32 
33 typedef uint32_t rand_uint;
34 
35 extern void init_genrand(uint32_t s);
36 extern void init_by_array(uint32_t init_key[], int key_length);
37 
38 /* generates a random number on [0,0xffffffff]-interval */
39 extern uint32_t genrand_int32(void);
40 
41 /* generates a random number on [0,0x7fffffff]-interval */
42 extern int32_t genrand_int31(void);
43 
44 #else
45 
46 /*
47  * 64 bits
48  */
49 
50 typedef uint64_t rand_uint;
51 
52 extern void init_genrand(uint64_t s);
53 extern void init_by_array(uint64_t init_key[], int key_length);
54 
55 /* generates a random number on [0,0xffffffff]-interval */
56 extern uint64_t genrand_int64(void);
57 
58 /* generates a random number on [0,0x7fffffff]-interval */
59 extern int64_t genrand_int63(void);
60 
61 #endif
62 
63 /* generates a random number on [0,1]-real-interval */
64 extern double genrand_real1(void);
65 
66 /* generates a random number on [0,1)-real-interval */
67 extern double genrand_real2(void);
68 
69 /* generates a random number on (0,1)-real-interval */
70 extern double genrand_real3(void);
71 
72 /* generates a random number on [0,1) with 53-bit resolution*/
73 extern double genrand_res53(void);
74 
75 } // namespace tensor
76 
77 #endif // !TENSOR_RAND_MT_H
78