GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
randmtzig.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2006-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 /*
24  A C-program for MT19937, with initialization improved 2002/2/10.
25  Coded by Takuji Nishimura and Makoto Matsumoto.
26  This is a faster version by taking Shawn Cokus's optimization,
27  Matthe Bellew's simplification, Isaku Wada's real version.
28  David Bateman added normal and exponential distributions following
29  Marsaglia and Tang's Ziggurat algorithm.
30 
31  Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
32  Copyright (C) 2004, David Bateman
33  All rights reserved.
34 
35  Redistribution and use in source and binary forms, with or without
36  modification, are permitted provided that the following conditions
37  are met:
38 
39  1. Redistributions of source code must retain the above copyright
40  notice, this list of conditions and the following disclaimer.
41 
42  2. Redistributions in binary form must reproduce the above copyright
43  notice, this list of conditions and the following disclaimer in the
44  documentation and/or other materials provided with the distribution.
45 
46  3. The names of its contributors may not be used to endorse or promote
47  products derived from this software without specific prior written
48  permission.
49 
50  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
54  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
55  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
56  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
57  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
58  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
59  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
60  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 
62 */
63 
64 #if ! defined (octave_randmtzig_h)
65 #define octave_randmtzig_h 1
66 
67 #include "octave-config.h"
68 
69 #define MT_N 624
70 
71 // Mersenne Twister.
72 extern OCTAVE_API void oct_init_by_int (uint32_t s);
73 extern OCTAVE_API void oct_init_by_array (uint32_t *init_key, int key_length);
74 extern OCTAVE_API void oct_init_by_entropy (void);
75 extern OCTAVE_API void oct_set_state (uint32_t *save);
76 extern OCTAVE_API void oct_get_state (uint32_t *save);
77 
78 // Array generators.
79 extern OCTAVE_API double oct_randu (void);
80 extern OCTAVE_API double oct_randn (void);
81 extern OCTAVE_API double oct_rande (void);
82 
83 extern OCTAVE_API float oct_float_randu (void);
84 extern OCTAVE_API float oct_float_randn (void);
85 extern OCTAVE_API float oct_float_rande (void);
86 
87 // Array generators.
88 extern OCTAVE_API void oct_fill_randu (octave_idx_type n, double *p);
89 extern OCTAVE_API void oct_fill_randn (octave_idx_type n, double *p);
90 extern OCTAVE_API void oct_fill_rande (octave_idx_type n, double *p);
91 
92 extern OCTAVE_API void oct_fill_float_randu (octave_idx_type n, float *p);
93 extern OCTAVE_API void oct_fill_float_randn (octave_idx_type n, float *p);
94 extern OCTAVE_API void oct_fill_float_rande (octave_idx_type n, float *p);
95 
96 #endif
OCTAVE_API void oct_init_by_array(uint32_t *init_key, int key_length)
Definition: randmtzig.cc:213
OCTAVE_API void oct_fill_float_randn(octave_idx_type n, float *p)
Definition: randmtzig.cc:853
OCTAVE_API void oct_fill_float_randu(octave_idx_type n, float *p)
Definition: randmtzig.cc:845
OCTAVE_API double oct_randu(void)
Definition: randmtzig.cc:408
OCTAVE_API float oct_float_randu(void)
Definition: randmtzig.cc:415
s
Definition: file-io.cc:2682
OCTAVE_API void oct_init_by_int(uint32_t s)
Definition: randmtzig.cc:192
OCTAVE_API void oct_fill_randu(octave_idx_type n, double *p)
Definition: randmtzig.cc:821
OCTAVE_API void oct_get_state(uint32_t *save)
Definition: randmtzig.cc:302
OCTAVE_API void oct_init_by_entropy(void)
Definition: randmtzig.cc:254
OCTAVE_API void oct_fill_float_rande(octave_idx_type n, float *p)
Definition: randmtzig.cc:861
OCTAVE_API double oct_rande(void)
Definition: randmtzig.cc:627
OCTAVE_API double oct_randn(void)
Definition: randmtzig.cc:562
OCTAVE_API void oct_set_state(uint32_t *save)
Definition: randmtzig.cc:292
p
Definition: lu.cc:138
OCTAVE_API float oct_float_randn(void)
Definition: randmtzig.cc:752
OCTAVE_API void oct_fill_rande(octave_idx_type n, double *p)
Definition: randmtzig.cc:837
OCTAVE_API void oct_fill_randn(octave_idx_type n, double *p)
Definition: randmtzig.cc:829
OCTAVE_API float oct_float_rande(void)
Definition: randmtzig.cc:793