File Coverage

lib/PDL/Stats/TS-pp-fill_ma.c
Criterion Covered Total %
statement 34 62 54.8
branch 43 220 19.5
condition n/a
subroutine n/a
pod n/a
total 77 282 27.3


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/Stats/TS.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_Stats_TS
21             extern Core* PDL; /* Structure hold core C functions */
22             #line 23 "lib/PDL/Stats/TS-pp-fill_ma.c"
23              
24             #include
25             #define Z10 1.64485362695147
26             #define Z05 1.95996398454005
27             #define Z01 2.5758293035489
28             #define Z001 3.29052673149193
29              
30              
31             #line 1857 "lib/PDL/PP.pm"
32             pdl_error pdl_fill_ma_readdata(pdl_trans *__privtrans) {
33             pdl_error PDL_err = {0, NULL, 0};
34             #line 35 "lib/PDL/Stats/TS-pp-fill_ma.c"
35 1           register PDL_Indx __t_size = __privtrans->ind_sizes[0];
36 1 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in fill_ma:" "broadcast.incs NULL");
37             /* broadcastloop declarations */
38             int __brcloopval;
39             register PDL_Indx __tind0,__tind1; /* counters along dim */
40 1           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
41             /* dims here are how many steps along those dims */
42 1           register PDL_Indx __tinc0_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
43 1           register PDL_Indx __tinc0_q = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
44 1           register PDL_Indx __tinc0_xf = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
45 1           register PDL_Indx __tinc1_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
46 1           register PDL_Indx __tinc1_q = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
47 1           register PDL_Indx __tinc1_xf = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
48             #define PDL_BROADCASTLOOP_START_fill_ma_readdata PDL_BROADCASTLOOP_START( \
49             readdata, \
50             __privtrans->broadcast, \
51             __privtrans->vtable, \
52             x_datap += __offsp[0]; \
53             q_datap += __offsp[1]; \
54             xf_datap += __offsp[2]; \
55             , \
56             ( ,x_datap += __tinc1_x - __tinc0_x * __tdims0 \
57             ,q_datap += __tinc1_q - __tinc0_q * __tdims0 \
58             ,xf_datap += __tinc1_xf - __tinc0_xf * __tdims0 \
59             ), \
60             ( ,x_datap += __tinc0_x \
61             ,q_datap += __tinc0_q \
62             ,xf_datap += __tinc0_xf \
63             ) \
64             )
65             #define PDL_BROADCASTLOOP_END_fill_ma_readdata PDL_BROADCASTLOOP_END( \
66             __privtrans->broadcast, \
67             x_datap -= __tinc1_x * __tdims1 + __offsp[0]; \
68             q_datap -= __tinc1_q * __tdims1 + __offsp[1]; \
69             xf_datap -= __tinc1_xf * __tdims1 + __offsp[2]; \
70             )
71 1           register PDL_Indx __inc_x_t = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_x_t;
72 1           register PDL_Indx __inc_xf_t = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,2,0)]; (void)__inc_xf_t;
73             #ifndef PDL_DECLARE_PARAMS_fill_ma_1
74             #define PDL_DECLARE_PARAMS_fill_ma_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_q,PDL_PPSYM_PARAM_q) \
75             PDL_DECLARE_PARAMETER_BADVAL(PDL_TYPE_OP, x, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
76             PDL_DECLARE_PARAMETER_BADVAL(PDL_TYPE_PARAM_q, q, (__privtrans->pdls[1]), 1, PDL_PPSYM_PARAM_q) \
77             PDL_DECLARE_PARAMETER_BADVAL(PDL_TYPE_OP, xf, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP)
78             #endif
79 1 50         if ( __privtrans->bvalflag ) { /* ** do 'bad' Code ** */
80             #define PDL_BAD_CODE
81             #define PDL_IF_BAD(t,f) t
82 1           switch (__privtrans->__datatype) { /* Start generic switch */
83 0           case PDL_F: {
84 0 0         PDL_DECLARE_PARAMS_fill_ma_1(PDL_Float,F,PDL_Indx,N)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
85 0 0         PDL_BROADCASTLOOP_START_fill_ma_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
86             PDL_Float sum, xx;
87 0           PDL_Indx i, n, max = __privtrans->ind_sizes[0] - 1;
88 0 0         {/* Open t */ PDL_EXPAND2(register PDL_Indx t=0, __t_stop=(__t_size)); for(; t<__t_stop; t+=1) {
89 0 0         PDL_IF_BAD(if (PDL_ISBAD2((x_datap)[0+(__inc_x_t*(t))],x_badval,F,x_badval_isnan)) {
    0          
    0          
    0          
    0          
    0          
    0          
    0          
90             n=0; sum=0;
91             for (i=-(q_datap)[0]; i<=(q_datap)[0]; i++) {
92             xx = (t+i < 0)? (x_datap)[0+(__inc_x_t*(0))]
93             : (t+i > max)? (x_datap)[0+(__inc_x_t*(max))]
94             : (x_datap)[0+(__inc_x_t*(t+i))]
95             ;
96             if (!PDL_ISBAD2(xx,x_badval,F,x_badval_isnan)) {
97             sum += xx;
98             n ++;
99             }
100             }
101             if (n) {
102             (xf_datap)[0+(__inc_xf_t*(t))] = sum / n;
103             }
104             else {
105             (xf_datap)[0+(__inc_xf_t*(t))]=xf_badval;
106             }
107             continue;
108             },)
109 0           (xf_datap)[0+(__inc_xf_t*(t))] = (x_datap)[0+(__inc_x_t*(t))];
110             }} /* Close t */
111 0 0         }PDL_BROADCASTLOOP_END_fill_ma_readdata
    0          
112 0           } break;
113 1           case PDL_D: {
114 1 50         PDL_DECLARE_PARAMS_fill_ma_1(PDL_Double,D,PDL_Indx,N)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
115 5 50         PDL_BROADCASTLOOP_START_fill_ma_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
116             PDL_Double sum, xx;
117 2           PDL_Indx i, n, max = __privtrans->ind_sizes[0] - 1;
118 10 100         {/* Open t */ PDL_EXPAND2(register PDL_Indx t=0, __t_stop=(__t_size)); for(; t<__t_stop; t+=1) {
119 18 50         PDL_IF_BAD(if (PDL_ISBAD2((x_datap)[0+(__inc_x_t*(t))],x_badval,D,x_badval_isnan)) {
    100          
    50          
    100          
    50          
    100          
    100          
    50          
120             n=0; sum=0;
121             for (i=-(q_datap)[0]; i<=(q_datap)[0]; i++) {
122             xx = (t+i < 0)? (x_datap)[0+(__inc_x_t*(0))]
123             : (t+i > max)? (x_datap)[0+(__inc_x_t*(max))]
124             : (x_datap)[0+(__inc_x_t*(t+i))]
125             ;
126             if (!PDL_ISBAD2(xx,x_badval,D,x_badval_isnan)) {
127             sum += xx;
128             n ++;
129             }
130             }
131             if (n) {
132             (xf_datap)[0+(__inc_xf_t*(t))] = sum / n;
133             }
134             else {
135             (xf_datap)[0+(__inc_xf_t*(t))]=xf_badval;
136             }
137             continue;
138             },)
139 6           (xf_datap)[0+(__inc_xf_t*(t))] = (x_datap)[0+(__inc_x_t*(t))];
140             }} /* Close t */
141 1 50         }PDL_BROADCASTLOOP_END_fill_ma_readdata
    50          
142 1           } break;
143 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in fill_ma: unhandled datatype(%d), only handles (FD)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
144             }
145             #undef PDL_BAD_CODE
146             #undef PDL_IF_BAD
147             } else { /* ** else do 'good' Code ** */
148             #define PDL_IF_BAD(t,f) f
149 0           switch (__privtrans->__datatype) { /* Start generic switch */
150 0           case PDL_F: {
151 0 0         PDL_DECLARE_PARAMS_fill_ma_1(PDL_Float,F,PDL_Indx,N)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
152 0 0         PDL_BROADCASTLOOP_START_fill_ma_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
153             PDL_Float sum, xx;
154 0           PDL_Indx i, n, max = __privtrans->ind_sizes[0] - 1;
155 0 0         {/* Open t */ PDL_EXPAND2(register PDL_Indx t=0, __t_stop=(__t_size)); for(; t<__t_stop; t+=1) {
156             PDL_IF_BAD(if (PDL_ISBAD2((x_datap)[0+(__inc_x_t*(t))],x_badval,F,x_badval_isnan)) {
157             n=0; sum=0;
158             for (i=-(q_datap)[0]; i<=(q_datap)[0]; i++) {
159             xx = (t+i < 0)? (x_datap)[0+(__inc_x_t*(0))]
160             : (t+i > max)? (x_datap)[0+(__inc_x_t*(max))]
161             : (x_datap)[0+(__inc_x_t*(t+i))]
162             ;
163             if (!PDL_ISBAD2(xx,x_badval,F,x_badval_isnan)) {
164             sum += xx;
165             n ++;
166             }
167             }
168             if (n) {
169             (xf_datap)[0+(__inc_xf_t*(t))] = sum / n;
170             }
171             else {
172             (xf_datap)[0+(__inc_xf_t*(t))]=xf_badval;
173             }
174             continue;
175             },)
176 0           (xf_datap)[0+(__inc_xf_t*(t))] = (x_datap)[0+(__inc_x_t*(t))];
177             }} /* Close t */
178 0 0         }PDL_BROADCASTLOOP_END_fill_ma_readdata
    0          
179 0           } break;
180 0           case PDL_D: {
181 0 0         PDL_DECLARE_PARAMS_fill_ma_1(PDL_Double,D,PDL_Indx,N)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
182 0 0         PDL_BROADCASTLOOP_START_fill_ma_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
183             PDL_Double sum, xx;
184 0           PDL_Indx i, n, max = __privtrans->ind_sizes[0] - 1;
185 0 0         {/* Open t */ PDL_EXPAND2(register PDL_Indx t=0, __t_stop=(__t_size)); for(; t<__t_stop; t+=1) {
186             PDL_IF_BAD(if (PDL_ISBAD2((x_datap)[0+(__inc_x_t*(t))],x_badval,D,x_badval_isnan)) {
187             n=0; sum=0;
188             for (i=-(q_datap)[0]; i<=(q_datap)[0]; i++) {
189             xx = (t+i < 0)? (x_datap)[0+(__inc_x_t*(0))]
190             : (t+i > max)? (x_datap)[0+(__inc_x_t*(max))]
191             : (x_datap)[0+(__inc_x_t*(t+i))]
192             ;
193             if (!PDL_ISBAD2(xx,x_badval,D,x_badval_isnan)) {
194             sum += xx;
195             n ++;
196             }
197             }
198             if (n) {
199             (xf_datap)[0+(__inc_xf_t*(t))] = sum / n;
200             }
201             else {
202             (xf_datap)[0+(__inc_xf_t*(t))]=xf_badval;
203             }
204             continue;
205             },)
206 0           (xf_datap)[0+(__inc_xf_t*(t))] = (x_datap)[0+(__inc_x_t*(t))];
207             }} /* Close t */
208 0 0         }PDL_BROADCASTLOOP_END_fill_ma_readdata
    0          
209 0           } break;
210 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in fill_ma: unhandled datatype(%d), only handles (FD)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
211             }
212             #undef PDL_IF_BAD
213             }
214 1           return PDL_err;
215             }
216              
217             static pdl_datatypes pdl_fill_ma_vtable_gentypes[] = { PDL_F, PDL_D, -1 };
218             static PDL_Indx pdl_fill_ma_vtable_realdims[] = { 1, 0, 1 };
219             static char *pdl_fill_ma_vtable_parnames[] = { "x","q","xf" };
220             static short pdl_fill_ma_vtable_parflags[] = {
221             0,
222             PDL_PARAM_ISTYPED,
223             PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE
224             };
225             static pdl_datatypes pdl_fill_ma_vtable_partypes[] = { -1, PDL_IND, -1 };
226             static PDL_Indx pdl_fill_ma_vtable_realdims_starts[] = { 0, 1, 1 };
227             static PDL_Indx pdl_fill_ma_vtable_realdims_ind_ids[] = { 0, 0 };
228             static char *pdl_fill_ma_vtable_indnames[] = { "t" };
229             pdl_transvtable pdl_fill_ma_vtable = {
230             PDL_TRANS_DO_BROADCAST|PDL_TRANS_BADPROCESS, 0, pdl_fill_ma_vtable_gentypes, 2, 3, NULL /*CORE21*/,
231             pdl_fill_ma_vtable_realdims, pdl_fill_ma_vtable_parnames,
232             pdl_fill_ma_vtable_parflags, pdl_fill_ma_vtable_partypes,
233             pdl_fill_ma_vtable_realdims_starts, pdl_fill_ma_vtable_realdims_ind_ids, 2,
234             1, pdl_fill_ma_vtable_indnames,
235             NULL, pdl_fill_ma_readdata, NULL,
236             NULL,
237             0,"PDL::Stats::TS::fill_ma"
238             };
239              
240              
241 1           pdl_error pdl_run_fill_ma(pdl *x,pdl *q,pdl *xf) {
242 1           pdl_error PDL_err = {0, NULL, 0};
243 1 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
244 1           pdl_trans *__privtrans = PDL->create_trans(&pdl_fill_ma_vtable);
245 1 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
246 1           __privtrans->pdls[0] = x;
247 1           __privtrans->pdls[1] = q;
248 1           __privtrans->pdls[2] = xf;
249 1 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
250 1 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
251 1           return PDL_err;
252             }