Debian Codegraph @

external/gsl/gsl_rng__knuthran2.c

raw symbols SCIP
1 /* rng/knuthran2.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 * This implementation copyright (C) 2001 Carlo Perassi
29 * and (C) 2003 Heiko Bauke.
30 */
31
32 #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/
33 #include <stdlib.h>
34 #include "gsl_rng.h"cxx . . $ `<file>/external/gsl/gsl_rng.h`/
35
36 #include "gsl_rng__schrage.c"cxx . . $ `<file>/external/gsl/gsl_rng__schrage.c`/
37
38 #define AA1cxx . . $ `external/gsl/gsl_rng__knuthran2.c:38:9`! 271828183UL
39 #define AA2cxx . . $ `external/gsl/gsl_rng__knuthran2.c:39:9`! 1833324378UL /* = -314159269 mod (2 ^ 31 -1) */
40 #define MMcxx . . $ `external/gsl/gsl_rng__knuthran2.c:40:9`! 0x7fffffffUL /* 2 ^ 31 - 1 */
41 #define CEIL_SQRT_MMcxx . . $ `external/gsl/gsl_rng__knuthran2.c:41:9`! 46341UL /* sqrt(2 ^ 31 - 1) */
42
43 static inline unsigned long int ran_getcxx . . $ ran_get(751e5d26f8574c32). (void *vstate);
44 static double ran_get_doublecxx . . $ ran_get_double(a405b17f82753acc). (void *vstate);
45 static void ran_setcxx . . $ ran_set(5500c4293b1bbef0). (void *state, unsigned long int s);
46
47 typedef structcxx . . $ $anonymous_type_615e127b340c4437_0#
48 {
49 unsigned long int x0cxx . . $ $anonymous_type_615e127b340c4437_0#x0.;
50 unsigned long int x1cxx . . $ $anonymous_type_615e127b340c4437_0#x1.;
51 }
52 ran_state_tcxx . . $ ran_state_t#;
53
54 static inline unsigned long int
55 ran_getcxx . . $ ran_get(751e5d26f8574c32). (void *vstate)
56 {
57 ran_state_tcxx . . $ ran_state_t# *state = (ran_state_tcxx . . $ ran_state_t# *) vstate;
58
59 const unsigned long int xtmp = state->x1cxx . . $ $anonymous_type_615e127b340c4437_0#x1.;
60 state->x1cxx . . $ $anonymous_type_615e127b340c4437_0#x1. = schrage_multcxx . . $ schrage_mult(8f424044f20ee7cf). (AA1cxx . . $ `external/gsl/gsl_rng__knuthran2.c:38:9`!, state->x1cxx . . $ $anonymous_type_615e127b340c4437_0#x1., MMcxx . . $ `external/gsl/gsl_rng__knuthran2.c:40:9`!, CEIL_SQRT_MMcxx . . $ `external/gsl/gsl_rng__knuthran2.c:41:9`!)
61 + schrage_multcxx . . $ schrage_mult(8f424044f20ee7cf). (AA2cxx . . $ `external/gsl/gsl_rng__knuthran2.c:39:9`!, state->x0cxx . . $ $anonymous_type_615e127b340c4437_0#x0., MMcxx . . $ `external/gsl/gsl_rng__knuthran2.c:40:9`!, CEIL_SQRT_MMcxx . . $ `external/gsl/gsl_rng__knuthran2.c:41:9`!);
62
63 if (state->x1cxx . . $ $anonymous_type_615e127b340c4437_0#x1. >= MMcxx . . $ `external/gsl/gsl_rng__knuthran2.c:40:9`!)
64 state->x1cxx . . $ $anonymous_type_615e127b340c4437_0#x1. -= MMcxx . . $ `external/gsl/gsl_rng__knuthran2.c:40:9`!;
65
66 state->x0cxx . . $ $anonymous_type_615e127b340c4437_0#x0. = xtmp;
67
68 return state->x1cxx . . $ $anonymous_type_615e127b340c4437_0#x1.;
69 }
70
71 static double
72 ran_get_doublecxx . . $ ran_get_double(a405b17f82753acc). (void *vstate)
73 {
74 ran_state_tcxx . . $ ran_state_t# *state = (ran_state_tcxx . . $ ran_state_t# *) vstate;
75
76 return ran_getcxx . . $ ran_get(751e5d26f8574c32). (state) / 2147483647.0;
77 }
78
79 static void
80 ran_setcxx . . $ ran_set(5500c4293b1bbef0). (void *vstate, unsigned long int s)
81 {
82 ran_state_tcxx . . $ ran_state_t# *state = (ran_state_tcxx . . $ ran_state_t# *) vstate;
83
84 if ((s % MMcxx . . $ `external/gsl/gsl_rng__knuthran2.c:40:9`!) == 0)
85 s = 1; /* default seed is 1 */
86
87 state->x0cxx . . $ $anonymous_type_615e127b340c4437_0#x0. = s % MMcxx . . $ `external/gsl/gsl_rng__knuthran2.c:40:9`!;
88 state->x1cxx . . $ $anonymous_type_615e127b340c4437_0#x1. = s % MMcxx . . $ `external/gsl/gsl_rng__knuthran2.c:40:9`!;
89
90 return;
91 }
92
93 static const gsl_rng_typecxx . . $ gsl_rng_type# ran_typecxx . . $ ran_type. = {
94 "knuthran2", /* name */
95 MMcxx . . $ `external/gsl/gsl_rng__knuthran2.c:40:9`! - 1L, /* RAND_MAX */
96 0, /* 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_knuthran2cxx . . $ gsl_rng_knuthran2. = &ran_typecxx . . $ ran_type.;