File Coverage

lib/PDL/Primitive-pp-fibonacci.c
Criterion Covered Total %
statement 33 202 16.3
branch 26 520 5.0
condition n/a
subroutine n/a
pod n/a
total 59 722 8.1


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/Primitive.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_Primitive
21             extern Core* PDL; /* Structure hold core C functions */
22              
23             #line 1857 "lib/PDL/PP.pm"
24             pdl_error pdl_fibonacci_readdata(pdl_trans *__privtrans) {
25             pdl_error PDL_err = {0, NULL, 0};
26             #line 27 "lib/PDL/Primitive-pp-fibonacci.c"
27 1           register PDL_Indx __n_size = __privtrans->ind_sizes[0];
28 1 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in fibonacci:" "broadcast.incs NULL");
29             /* broadcastloop declarations */
30             int __brcloopval;
31             register PDL_Indx __tind0,__tind1; /* counters along dim */
32 1           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
33             /* dims here are how many steps along those dims */
34 1           register PDL_Indx __tinc0_i = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
35 1           register PDL_Indx __tinc0_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
36 1           register PDL_Indx __tinc1_i = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
37 1           register PDL_Indx __tinc1_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
38             #define PDL_BROADCASTLOOP_START_fibonacci_readdata PDL_BROADCASTLOOP_START( \
39             readdata, \
40             __privtrans->broadcast, \
41             __privtrans->vtable, \
42             i_datap += __offsp[0]; \
43             x_datap += __offsp[1]; \
44             , \
45             ( ,i_datap += __tinc1_i - __tinc0_i * __tdims0 \
46             ,x_datap += __tinc1_x - __tinc0_x * __tdims0 \
47             ), \
48             ( ,i_datap += __tinc0_i \
49             ,x_datap += __tinc0_x \
50             ) \
51             )
52             #define PDL_BROADCASTLOOP_END_fibonacci_readdata PDL_BROADCASTLOOP_END( \
53             __privtrans->broadcast, \
54             i_datap -= __tinc1_i * __tdims1 + __offsp[0]; \
55             x_datap -= __tinc1_x * __tdims1 + __offsp[1]; \
56             )
57 1           register PDL_Indx __inc_i_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_i_n;
58 1           register PDL_Indx __inc_x_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_x_n;
59             #ifndef PDL_DECLARE_PARAMS_fibonacci_1
60             #define PDL_DECLARE_PARAMS_fibonacci_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
61             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, i, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
62             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, x, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP)
63             #endif
64             #define PDL_IF_BAD(t,f) f
65 1           switch (__privtrans->__datatype) { /* Start generic switch */
66 0           case PDL_SB: {
67 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_SByte,A)
    0          
    0          
    0          
    0          
    0          
68 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
69 0           PDL_Indx i=0;
70             PDL_SByte x1, x2;
71 0           x1 = 1; x2 = 0;
72 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
73 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
74 0 0         if (i++>0) {
75 0           x2 = x1;
76 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
77             }
78             }} /* Close n */
79 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
80 0           } break;
81 0           case PDL_B: {
82 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_Byte,B)
    0          
    0          
    0          
    0          
    0          
83 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
84 0           PDL_Indx i=0;
85             PDL_Byte x1, x2;
86 0           x1 = 1; x2 = 0;
87 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
88 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
89 0 0         if (i++>0) {
90 0           x2 = x1;
91 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
92             }
93             }} /* Close n */
94 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
95 0           } break;
96 0           case PDL_S: {
97 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_Short,S)
    0          
    0          
    0          
    0          
    0          
98 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
99 0           PDL_Indx i=0;
100             PDL_Short x1, x2;
101 0           x1 = 1; x2 = 0;
102 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
103 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
104 0 0         if (i++>0) {
105 0           x2 = x1;
106 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
107             }
108             }} /* Close n */
109 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
110 0           } break;
111 0           case PDL_US: {
112 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_Ushort,U)
    0          
    0          
    0          
    0          
    0          
113 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
114 0           PDL_Indx i=0;
115             PDL_Ushort x1, x2;
116 0           x1 = 1; x2 = 0;
117 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
118 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
119 0 0         if (i++>0) {
120 0           x2 = x1;
121 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
122             }
123             }} /* Close n */
124 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
125 0           } break;
126 0           case PDL_L: {
127 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_Long,L)
    0          
    0          
    0          
    0          
    0          
128 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
129 0           PDL_Indx i=0;
130             PDL_Long x1, x2;
131 0           x1 = 1; x2 = 0;
132 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
133 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
134 0 0         if (i++>0) {
135 0           x2 = x1;
136 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
137             }
138             }} /* Close n */
139 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
140 0           } break;
141 0           case PDL_UL: {
142 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_ULong,K)
    0          
    0          
    0          
    0          
    0          
143 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
144 0           PDL_Indx i=0;
145             PDL_ULong x1, x2;
146 0           x1 = 1; x2 = 0;
147 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
148 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
149 0 0         if (i++>0) {
150 0           x2 = x1;
151 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
152             }
153             }} /* Close n */
154 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
155 0           } break;
156 0           case PDL_IND: {
157 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_Indx,N)
    0          
    0          
    0          
    0          
    0          
158 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
159 0           PDL_Indx i=0;
160             PDL_Indx x1, x2;
161 0           x1 = 1; x2 = 0;
162 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
163 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
164 0 0         if (i++>0) {
165 0           x2 = x1;
166 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
167             }
168             }} /* Close n */
169 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
170 0           } break;
171 0           case PDL_ULL: {
172 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_ULongLong,P)
    0          
    0          
    0          
    0          
    0          
173 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
174 0           PDL_Indx i=0;
175             PDL_ULongLong x1, x2;
176 0           x1 = 1; x2 = 0;
177 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
178 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
179 0 0         if (i++>0) {
180 0           x2 = x1;
181 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
182             }
183             }} /* Close n */
184 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
185 0           } break;
186 0           case PDL_LL: {
187 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_LongLong,Q)
    0          
    0          
    0          
    0          
    0          
188 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
189 0           PDL_Indx i=0;
190             PDL_LongLong x1, x2;
191 0           x1 = 1; x2 = 0;
192 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
193 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
194 0 0         if (i++>0) {
195 0           x2 = x1;
196 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
197             }
198             }} /* Close n */
199 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
200 0           } break;
201 0           case PDL_F: {
202 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_Float,F)
    0          
    0          
    0          
    0          
    0          
203 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
204 0           PDL_Indx i=0;
205             PDL_Float x1, x2;
206 0           x1 = 1; x2 = 0;
207 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
208 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
209 0 0         if (i++>0) {
210 0           x2 = x1;
211 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
212             }
213             }} /* Close n */
214 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
215 0           } break;
216 1           case PDL_D: {
217 1 50         PDL_DECLARE_PARAMS_fibonacci_1(PDL_Double,D)
    50          
    50          
    50          
    50          
    50          
218 4 50         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
219 1           PDL_Indx i=0;
220             PDL_Double x1, x2;
221 1           x1 = 1; x2 = 0;
222 16 100         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
223 15           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
224 15 100         if (i++>0) {
225 14           x2 = x1;
226 14           x1 = (x_datap)[0+(__inc_x_n*(n))];
227             }
228             }} /* Close n */
229 1 50         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    50          
230 1           } break;
231 0           case PDL_LD: {
232 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_LDouble,E)
    0          
    0          
    0          
    0          
    0          
233 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
234 0           PDL_Indx i=0;
235             PDL_LDouble x1, x2;
236 0           x1 = 1; x2 = 0;
237 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
238 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
239 0 0         if (i++>0) {
240 0           x2 = x1;
241 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
242             }
243             }} /* Close n */
244 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
245 0           } break;
246 0           case PDL_CF: {
247 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_CFloat,G)
    0          
    0          
    0          
    0          
    0          
248 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
249 0           PDL_Indx i=0;
250             PDL_CFloat x1, x2;
251 0           x1 = 1; x2 = 0;
252 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
253 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
254 0 0         if (i++>0) {
255 0           x2 = x1;
256 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
257             }
258             }} /* Close n */
259 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
260 0           } break;
261 0           case PDL_CD: {
262 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_CDouble,C)
    0          
    0          
    0          
    0          
    0          
263 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
264 0           PDL_Indx i=0;
265             PDL_CDouble x1, x2;
266 0           x1 = 1; x2 = 0;
267 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
268 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
269 0 0         if (i++>0) {
270 0           x2 = x1;
271 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
272             }
273             }} /* Close n */
274 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
275 0           } break;
276 0           case PDL_CLD: {
277 0 0         PDL_DECLARE_PARAMS_fibonacci_1(PDL_CLDouble,H)
    0          
    0          
    0          
    0          
    0          
278 0 0         PDL_BROADCASTLOOP_START_fibonacci_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
279 0           PDL_Indx i=0;
280             PDL_CLDouble x1, x2;
281 0           x1 = 1; x2 = 0;
282 0 0         {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) {
283 0           (x_datap)[0+(__inc_x_n*(n))] = x1 + x2;
284 0 0         if (i++>0) {
285 0           x2 = x1;
286 0           x1 = (x_datap)[0+(__inc_x_n*(n))];
287             }
288             }} /* Close n */
289 0 0         }PDL_BROADCASTLOOP_END_fibonacci_readdata
    0          
290 0           } break;
291 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in fibonacci: unhandled datatype(%d), only handles (ABSULKNPQFDEGCH)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
292             }
293             #undef PDL_IF_BAD
294 1           return PDL_err;
295             }
296              
297             static pdl_datatypes pdl_fibonacci_vtable_gentypes[] = { PDL_SB, PDL_B, PDL_S, PDL_US, PDL_L, PDL_UL, PDL_IND, PDL_ULL, PDL_LL, PDL_F, PDL_D, PDL_LD, PDL_CF, PDL_CD, PDL_CLD, -1 };
298             static PDL_Indx pdl_fibonacci_vtable_realdims[] = { 1, 1 };
299             static char *pdl_fibonacci_vtable_parnames[] = { "i","x" };
300             static short pdl_fibonacci_vtable_parflags[] = {
301             0,
302             PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE
303             };
304             static pdl_datatypes pdl_fibonacci_vtable_partypes[] = { -1, -1 };
305             static PDL_Indx pdl_fibonacci_vtable_realdims_starts[] = { 0, 1 };
306             static PDL_Indx pdl_fibonacci_vtable_realdims_ind_ids[] = { 0, 0 };
307             static char *pdl_fibonacci_vtable_indnames[] = { "n" };
308             pdl_transvtable pdl_fibonacci_vtable = {
309             PDL_TRANS_DO_BROADCAST, 0, pdl_fibonacci_vtable_gentypes, 1, 2, NULL /*CORE21*/,
310             pdl_fibonacci_vtable_realdims, pdl_fibonacci_vtable_parnames,
311             pdl_fibonacci_vtable_parflags, pdl_fibonacci_vtable_partypes,
312             pdl_fibonacci_vtable_realdims_starts, pdl_fibonacci_vtable_realdims_ind_ids, 2,
313             1, pdl_fibonacci_vtable_indnames,
314             NULL, pdl_fibonacci_readdata, NULL,
315             NULL,
316             0,"PDL::Primitive::fibonacci"
317             };
318              
319              
320 1           pdl_error pdl_run_fibonacci(pdl *i,pdl *x) {
321 1           pdl_error PDL_err = {0, NULL, 0};
322 1 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
323 1           pdl_trans *__privtrans = PDL->create_trans(&pdl_fibonacci_vtable);
324 1 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
325 1           __privtrans->pdls[0] = i;
326 1           __privtrans->pdls[1] = x;
327 1 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
328 1 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
329 1           return PDL_err;
330             }