File Coverage

lib/PDL/Stats/TS-pp-portmanteau.c
Criterion Covered Total %
statement 33 44 75.0
branch 29 90 32.2
condition n/a
subroutine n/a
pod n/a
total 62 134 46.2


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-portmanteau.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_portmanteau_readdata(pdl_trans *__privtrans) {
33             pdl_error PDL_err = {0, NULL, 0};
34             #line 35 "lib/PDL/Stats/TS-pp-portmanteau.c"
35 1           register PDL_Indx __h_size = __privtrans->ind_sizes[0];
36 1 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in portmanteau:" "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_r = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
43 1           register PDL_Indx __tinc0_t = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
44 1           register PDL_Indx __tinc0_Q = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
45 1           register PDL_Indx __tinc1_r = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
46 1           register PDL_Indx __tinc1_t = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
47 1           register PDL_Indx __tinc1_Q = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
48             #define PDL_BROADCASTLOOP_START_portmanteau_readdata PDL_BROADCASTLOOP_START( \
49             readdata, \
50             __privtrans->broadcast, \
51             __privtrans->vtable, \
52             r_datap += __offsp[0]; \
53             t_datap += __offsp[1]; \
54             Q_datap += __offsp[2]; \
55             , \
56             ( ,r_datap += __tinc1_r - __tinc0_r * __tdims0 \
57             ,t_datap += __tinc1_t - __tinc0_t * __tdims0 \
58             ,Q_datap += __tinc1_Q - __tinc0_Q * __tdims0 \
59             ), \
60             ( ,r_datap += __tinc0_r \
61             ,t_datap += __tinc0_t \
62             ,Q_datap += __tinc0_Q \
63             ) \
64             )
65             #define PDL_BROADCASTLOOP_END_portmanteau_readdata PDL_BROADCASTLOOP_END( \
66             __privtrans->broadcast, \
67             r_datap -= __tinc1_r * __tdims1 + __offsp[0]; \
68             t_datap -= __tinc1_t * __tdims1 + __offsp[1]; \
69             Q_datap -= __tinc1_Q * __tdims1 + __offsp[2]; \
70             )
71 1           register PDL_Indx __inc_r_h = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_r_h;
72             #ifndef PDL_DECLARE_PARAMS_portmanteau_1
73             #define PDL_DECLARE_PARAMS_portmanteau_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_t,PDL_PPSYM_PARAM_t) \
74             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, r, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
75             PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_t, t, (__privtrans->pdls[1]), 1, PDL_PPSYM_PARAM_t) \
76             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, Q, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP)
77             #endif
78             #define PDL_IF_BAD(t,f) f
79 1           switch (__privtrans->__datatype) { /* Start generic switch */
80 0           case PDL_F: {
81 0 0         PDL_DECLARE_PARAMS_portmanteau_1(PDL_Float,F,PDL_LongLong,Q)
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
82 0 0         PDL_BROADCASTLOOP_START_portmanteau_readdata {
    0          
    0          
    0          
    0          
    0          
    0          
83             PDL_Float sum;
84 0           sum = 0;
85 0 0         {/* Open h */ PDL_EXPAND2(register PDL_Indx h=0, __h_stop=(__h_size)); for(; h<__h_stop; h+=1) {
86 0 0         if (h)
87 0           sum += (r_datap)[0+(__inc_r_h*(h))]*(r_datap)[0+(__inc_r_h*(h))] / ((t_datap)[0] - h);
88             }} /* Close h */
89 0           (Q_datap)[0] = (t_datap)[0] * ((t_datap)[0]+2) * sum;
90 0 0         }PDL_BROADCASTLOOP_END_portmanteau_readdata
    0          
91 0           } break;
92 1           case PDL_D: {
93 1 50         PDL_DECLARE_PARAMS_portmanteau_1(PDL_Double,D,PDL_LongLong,Q)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
94 4 50         PDL_BROADCASTLOOP_START_portmanteau_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
95             PDL_Double sum;
96 1           sum = 0;
97 7 100         {/* Open h */ PDL_EXPAND2(register PDL_Indx h=0, __h_stop=(__h_size)); for(; h<__h_stop; h+=1) {
98 6 100         if (h)
99 5           sum += (r_datap)[0+(__inc_r_h*(h))]*(r_datap)[0+(__inc_r_h*(h))] / ((t_datap)[0] - h);
100             }} /* Close h */
101 1           (Q_datap)[0] = (t_datap)[0] * ((t_datap)[0]+2) * sum;
102 1 50         }PDL_BROADCASTLOOP_END_portmanteau_readdata
    50          
103 1           } break;
104 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in portmanteau: unhandled datatype(%d), only handles (FD)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
105             }
106             #undef PDL_IF_BAD
107 1           return PDL_err;
108             }
109              
110             static pdl_datatypes pdl_portmanteau_vtable_gentypes[] = { PDL_F, PDL_D, -1 };
111             static PDL_Indx pdl_portmanteau_vtable_realdims[] = { 1, 0, 0 };
112             static char *pdl_portmanteau_vtable_parnames[] = { "r","t","Q" };
113             static short pdl_portmanteau_vtable_parflags[] = {
114             0,
115             PDL_PARAM_ISTYPED,
116             PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE
117             };
118             static pdl_datatypes pdl_portmanteau_vtable_partypes[] = { -1, PDL_LL, -1 };
119             static PDL_Indx pdl_portmanteau_vtable_realdims_starts[] = { 0, 1, 1 };
120             static PDL_Indx pdl_portmanteau_vtable_realdims_ind_ids[] = { 0 };
121             static char *pdl_portmanteau_vtable_indnames[] = { "h" };
122             pdl_transvtable pdl_portmanteau_vtable = {
123             PDL_TRANS_DO_BROADCAST, 0, pdl_portmanteau_vtable_gentypes, 2, 3, NULL /*CORE21*/,
124             pdl_portmanteau_vtable_realdims, pdl_portmanteau_vtable_parnames,
125             pdl_portmanteau_vtable_parflags, pdl_portmanteau_vtable_partypes,
126             pdl_portmanteau_vtable_realdims_starts, pdl_portmanteau_vtable_realdims_ind_ids, 1,
127             1, pdl_portmanteau_vtable_indnames,
128             NULL, pdl_portmanteau_readdata, NULL,
129             NULL,
130             0,"PDL::Stats::TS::portmanteau"
131             };
132              
133              
134 1           pdl_error pdl_run_portmanteau(pdl *r,pdl *t,pdl *Q) {
135 1           pdl_error PDL_err = {0, NULL, 0};
136 1 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
137 1           pdl_trans *__privtrans = PDL->create_trans(&pdl_portmanteau_vtable);
138 1 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
139 1           __privtrans->pdls[0] = r;
140 1           __privtrans->pdls[1] = t;
141 1           __privtrans->pdls[2] = Q;
142 1 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
143 1 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
144 1           return PDL_err;
145             }