File Coverage

lib/PDL/Math-pp-polyval.c
Criterion Covered Total %
statement 30 31 96.7
branch 28 50 56.0
condition n/a
subroutine n/a
pod n/a
total 58 81 71.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/Math.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_Math
21             extern Core* PDL; /* Structure hold core C functions */
22             #line 23 "lib/PDL/Math-pp-polyval.c"
23              
24             #include
25             #include "protos.h"
26             #include "cpoly.h"
27              
28             #line 1857 "lib/PDL/PP.pm"
29             pdl_error pdl_polyval_readdata(pdl_trans *__privtrans) {
30             pdl_error PDL_err = {0, NULL, 0};
31             #line 32 "lib/PDL/Math-pp-polyval.c"
32 4           register PDL_Indx __n_size = __privtrans->ind_sizes[0];
33 4 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in polyval:" "broadcast.incs NULL");
34             /* broadcastloop declarations */
35             int __brcloopval;
36             register PDL_Indx __tind0,__tind1; /* counters along dim */
37 4           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
38             /* dims here are how many steps along those dims */
39 4           register PDL_Indx __tinc0_c = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
40 4           register PDL_Indx __tinc0_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
41 4           register PDL_Indx __tinc0_y = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
42 4           register PDL_Indx __tinc1_c = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
43 4           register PDL_Indx __tinc1_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
44 4           register PDL_Indx __tinc1_y = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
45             #define PDL_BROADCASTLOOP_START_polyval_readdata PDL_BROADCASTLOOP_START( \
46             readdata, \
47             __privtrans->broadcast, \
48             __privtrans->vtable, \
49             c_datap += __offsp[0]; \
50             x_datap += __offsp[1]; \
51             y_datap += __offsp[2]; \
52             , \
53             ( ,c_datap += __tinc1_c - __tinc0_c * __tdims0 \
54             ,x_datap += __tinc1_x - __tinc0_x * __tdims0 \
55             ,y_datap += __tinc1_y - __tinc0_y * __tdims0 \
56             ), \
57             ( ,c_datap += __tinc0_c \
58             ,x_datap += __tinc0_x \
59             ,y_datap += __tinc0_y \
60             ) \
61             )
62             #define PDL_BROADCASTLOOP_END_polyval_readdata PDL_BROADCASTLOOP_END( \
63             __privtrans->broadcast, \
64             c_datap -= __tinc1_c * __tdims1 + __offsp[0]; \
65             x_datap -= __tinc1_x * __tdims1 + __offsp[1]; \
66             y_datap -= __tinc1_y * __tdims1 + __offsp[2]; \
67             )
68 4           register PDL_Indx __inc_c_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_c_n;
69             #ifndef PDL_DECLARE_PARAMS_polyval_1
70             #define PDL_DECLARE_PARAMS_polyval_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
71             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, c, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
72             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, x, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \
73             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, y, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP)
74             #endif
75             #define PDL_IF_BAD(t,f) f
76 4 50         switch (__privtrans->__datatype) { /* Start generic switch */
77 4           case PDL_CD: {
78 4 50         PDL_DECLARE_PARAMS_polyval_1(PDL_CDouble,C)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
79 24 50         PDL_BROADCASTLOOP_START_polyval_readdata {PDL_CDouble vc = (c_datap)[0+(__inc_c_n*(0))], sc = (x_datap)[0];
    50          
    50          
    50          
    50          
    100          
    100          
80 36 100         {/* Open n=1 */ PDL_EXPAND2(register PDL_Indx n=PDLMAX((1),0), __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { vc = vc*sc + (c_datap)[0+(__inc_c_n*(n))]; }} /* Close n=1 */
81 12           (y_datap)[0] = vc;
82 4 50         }PDL_BROADCASTLOOP_END_polyval_readdata
    50          
83 4           } break;
84 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in polyval: unhandled datatype(%d), only handles (C)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
85             }
86             #undef PDL_IF_BAD
87 4           return PDL_err;
88             }
89              
90             static pdl_datatypes pdl_polyval_vtable_gentypes[] = { PDL_CD, -1 };
91             static PDL_Indx pdl_polyval_vtable_realdims[] = { 1, 0, 0 };
92             static char *pdl_polyval_vtable_parnames[] = { "c","x","y" };
93             static short pdl_polyval_vtable_parflags[] = {
94             0,
95             0,
96             PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE
97             };
98             static pdl_datatypes pdl_polyval_vtable_partypes[] = { -1, -1, -1 };
99             static PDL_Indx pdl_polyval_vtable_realdims_starts[] = { 0, 1, 1 };
100             static PDL_Indx pdl_polyval_vtable_realdims_ind_ids[] = { 0 };
101             static char *pdl_polyval_vtable_indnames[] = { "n" };
102             pdl_transvtable pdl_polyval_vtable = {
103             PDL_TRANS_DO_BROADCAST, 0, pdl_polyval_vtable_gentypes, 2, 3, NULL /*CORE21*/,
104             pdl_polyval_vtable_realdims, pdl_polyval_vtable_parnames,
105             pdl_polyval_vtable_parflags, pdl_polyval_vtable_partypes,
106             pdl_polyval_vtable_realdims_starts, pdl_polyval_vtable_realdims_ind_ids, 1,
107             1, pdl_polyval_vtable_indnames,
108             NULL, pdl_polyval_readdata, NULL,
109             NULL,
110             0,"PDL::Math::polyval"
111             };
112              
113              
114 4           pdl_error pdl_run_polyval(pdl *c,pdl *x,pdl *y) {
115 4           pdl_error PDL_err = {0, NULL, 0};
116 4 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
117 4           pdl_trans *__privtrans = PDL->create_trans(&pdl_polyval_vtable);
118 4 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
119 4           __privtrans->pdls[0] = c;
120 4           __privtrans->pdls[1] = x;
121 4           __privtrans->pdls[2] = y;
122 4 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
123 4 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
124 4           return PDL_err;
125             }