File Coverage

lib/PDL/Stats/TS-pp-acvf.c
Criterion Covered Total %
statement 47 66 71.2
branch 31 88 35.2
condition n/a
subroutine n/a
pod n/a
total 78 154 50.6


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-acvf.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 1846 "lib/PDL/PP.pm"
32             typedef struct pdl_params_acvf {
33             #line 34 "lib/PDL/Stats/TS-pp-acvf.c"
34             IV lag;
35             } pdl_params_acvf;
36              
37              
38             #line 1857 "lib/PDL/PP.pm"
39             pdl_error pdl_acvf_redodims(pdl_trans *__privtrans) {
40             pdl_error PDL_err = {0, NULL, 0};
41             #line 42 "lib/PDL/Stats/TS-pp-acvf.c"
42 1           pdl_params_acvf *__params = __privtrans->params; (void)__params;
43 1           __privtrans->ind_sizes[0] = __params->lag;
44 1 50         PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans));
45 1           return PDL_err;
46             }
47              
48              
49             #line 1857 "lib/PDL/PP.pm"
50             pdl_error pdl_acvf_readdata(pdl_trans *__privtrans) {
51             pdl_error PDL_err = {0, NULL, 0};
52             #line 53 "lib/PDL/Stats/TS-pp-acvf.c"
53 1           pdl_params_acvf *__params = __privtrans->params; (void)__params;
54 1           register PDL_Indx __h_size = __privtrans->ind_sizes[0];
55 1           register PDL_Indx __t_size = __privtrans->ind_sizes[1];
56 1 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in acvf:" "broadcast.incs NULL");
57             /* broadcastloop declarations */
58             int __brcloopval;
59             register PDL_Indx __tind0,__tind1; /* counters along dim */
60 1           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
61             /* dims here are how many steps along those dims */
62 1           register PDL_Indx __tinc0_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
63 1           register PDL_Indx __tinc0_v = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
64 1           register PDL_Indx __tinc1_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
65 1           register PDL_Indx __tinc1_v = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
66             #define PDL_BROADCASTLOOP_START_acvf_readdata PDL_BROADCASTLOOP_START( \
67             readdata, \
68             __privtrans->broadcast, \
69             __privtrans->vtable, \
70             x_datap += __offsp[0]; \
71             v_datap += __offsp[1]; \
72             , \
73             ( ,x_datap += __tinc1_x - __tinc0_x * __tdims0 \
74             ,v_datap += __tinc1_v - __tinc0_v * __tdims0 \
75             ), \
76             ( ,x_datap += __tinc0_x \
77             ,v_datap += __tinc0_v \
78             ) \
79             )
80             #define PDL_BROADCASTLOOP_END_acvf_readdata PDL_BROADCASTLOOP_END( \
81             __privtrans->broadcast, \
82             x_datap -= __tinc1_x * __tdims1 + __offsp[0]; \
83             v_datap -= __tinc1_v * __tdims1 + __offsp[1]; \
84             )
85 1           register PDL_Indx __inc_v_h = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_v_h;
86 1           register PDL_Indx __inc_x_t = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_x_t;
87             #ifndef PDL_DECLARE_PARAMS_acvf_1
88             #define PDL_DECLARE_PARAMS_acvf_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
89             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, x, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
90             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, v, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP)
91             #endif
92             #define PDL_IF_BAD(t,f) f
93 1           switch (__privtrans->__datatype) { /* Start generic switch */
94 0           case PDL_F: {
95 0 0         PDL_DECLARE_PARAMS_acvf_1(PDL_Float,F)
    0          
    0          
    0          
    0          
    0          
96 0 0         PDL_BROADCASTLOOP_START_acvf_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
97             PDL_Float s, s2, m, covh;
98 0           s=0; s2=0; m=0; covh=0;
99             long T, i;
100 0           T = __privtrans->ind_sizes[1];
101 0 0         {/* Open t */ PDL_EXPAND2(register PDL_Indx t=0, __t_stop=(__t_size)); for(; t<__t_stop; t+=1) {
102 0           s += (x_datap)[0+(__inc_x_t*(t))];
103 0           s2 += (x_datap)[0+(__inc_x_t*(t))]*(x_datap)[0+(__inc_x_t*(t))];
104             }} /* Close t */
105 0           m = s/T;
106 0 0         {/* Open h */ PDL_EXPAND2(register PDL_Indx h=0, __h_stop=(__h_size)); for(; h<__h_stop; h+=1) {
107 0 0         if (h) {
108 0           covh = 0;
109 0 0         for (i=0; i
110 0           covh += ((x_datap)[0+(__inc_x_t*(i))] - m) * ((x_datap)[0+(__inc_x_t*(i+h))] - m);
111             }
112 0           (v_datap)[0+(__inc_v_h*(h))] = covh;
113             }
114             else {
115 0           (v_datap)[0+(__inc_v_h*(h))] = s2 - T * m * m;
116             }
117             }} /* Close h */
118 0 0         }PDL_BROADCASTLOOP_END_acvf_readdata
    0          
119 0           } break;
120 1           case PDL_D: {
121 1 50         PDL_DECLARE_PARAMS_acvf_1(PDL_Double,D)
    50          
    50          
    50          
    50          
    50          
122 4 50         PDL_BROADCASTLOOP_START_acvf_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
123             PDL_Double s, s2, m, covh;
124 1           s=0; s2=0; m=0; covh=0;
125             long T, i;
126 1           T = __privtrans->ind_sizes[1];
127 11 100         {/* Open t */ PDL_EXPAND2(register PDL_Indx t=0, __t_stop=(__t_size)); for(; t<__t_stop; t+=1) {
128 10           s += (x_datap)[0+(__inc_x_t*(t))];
129 10           s2 += (x_datap)[0+(__inc_x_t*(t))]*(x_datap)[0+(__inc_x_t*(t))];
130             }} /* Close t */
131 1           m = s/T;
132 6 100         {/* Open h */ PDL_EXPAND2(register PDL_Indx h=0, __h_stop=(__h_size)); for(; h<__h_stop; h+=1) {
133 5 100         if (h) {
134 4           covh = 0;
135 34 100         for (i=0; i
136 30           covh += ((x_datap)[0+(__inc_x_t*(i))] - m) * ((x_datap)[0+(__inc_x_t*(i+h))] - m);
137             }
138 4           (v_datap)[0+(__inc_v_h*(h))] = covh;
139             }
140             else {
141 1           (v_datap)[0+(__inc_v_h*(h))] = s2 - T * m * m;
142             }
143             }} /* Close h */
144 1 50         }PDL_BROADCASTLOOP_END_acvf_readdata
    50          
145 1           } break;
146 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in acvf: unhandled datatype(%d), only handles (FD)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
147             }
148             #undef PDL_IF_BAD
149 1           return PDL_err;
150             }
151              
152             static pdl_datatypes pdl_acvf_vtable_gentypes[] = { PDL_F, PDL_D, -1 };
153             static PDL_Indx pdl_acvf_vtable_realdims[] = { 1, 1 };
154             static char *pdl_acvf_vtable_parnames[] = { "x","v" };
155             static short pdl_acvf_vtable_parflags[] = {
156             0,
157             PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE
158             };
159             static pdl_datatypes pdl_acvf_vtable_partypes[] = { -1, -1 };
160             static PDL_Indx pdl_acvf_vtable_realdims_starts[] = { 0, 1 };
161             static PDL_Indx pdl_acvf_vtable_realdims_ind_ids[] = { 1, 0 };
162             static char *pdl_acvf_vtable_indnames[] = { "h","t" };
163             pdl_transvtable pdl_acvf_vtable = {
164             PDL_TRANS_DO_BROADCAST, 0, pdl_acvf_vtable_gentypes, 1, 2, NULL /*CORE21*/,
165             pdl_acvf_vtable_realdims, pdl_acvf_vtable_parnames,
166             pdl_acvf_vtable_parflags, pdl_acvf_vtable_partypes,
167             pdl_acvf_vtable_realdims_starts, pdl_acvf_vtable_realdims_ind_ids, 2,
168             2, pdl_acvf_vtable_indnames,
169             pdl_acvf_redodims, pdl_acvf_readdata, NULL,
170             NULL,
171             sizeof(pdl_params_acvf),"PDL::Stats::TS::acvf"
172             };
173              
174              
175 1           pdl_error pdl_run_acvf(pdl *x,pdl *v,IV lag) {
176 1           pdl_error PDL_err = {0, NULL, 0};
177 1 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
178 1           pdl_trans *__privtrans = PDL->create_trans(&pdl_acvf_vtable);
179 1 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
180 1           pdl_params_acvf *__params = __privtrans->params;
181 1           __privtrans->pdls[0] = x;
182 1           __privtrans->pdls[1] = v;
183 1 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
184 1           (__params->lag) = (lag); /* CType.get_copy */
185 1 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
186 1           return PDL_err;
187             }