File Coverage

lib/PDL/Bad.xs
Criterion Covered Total %
statement 83 88 94.3
branch 217 518 41.8
condition n/a
subroutine n/a
pod n/a
total 300 606 49.5


line stmt bran cond sub pod time code
1              
2             #line 453 "lib/PDL/PP.pm"
3             /*
4             * THIS FILE WAS GENERATED BY PDL::PP from lib/PDL/Bad.pd! Do not modify!
5             */
6              
7             #define PDL_FREE_CODE(trans, destroy, comp_free_code, ntpriv_free_code) \
8             if (destroy) { \
9             comp_free_code \
10             } \
11             if ((trans)->dims_redone) { \
12             ntpriv_free_code \
13             }
14              
15             #include "EXTERN.h"
16             #include "perl.h"
17             #include "XSUB.h"
18             #include "pdl.h"
19             #include "pdlcore.h"
20             #define PDL PDL_Bad
21             extern Core* PDL; /* Structure hold core C functions */
22             #line 23 "lib/PDL/Bad.xs"
23              
24             #include
25             pdl_error pdl_run_isbad(pdl *a,pdl *b);
26             pdl_error pdl_run_isgood(pdl *a,pdl *b);
27             pdl_error pdl_run_nbadover(pdl *a,pdl *b);
28             pdl_error pdl_run_ngoodover(pdl *a,pdl *b);
29             pdl_error pdl_run_setbadif(pdl *a,pdl *mask,pdl *b);
30             pdl_error pdl_run_setvaltobad(pdl *a,pdl *b,double value);
31             pdl_error pdl_run_setnantobad(pdl *a,pdl *b);
32             pdl_error pdl_run_setinftobad(pdl *a,pdl *b);
33             pdl_error pdl_run_setnonfinitetobad(pdl *a,pdl *b);
34             pdl_error pdl_run_setbadtonan(pdl *a,pdl *b);
35             pdl_error pdl_run_setbadtoval(pdl *a,pdl *b,double newval);
36             pdl_error pdl_run_badmask(pdl *a,pdl *b,pdl *c);
37             pdl_error pdl_run_copybad(pdl *a,pdl *mask,pdl *b);
38             pdl_error pdl_run_locf(pdl *a,pdl *b);
39              
40             #line 449 "lib/PDL/PP.pm"
41             #include "pdlperl.h"
42             #line 43 "lib/PDL/Bad.xs"
43              
44             Core* PDL = NULL; /* Structure hold core C functions */
45              
46             MODULE = PDL::Bad PACKAGE = PDL PREFIX=pdl_run_
47              
48             PROTOTYPES: DISABLE
49              
50              
51             MODULE = PDL::Bad PACKAGE = PDL::Bad
52              
53             pdl *
54             _badvalue_int(val, type)
55             PDL_Anyval val
56             int type
57             CODE:
58 114 100         if ( val.type != -1 ) {
59             #define X_OUTER(datatype, ctype, ppsym, ...) \
60             ctype cnewval = val.value.ppsym;
61             #define X_INNER(datatype, ctype, ppsym, ...) \
62             PDL->bvals.ppsym = cnewval;
63 4           PDL_GENERICSWITCH2(
64             PDL_TYPELIST_ALL, val.type, X_OUTER, croak("Not a known data type code=%d", val.type),
65             PDL_TYPELIST_ALL_, type, X_INNER, croak("Not a known data type code=%d", type))
66             #undef X_OUTER
67             #undef X_INNER
68             }
69 114           PDL_Anyval newval = {type, {0}};
70 114           pdl* p = PDL->scalar(newval);
71 114 50         if (!p) PDL->pdl_barf("Error making new pdl");
72             #define X(datatype, ctype, ppsym, ...) \
73             *((ctype *)p->data) = PDL->bvals.ppsym;
74 114           PDL_GENERICSWITCH(PDL_TYPELIST_ALL, type, X, croak("Not a known data type code=%d", type))
75             #undef X
76 114           RETVAL = p;
77             OUTPUT:
78             RETVAL
79              
80             pdl *
81             _badvalue_per_pdl_int(pdl_val, val, type)
82             pdl* pdl_val
83             PDL_Anyval val
84             int type
85             CODE:
86 108 100         if ( val.type != -1) {
87             PDL_Anyval typedval;
88 42           ANYVAL_TO_ANYVAL_NEWTYPE(val, typedval, pdl_val->datatype);
89 42 50         if (typedval.type < 0) PDL->pdl_barf("Error making typedval");
90             #define X(datatype, ctype, ppsym, ...) \
91             pdl_val->badvalue.type = typedval.type; \
92             pdl_val->badvalue.value.ppsym = typedval.value.ppsym;
93 42           PDL_GENERICSWITCH(PDL_TYPELIST_ALL, pdl_val->datatype, X, croak("Not a known data type code=%d", type))
94             #undef X
95 42           pdl_val->has_badvalue = 1;
96 42           PDL->propagate_badvalue( pdl_val );
97             }
98 108           PDL_Anyval newval = {type, {0}};
99 108           pdl* p = PDL->scalar(newval);
100 108 50         if (!p) PDL->pdl_barf("Error making new pdl");
101 108 100         if (pdl_val->has_badvalue == 0) {
102             #define X(datatype, ctype, ppsym, ...) \
103             *((ctype *)p->data) = PDL->bvals.ppsym;
104 57           PDL_GENERICSWITCH(PDL_TYPELIST_ALL, type, X, croak("Not a known data type code=%d", type))
105             #undef X
106             } else {
107             #define X_OUTER(datatype, ctype, ...) \
108             ctype *coutvalp = p->data;
109             #define X_INNER(datatype, ctype, ppsym, ...) \
110             *coutvalp = pdl_val->badvalue.value.ppsym;
111 51           PDL_GENERICSWITCH2(
112             PDL_TYPELIST_ALL, type, X_OUTER, croak("Not a known data type code=%d", type),
113             PDL_TYPELIST_ALL_, pdl_val->badvalue.type, X_INNER, croak("Not a known data type code=%d", pdl_val->badvalue.type))
114             #undef X_OUTER
115             #undef X_INNER
116             }
117 108           RETVAL = p;
118             OUTPUT:
119             RETVAL
120              
121             pdl *
122             _default_badvalue_int(type)
123             int type
124             CODE:
125 33           PDL_Anyval val = {type, {0}};
126 33           pdl* p = PDL->scalar(val);
127 33 50         if (!p) PDL->pdl_barf("Error making new pdl");
128             #define X(datatype, ctype, ppsym, shortctype, defbval, ...) \
129             *((ctype *)p->data) = defbval;
130 33           PDL_GENERICSWITCH(PDL_TYPELIST_ALL, type, X, croak("Not a known data type code=%d", type))
131             #undef X
132 33           RETVAL = p;
133             OUTPUT:
134             RETVAL
135              
136             MODULE = PDL::Bad PACKAGE = PDL PREFIX=pdl_run_
137              
138              
139             void
140             pdl_run_isbad(a, b=PDL_XS_PERLINIT_initsv(b_SV))
141             SV *b_SV = items > 1 ? ST(1) : NULL;
142             PREINIT:
143 704 50         PDL_XS_PREAMBLE((items == 2) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
144             INPUT:
145             pdl *a
146             pdl *b
147             PPCODE:
148 704           PDL->barf_if_error(pdl_run_isbad(a,b));
149 704 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
150              
151             void
152             pdl_run_isgood(a, b=PDL_XS_PERLINIT_initsv(b_SV))
153             SV *b_SV = items > 1 ? ST(1) : NULL;
154             PREINIT:
155 1 50         PDL_XS_PREAMBLE((items == 2) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
156             INPUT:
157             pdl *a
158             pdl *b
159             PPCODE:
160 1           PDL->barf_if_error(pdl_run_isgood(a,b));
161 1 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
162              
163             void
164             pdl_run_nbadover(a, b=PDL_XS_PERLINIT_initsv(b_SV))
165             SV *b_SV = items > 1 ? ST(1) : NULL;
166             PREINIT:
167 4 50         PDL_XS_PREAMBLE((items == 2) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
168             INPUT:
169             pdl *a
170             pdl *b
171             PPCODE:
172 4           PDL->barf_if_error(pdl_run_nbadover(a,b));
173 4 100         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    50          
174              
175             void
176             pdl_run_ngoodover(a, b=PDL_XS_PERLINIT_initsv(b_SV))
177             SV *b_SV = items > 1 ? ST(1) : NULL;
178             PREINIT:
179 24 50         PDL_XS_PREAMBLE((items == 2) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
180             INPUT:
181             pdl *a
182             pdl *b
183             PPCODE:
184 24           PDL->barf_if_error(pdl_run_ngoodover(a,b));
185 24 100         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    50          
186              
187             void
188             pdl_run_setbadif(a, mask, b=PDL_XS_PERLINIT_initsv(b_SV))
189             SV *b_SV = items > 2 ? ST(2) : NULL;
190             PREINIT:
191 40 50         PDL_XS_PREAMBLE((items == 3) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
192             INPUT:
193             pdl *a
194             pdl *mask
195             pdl *b
196             PPCODE:
197 40           PDL->barf_if_error(pdl_run_setbadif(a,mask,b));
198 40 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
199              
200             void
201             pdl_run_setvaltobad(a, b=b, value=value)
202             SV *b_SV = (items == 3) ? ST(1) : NULL;
203             SV *value_SV = (items == 3) ? ST(2) : ST(1);
204             PREINIT:
205 121 50         PDL_XS_PREAMBLE((items == 3) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
206 121 50         if (!((items == 2) || (items == 3)))
    0          
207 0           croak("Usage: PDL::setvaltobad(a,[b],value) (you may leave [outputs] and values with =defaults out of list)");
208             INPUT:
209             pdl *a
210             pdl *b=NO_INIT
211             double value; { value = (double)SvNV(value_SV); }
212             PPCODE:
213 121 100         PDL_XS_INPLACE(a, b)
    50          
    50          
    50          
214 121           PDL->barf_if_error(pdl_run_setvaltobad(a,b,value));
215 121 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
216              
217             void
218             pdl_run_setnantobad(a, b=b)
219             SV *b_SV = items > 1 ? ST(1) : NULL;
220             PREINIT:
221 59 50         PDL_XS_PREAMBLE((items == 2) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
222             INPUT:
223             pdl *a
224             pdl *b=NO_INIT
225             PPCODE:
226 59 100         PDL_XS_INPLACE(a, b)
    50          
    50          
    50          
227 59           PDL->barf_if_error(pdl_run_setnantobad(a,b));
228 59 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
229              
230             void
231             pdl_run_setinftobad(a, b=b)
232             SV *b_SV = items > 1 ? ST(1) : NULL;
233             PREINIT:
234 1 50         PDL_XS_PREAMBLE((items == 2) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
235             INPUT:
236             pdl *a
237             pdl *b=NO_INIT
238             PPCODE:
239 1 50         PDL_XS_INPLACE(a, b)
    50          
    0          
    0          
240 1           PDL->barf_if_error(pdl_run_setinftobad(a,b));
241 1 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
242              
243             void
244             pdl_run_setnonfinitetobad(a, b=b)
245             SV *b_SV = items > 1 ? ST(1) : NULL;
246             PREINIT:
247 1 50         PDL_XS_PREAMBLE((items == 2) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
248             INPUT:
249             pdl *a
250             pdl *b=NO_INIT
251             PPCODE:
252 1 50         PDL_XS_INPLACE(a, b)
    50          
    0          
    0          
253 1           PDL->barf_if_error(pdl_run_setnonfinitetobad(a,b));
254 1 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
255              
256             void
257             pdl_run_setbadtonan(a, b=b)
258             SV *b_SV = items > 1 ? ST(1) : NULL;
259             PREINIT:
260 3 50         PDL_XS_PREAMBLE((items == 2) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
261             INPUT:
262             pdl *a
263             pdl *b=NO_INIT
264             PPCODE:
265 3 50         PDL_XS_INPLACE(a, b)
    50          
    0          
    0          
266 3           PDL->barf_if_error(pdl_run_setbadtonan(a,b));
267 3 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
268              
269             void
270             pdl_run_setbadtoval(a, b=b, newval=newval)
271             SV *b_SV = (items == 3) ? ST(1) : NULL;
272             SV *newval_SV = (items == 3) ? ST(2) : ST(1);
273             PREINIT:
274 54 50         PDL_XS_PREAMBLE((items == 3) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
275 54 50         if (!((items == 2) || (items == 3)))
    0          
276 0           croak("Usage: PDL::setbadtoval(a,[b],newval) (you may leave [outputs] and values with =defaults out of list)");
277             INPUT:
278             pdl *a
279             pdl *b=NO_INIT
280             double newval; { newval = (double)SvNV(newval_SV); }
281             PPCODE:
282 54 100         PDL_XS_INPLACE(a, b)
    50          
    50          
    50          
283 54           PDL->barf_if_error(pdl_run_setbadtoval(a,b,newval));
284 54 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
285              
286             void
287             pdl_run_badmask(a, b, c=c)
288             SV *c_SV = items > 2 ? ST(2) : NULL;
289             PREINIT:
290 1 50         PDL_XS_PREAMBLE((items == 3) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
291             INPUT:
292             pdl *a
293             pdl *b
294             pdl *c=NO_INIT
295             PPCODE:
296 1 50         PDL_XS_INPLACE(a, c)
    50          
    0          
    0          
297 1           PDL->barf_if_error(pdl_run_badmask(a,b,c));
298 1 50         PDL_XS_RETURN(ST(0) = c_SV)
    50          
    50          
    50          
    0          
299              
300             void
301             pdl_run_copybad(a, mask, b=b)
302             SV *b_SV = items > 2 ? ST(2) : NULL;
303             PREINIT:
304 3 50         PDL_XS_PREAMBLE((items == 3) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
305             INPUT:
306             pdl *a
307             pdl *mask
308             pdl *b=NO_INIT
309             PPCODE:
310 3 100         PDL_XS_INPLACE(a, b)
    50          
    50          
    50          
311 3           PDL->barf_if_error(pdl_run_copybad(a,mask,b));
312 3 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
313              
314             void
315             pdl_run_locf(a, b=PDL_XS_PERLINIT_initsv(b_SV))
316             SV *b_SV = items > 1 ? ST(1) : NULL;
317             PREINIT:
318 1 50         PDL_XS_PREAMBLE((items == 2) ? 0 : 1);
    50          
    0          
    50          
    50          
    50          
    50          
    0          
    50          
    50          
319             INPUT:
320             pdl *a
321             pdl *b
322             PPCODE:
323 1           PDL->barf_if_error(pdl_run_locf(a,b));
324 1 50         PDL_XS_RETURN(ST(0) = b_SV)
    50          
    50          
    50          
    0          
325              
326              
327             #line 483 "lib/PDL/PP.pm"
328             BOOT:
329             /* Get pointer to structure of core shared C routines */
330             /* make sure PDL::Core is loaded */
331             #line 332 "lib/PDL/Bad.xs"
332 71           perl_require_pv ("PDL/Core.pm"); /* make sure PDL::Core is loaded */
333             #ifndef aTHX_
334             #define aTHX_
335             #endif
336 71 50         if (SvTRUE (ERRSV)) Perl_croak(aTHX_ "%s",SvPV_nolen (ERRSV));
    50          
    0          
337 71           SV* CoreSV = perl_get_sv("PDL::SHARE",FALSE); /* var with core structure */
338 71 50         if (!CoreSV)
339 0           Perl_croak(aTHX_ "We require the PDL::Core module, which was not found");
340 71 50         if (!(PDL = INT2PTR(Core*,SvIV( CoreSV )))) /* Core* value */
341 0           Perl_croak(aTHX_ "Got NULL pointer for PDL");
342 71 50         if (PDL->Version != PDL_CORE_VERSION)
343 0           Perl_croak(aTHX_ "[PDL->Version: %ld PDL_CORE_VERSION: %ld XS_VERSION: %s] PDL::Bad needs to be recompiled against the newly installed PDL", (long int)PDL->Version, (long int)PDL_CORE_VERSION, XS_VERSION);