Random.xs

filter: Statementstmt 20.0% 4 / 20 Branchbran 16.6% 1 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 19.2% 5 / 26 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Math/test2.pl ↑ Summary linpack.c »
1 #ifdef __cplusplus
2 extern "C" {
3 #endif
4 #include "EXTERN.h"
5 #include "perl.h"
6 #include "XSUB.h"
7 #ifdef __cplusplus
8 }
9 #endif
10  
11 #include "randlib.h"
12 #include "helper.h"
13  
14 #define PERL_VERSION_ATLEAST(a,b,c) \
15 (PERL_REVISION > (a) \
16 || (PERL_REVISION == (a) \
17 && (PERL_VERSION > (b) \
18 || (PERL_VERSION == (b) && PERL_SUBVERSION >= (c)))))
19  
20 #if PERL_VERSION_ATLEAST (5,8,1)
21 /* For whatever reason, the random seeds need to be in 1..2^30; the below will
22 * be uniformly distributed assuming the seed value is uniformly distributed.
23 *
24 * This approach isn't cryptographically secure. Consider using /dev/random
25 * or Math::TrulyRandom to get some real entropy.
26 */
27 #define Perl_get_seed (long)(Perl_seed(aTHX) % 1073741824L)
28 #else
29 /* If we don't support seeds, return 0 so we can fall back to localtime for
30 * default seeding. There's a chance Perl_seed will return 0 and mask this,
31 * but in that case the data should still be "random enough" anyway.
32 */
33 #define Perl_get_seed 0L
34 #endif /* Perl_seed */
35  
36 static int
37 0 not_here(s)
38 char *s;
39 {
40 0 croak("%s not implemented on this architecture", s);
41 return -1;
42 }
43  
44 static double
45 0 constant(name, arg)
46 char *name;
47 int arg;
48 {
49 0 errno = 0;
50 0 switch (*name) {
51 }
52 0 errno = EINVAL;
53 0 return 0;
54  
55 not_there:
56 errno = ENOENT;
57 return 0;
58 }
59  
60  
61 MODULE = Math::Random PACKAGE = Math::Random
62  
63 long
64 get_seed()
65 CODE:
66 1 ▶ RETVAL = Perl_get_seed;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = Perl_get_seed; 0 1 1
67 OUTPUT:
68 RETVAL
69  
70 double
71 genbet (aa,bb)
72 INPUT:
73 double aa
74 double bb
75  
76 double
77 genchi (df)
78 INPUT:
79 double df
80  
81 double
82 genexp (av)
83 INPUT:
84 double av
85  
86 double
87 genf (dfn,dfd)
88 INPUT:
89 double dfn
90 double dfd
91  
92 double
93 gengam (a,r)
94 INPUT:
95 double a
96 double r
97  
98 int
99 psetmn (p)
100 INPUT:
101 long p
102  
103 int
104 pgenmn ()
105 PROTOTYPE:
106 INPUT:
107 CODE:
108 2 RETVAL = pgenmn();
109 OUTPUT:
110 RETVAL
111  
112 int
113 rspriw (size)
114 INPUT:
115 long size
116  
117 int
118 rsprfw (size)
119 INPUT:
120 long size
121  
122 void
123 svprfw (index,value)
124 INPUT:
125 long index
126 double value
127  
128 void
129 pgnmul (n,ncat)
130 INPUT:
131 long n
132 long ncat
133  
134 long
135 gvpriw (index)
136 INPUT:
137 long index
138  
139 double
140 gennch (df,xnonc)
141 INPUT:
142 double df
143 double xnonc
144  
145 double
146 gennf (dfn,dfd,xnonc)
147 INPUT:
148 double dfn
149 double dfd
150 double xnonc
151  
152 double
153 gennor (av,sd)
154 INPUT:
155 double av
156 double sd
157  
158 void
159 pgnprm (n)
160 PROTOTYPE: $
161 INPUT:
162 long n
163 CODE:
164 2 pgnprm(n);
165 OUTPUT:
166  
167 double
168 genunf (low,high)
169 INPUT:
170 double low
171 double high
172  
173 long
174 ignpoi (mu)
175 INPUT:
176 double mu
177  
178 long
179 ignuin (low,high)
180 INPUT:
181 long low
182 long high
183  
184 long
185 ignnbn (n,p)
186 INPUT:
187 long n
188 double p
189  
190 long
191 ignbin (n,pp)
192 INPUT:
193 long n
194 double pp
195  
196 void
197 phrtsd (phrase)
198 PROTOTYPE: $
199 INPUT:
200 char * phrase
201 PREINIT:
202 long newseed1;
203 long newseed2;
204 PPCODE:
205 0 phrtsd(phrase,&newseed1,&newseed2);
206 0 ▶ EXTEND(sp, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(sp, 2); 0 0 0
207 0 PUSHs(sv_2mortal(newSViv(newseed1)));
208 0 PUSHs(sv_2mortal(newSViv(newseed2)));
209  
210 void
211 getsd ()
212 PROTOTYPE:
213 PREINIT:
214 long newseed1;
215 long newseed2;
216 PPCODE:
217 0 getsd(&newseed1,&newseed2);
218 0 ▶ EXTEND(sp, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(sp, 2); 0 0 0
219 0 PUSHs(sv_2mortal(newSViv(newseed1)));
220 0 PUSHs(sv_2mortal(newSViv(newseed2)));
221  
222 void
223 salfph (phrase)
224 PROTOTYPE: $
225 INPUT:
226 char * phrase
227 CODE:
228 2 salfph(phrase);
229 OUTPUT:
230  
231 void
232 setall (iseed1,iseed2)
233 PROTOTYPE: $$
234 INPUT:
235 long iseed1
236 long iseed2
237 CODE:
238 0 setall(iseed1,iseed2);
239 OUTPUT:
240  
241 double
242 gvprfw (index)
243 INPUT:
244 long index
245  
« blib/lib/Math/test2.pl ↑ Summary linpack.c »