Debian Codegraph @

external/gsl/gsl_rng__fishman20.c

raw symbols SCIP
1 /* rng/fishman20.c
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 3 of the License, or (at
6 * your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17
18 /*
19 * This generator is taken from
20 *
21 * Donald E. Knuth
22 * The Art of Computer Programming
23 * Volume 2
24 * Third Edition
25 * Addison-Wesley
26 * Page 108
27 *
28 * It is called "Fishman"
29 *
30 * This implementation copyright (C) 2001 Carlo Perassi
31 * and (C) 2003 Heiko Bauke.
32 */
33
34 #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/
35 #include <stdlib.h>
36 #include "gsl_rng.h"cxx . . $ `<file>/external/gsl/gsl_rng.h`/
37
38 static inline unsigned long int ran_getcxx . . $ ran_get(751e5d26f8574c32). (void *vstate);
39 static double ran_get_doublecxx . . $ ran_get_double(a405b17f82753acc). (void *vstate);
40 static void ran_setcxx . . $ ran_set(5500c4293b1bbef0). (void *state, unsigned long int s);
41
42 static const long int mcxx . . $ m. = 2147483647, acxx . . $ a. = 48271, qcxx . . $ q. = 44488, rcxx . . $ r. = 3399;
43
44 typedef structcxx . . $ $anonymous_type_8cffabcb93dd3848_0#
45 {
46 unsigned long int xcxx . . $ $anonymous_type_8cffabcb93dd3848_0#x.;
47 }
48 ran_state_tcxx . . $ ran_state_t#;
49
50 static inline unsigned long int
51 ran_getcxx . . $ ran_get(751e5d26f8574c32). (void *vstate)
52 {
53 ran_state_tcxx . . $ ran_state_t# *state = (ran_state_tcxx . . $ ran_state_t# *) vstate;
54
55 const unsigned long int x = state->xcxx . . $ $anonymous_type_8cffabcb93dd3848_0#x.;
56
57 const long int h = x / qcxx . . $ q.;
58 const long int t = acxx . . $ a. * (x - h * qcxx . . $ q.) - h * rcxx . . $ r.;
59
60 if (t < 0)
61 {
62 state->xcxx . . $ $anonymous_type_8cffabcb93dd3848_0#x. = t + mcxx . . $ m.;
63 }
64 else
65 {
66 state->xcxx . . $ $anonymous_type_8cffabcb93dd3848_0#x. = t;
67 }
68
69 return state->xcxx . . $ $anonymous_type_8cffabcb93dd3848_0#x.;
70 }
71
72 static double
73 ran_get_doublecxx . . $ ran_get_double(a405b17f82753acc). (void *vstate)
74 {
75 ran_state_tcxx . . $ ran_state_t# *state = (ran_state_tcxx . . $ ran_state_t# *) vstate;
76
77 return ran_getcxx . . $ ran_get(751e5d26f8574c32). (state) / 2147483647.0;
78 }
79
80 static void
81 ran_setcxx . . $ ran_set(5500c4293b1bbef0). (void *vstate, unsigned long int s)
82 {
83 ran_state_tcxx . . $ ran_state_t# *state = (ran_state_tcxx . . $ ran_state_t# *) vstate;
84
85 if ((s%mcxx . . $ m.) == 0)
86 s = 1; /* default seed is 1 */
87
88 state->xcxx . . $ $anonymous_type_8cffabcb93dd3848_0#x. = s & mcxx . . $ m.;
89
90 return;
91 }
92
93 static const gsl_rng_typecxx . . $ gsl_rng_type# ran_typecxx . . $ ran_type. = {
94 "fishman20", /* name */
95 2147483646, /* RAND_MAX */
96 1, /* RAND_MIN */
97 sizeof (ran_state_tcxx . . $ ran_state_t#),
98 &ran_setcxx . . $ ran_set(5500c4293b1bbef0).,
99 &ran_getcxx . . $ ran_get(751e5d26f8574c32).,
100 &ran_get_doublecxx . . $ ran_get_double(a405b17f82753acc).
101 };
102
103 const gsl_rng_typecxx . . $ gsl_rng_type# *gsl_rng_fishman20cxx . . $ gsl_rng_fishman20. = &ran_typecxx . . $ ran_type.;