File Coverage

lib/PDL/Stats/TS-pp-filter_ma.c
Criterion Covered Total %
statement 38 53 71.7
branch 33 98 33.6
condition n/a
subroutine n/a
pod n/a
total 71 151 47.0


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-filter_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_filter_ma_readdata(pdl_trans *__privtrans) {
33             pdl_error PDL_err = {0, NULL, 0};
34             #line 35 "lib/PDL/Stats/TS-pp-filter_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 filter_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_filter_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_filter_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_filter_ma_1
74             #define PDL_DECLARE_PARAMS_filter_ma_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_q,PDL_PPSYM_PARAM_q) \
75             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, x, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
76             PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_q, q, (__privtrans->pdls[1]), 1, PDL_PPSYM_PARAM_q) \
77             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, xf, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP)
78             #endif
79             #define PDL_IF_BAD(t,f) f
80 1           switch (__privtrans->__datatype) { /* Start generic switch */
81 0           case PDL_F: {
82 0 0         PDL_DECLARE_PARAMS_filter_ma_1(PDL_Float,F,PDL_Indx,N)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
83 0 0         PDL_BROADCASTLOOP_START_filter_ma_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
84             PDL_Float sum;
85             PDL_Indx i, n, max;
86 0           n = 2 * (q_datap)[0] + 1;
87 0           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           sum = 0;
90 0 0         for (i=-(q_datap)[0]; i<=(q_datap)[0]; i++) {
91 0           sum += (t+i < 0)? (x_datap)[0+(__inc_x_t*(0))]
92 0 0         : (t+i > max)? (x_datap)[0+(__inc_x_t*(max))]
93 0 0         : (x_datap)[0+(__inc_x_t*(t+i))]
94             ;
95             }
96 0           (xf_datap)[0+(__inc_xf_t*(t))] = sum / n;
97             }} /* Close t */
98 0 0         }PDL_BROADCASTLOOP_END_filter_ma_readdata
    0          
99 0           } break;
100 1           case PDL_D: {
101 1 50         PDL_DECLARE_PARAMS_filter_ma_1(PDL_Double,D,PDL_Indx,N)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
102 4 50         PDL_BROADCASTLOOP_START_filter_ma_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
103             PDL_Double sum;
104             PDL_Indx i, n, max;
105 1           n = 2 * (q_datap)[0] + 1;
106 1           max = __privtrans->ind_sizes[0] - 1;
107 11 100         {/* Open t */ PDL_EXPAND2(register PDL_Indx t=0, __t_stop=(__t_size)); for(; t<__t_stop; t+=1) {
108 10           sum = 0;
109 60 100         for (i=-(q_datap)[0]; i<=(q_datap)[0]; i++) {
110 50           sum += (t+i < 0)? (x_datap)[0+(__inc_x_t*(0))]
111 97 100         : (t+i > max)? (x_datap)[0+(__inc_x_t*(max))]
112 47 100         : (x_datap)[0+(__inc_x_t*(t+i))]
113             ;
114             }
115 10           (xf_datap)[0+(__inc_xf_t*(t))] = sum / n;
116             }} /* Close t */
117 1 50         }PDL_BROADCASTLOOP_END_filter_ma_readdata
    50          
118 1           } break;
119 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in filter_ma: unhandled datatype(%d), only handles (FD)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
120             }
121             #undef PDL_IF_BAD
122 1           return PDL_err;
123             }
124              
125             static pdl_datatypes pdl_filter_ma_vtable_gentypes[] = { PDL_F, PDL_D, -1 };
126             static PDL_Indx pdl_filter_ma_vtable_realdims[] = { 1, 0, 1 };
127             static char *pdl_filter_ma_vtable_parnames[] = { "x","q","xf" };
128             static short pdl_filter_ma_vtable_parflags[] = {
129             0,
130             PDL_PARAM_ISTYPED,
131             PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE
132             };
133             static pdl_datatypes pdl_filter_ma_vtable_partypes[] = { -1, PDL_IND, -1 };
134             static PDL_Indx pdl_filter_ma_vtable_realdims_starts[] = { 0, 1, 1 };
135             static PDL_Indx pdl_filter_ma_vtable_realdims_ind_ids[] = { 0, 0 };
136             static char *pdl_filter_ma_vtable_indnames[] = { "t" };
137             pdl_transvtable pdl_filter_ma_vtable = {
138             PDL_TRANS_DO_BROADCAST, 0, pdl_filter_ma_vtable_gentypes, 2, 3, NULL /*CORE21*/,
139             pdl_filter_ma_vtable_realdims, pdl_filter_ma_vtable_parnames,
140             pdl_filter_ma_vtable_parflags, pdl_filter_ma_vtable_partypes,
141             pdl_filter_ma_vtable_realdims_starts, pdl_filter_ma_vtable_realdims_ind_ids, 2,
142             1, pdl_filter_ma_vtable_indnames,
143             NULL, pdl_filter_ma_readdata, NULL,
144             NULL,
145             0,"PDL::Stats::TS::filter_ma"
146             };
147              
148              
149 1           pdl_error pdl_run_filter_ma(pdl *x,pdl *q,pdl *xf) {
150 1           pdl_error PDL_err = {0, NULL, 0};
151 1 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
152 1           pdl_trans *__privtrans = PDL->create_trans(&pdl_filter_ma_vtable);
153 1 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
154 1           __privtrans->pdls[0] = x;
155 1           __privtrans->pdls[1] = q;
156 1           __privtrans->pdls[2] = xf;
157 1 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
158 1 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
159 1           return PDL_err;
160             }