xs/RNG.xs

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 30 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« lib/App/Sandy/Types.pm ↑ Summary xs/gauss.c »
1 #define PERL_NO_GET_CONTEXT
2 #include "EXTERN.h"
3 #include "perl.h"
4 #include "XSUB.h"
5  
6 #include "ppport.h"
7  
8 #include "sandy_rng.h"
9 #include "RNG.h"
10  
11 MODULE = App::Sandy::RNG PACKAGE = App::Sandy::RNG
12  
13 PROTOTYPES: DISABLED
14  
15 RNGContext *
16 App::Sandy::RNG::new (unsigned long seed)
17 PREINIT:
18 RNGContext *ctx;
19 CODE:
20 0 Newx (ctx, 1, RNGContext);
21 0 ctx->rng = gsl_rng_alloc (gsl_rng_ranlxd2);
22 0 gsl_rng_set (ctx->rng, seed);
23 0 RETVAL = ctx;
24 OUTPUT:
25 RETVAL
26  
27 void
28 DESTROY (RNGContext *ctx)
29 CODE:
30 0 Safefree (ctx->rng);
31 0 Safefree (ctx);
32  
33 void
34 set (RNGContext *ctx, unsigned long seed)
35 CODE:
36 0 gsl_rng_set (ctx->rng, seed);
37  
38 unsigned long
39 max (RNGContext *ctx)
40 CODE:
41 0 RETVAL = gsl_rng_max (ctx->rng);
42 OUTPUT:
43 RETVAL
44  
45 unsigned long
46 min (RNGContext *ctx)
47 CODE:
48 0 RETVAL = gsl_rng_min (ctx->rng);
49 OUTPUT:
50 RETVAL
51  
52 size_t
53 size (RNGContext *ctx)
54 CODE:
55 0 RETVAL = gsl_rng_size (ctx->rng);
56 OUTPUT:
57 RETVAL
58  
59 char *
60 name (RNGContext *ctx)
61 CODE:
62 0 RETVAL = (char *) gsl_rng_name (ctx->rng);
63 OUTPUT:
64 RETVAL
65  
66 unsigned long
67 get (RNGContext *ctx)
68 CODE:
69 0 RETVAL = gsl_rng_get (ctx->rng);
70 OUTPUT:
71 RETVAL
72  
73 double
74 uniform (RNGContext *ctx)
75 CODE:
76 0 RETVAL = gsl_rng_uniform (ctx->rng);
77 OUTPUT:
78 RETVAL
79  
80 double
81 uniform_pos (RNGContext *ctx)
82 CODE:
83 0 RETVAL = gsl_rng_uniform_pos (ctx->rng);
84 OUTPUT:
85 RETVAL
86  
87 double
88 ran_gaussian (RNGContext *ctx, double sigma)
89 CODE:
90 0 RETVAL = gsl_ran_gaussian (ctx->rng, sigma);
91 OUTPUT:
92 RETVAL
93  
94 double
95 ran_gaussian_ratio_method (RNGContext *ctx, double sigma)
96 CODE:
97 0 RETVAL = gsl_ran_gaussian_ratio_method (ctx->rng, sigma);
98 OUTPUT:
99 RETVAL
100  
101 double
102 ran_gaussian_pdf (double x, double sigma)
103 CODE:
104 0 RETVAL = gsl_ran_gaussian_pdf (x, sigma);
105 OUTPUT:
106 RETVAL
107  
108 double
109 ran_ugaussian (RNGContext *ctx)
110 CODE:
111 0 RETVAL = gsl_ran_ugaussian (ctx->rng);
112 OUTPUT:
113 RETVAL
114  
115 double
116 ran_ugaussian_ratio_method (RNGContext *ctx)
117 CODE:
118 0 RETVAL = gsl_ran_ugaussian_ratio_method (ctx->rng);
119 OUTPUT:
120 RETVAL
121  
122 double
123 ran_ugaussian_pdf (double x)
124 CODE:
125 0 RETVAL = gsl_ran_ugaussian_pdf (x);
126 OUTPUT:
127 RETVAL
128  
129 unsigned long
130 get_n (RNGContext *ctx, unsigned long n)
131 INIT:
132 0 ▶ if (n <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (n <= 0) 0 0 0
133 0 croak ("n must be greater than zero");
134 CODE:
135 0 ▶ RETVAL = gsl_rng_get (ctx->rng) % n;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = gsl_rng_get (ctx->rng) % n; 0 0 0
136 OUTPUT:
137 RETVAL
138  
139 double
140 get_norm (RNGContext *ctx, double mean, double stdd)
141 CODE:
142 0 ▶ RETVAL = mean + (int) (gsl_ran_gaussian (ctx->rng, stdd) + 0.5);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = mean + (int) (gsl_ran_gaussian (ctx->rng, stdd) + 0.5); 0 0 0
143 OUTPUT:
144 RETVAL
« lib/App/Sandy/Types.pm ↑ Summary xs/gauss.c »