1 /* -*- Mode: c; c-basic-offset: 2 -*-
2  *
3  * mtwist.h - Mersenne Twister header
4  *
5  * This is free and unencumbered software released into the public domain.
6  *
7  * Anyone is free to copy, modify, publish, use, compile, sell, or
8  * distribute this software, either in source code form or as a compiled
9  * binary, for any purpose, commercial or non-commercial, and by any
10  * means.
11  *
12  * In jurisdictions that recognize copyright laws, the author or authors
13  * of this software dedicate any and all copyright interest in the
14  * software to the public domain. We make this dedication for the benefit
15  * of the public at large and to the detriment of our heirs and
16  * successors. We intend this dedication to be an overt act of
17  * relinquishment in perpetuity of all present and future rights to this
18  * software under copyright law.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  *
28  * For more information, please refer to <http://unlicense.org/>
29  *
30  */
31 
32 #ifndef MTWIST_H
33 #define MTWIST_H
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /* Mersenne Twister state */
40 typedef struct mtwist_s mtwist;
41 
42 /* constructor */
43 mtwist* mtwist_new(void);
44 /* destructor */
45 void mtwist_free(mtwist* mt);
46 
47 /* methods */
48 void mtwist_init(mtwist* mt, unsigned long seed);
49 unsigned long mtwist_u32rand(mtwist* mt);
50 double mtwist_drand(mtwist* mt);
51 
52 /* utility functions */
53 unsigned long mtwist_seed_from_system(mtwist* mt);
54 
55 #ifdef __cplusplus
56 }
57 #endif
58 
59 #endif
60