File Coverage

lib/PDL/Math-pp-polyfromroots.c
Criterion Covered Total %
statement 33 34 97.0
branch 30 50 60.0
condition n/a
subroutine n/a
pod n/a
total 63 84 75.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/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-polyfromroots.c"
23              
24             #include
25             #include "protos.h"
26             #include "cpoly.h"
27              
28             #line 1857 "lib/PDL/PP.pm"
29             pdl_error pdl_polyfromroots_redodims(pdl_trans *__privtrans) {
30             pdl_error PDL_err = {0, NULL, 0};
31             #line 32 "lib/PDL/Math-pp-polyfromroots.c"
32 4           __privtrans->ind_sizes[1] = __privtrans->ind_sizes[0]+1;
33 4 50         PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans));
34 4           return PDL_err;
35             }
36              
37              
38             #line 1857 "lib/PDL/PP.pm"
39             pdl_error pdl_polyfromroots_readdata(pdl_trans *__privtrans) {
40             pdl_error PDL_err = {0, NULL, 0};
41             #line 42 "lib/PDL/Math-pp-polyfromroots.c"
42 4           register PDL_Indx __m_size = __privtrans->ind_sizes[0];
43 4 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in polyfromroots:" "broadcast.incs NULL");
44             /* broadcastloop declarations */
45             int __brcloopval;
46             register PDL_Indx __tind0,__tind1; /* counters along dim */
47 4           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
48             /* dims here are how many steps along those dims */
49 4           register PDL_Indx __tinc0_r = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
50 4           register PDL_Indx __tinc0_c = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
51 4           register PDL_Indx __tinc1_r = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
52 4           register PDL_Indx __tinc1_c = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
53             #define PDL_BROADCASTLOOP_START_polyfromroots_readdata PDL_BROADCASTLOOP_START( \
54             readdata, \
55             __privtrans->broadcast, \
56             __privtrans->vtable, \
57             r_datap += __offsp[0]; \
58             c_datap += __offsp[1]; \
59             , \
60             ( ,r_datap += __tinc1_r - __tinc0_r * __tdims0 \
61             ,c_datap += __tinc1_c - __tinc0_c * __tdims0 \
62             ), \
63             ( ,r_datap += __tinc0_r \
64             ,c_datap += __tinc0_c \
65             ) \
66             )
67             #define PDL_BROADCASTLOOP_END_polyfromroots_readdata PDL_BROADCASTLOOP_END( \
68             __privtrans->broadcast, \
69             r_datap -= __tinc1_r * __tdims1 + __offsp[0]; \
70             c_datap -= __tinc1_c * __tdims1 + __offsp[1]; \
71             )
72 4           register PDL_Indx __inc_c_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_c_n;
73 4           register PDL_Indx __inc_r_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_r_m;
74             #ifndef PDL_DECLARE_PARAMS_polyfromroots_1
75             #define PDL_DECLARE_PARAMS_polyfromroots_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
76             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, r, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
77             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, c, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP)
78             #endif
79             #define PDL_IF_BAD(t,f) f
80 4 50         switch (__privtrans->__datatype) { /* Start generic switch */
81 4           case PDL_CD: {
82 4 50         PDL_DECLARE_PARAMS_polyfromroots_1(PDL_CDouble,C)
    50          
    50          
    50          
    50          
    50          
83 16 50         PDL_BROADCASTLOOP_START_polyfromroots_readdata {(c_datap)[0+(__inc_c_n*(0))] = 1.0;
    50          
    50          
    50          
    50          
    100          
    100          
84 44 100         {/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) { (c_datap)[0+(__inc_c_n*(m+1))] = 0.0; }} /* Close m */
85             PDL_Indx k;
86 44 100         {/* Open m */ PDL_EXPAND2(register PDL_Indx m=0, __m_stop=(__m_size)); for(; m<__m_stop; m+=1) {
87 260 100         for (k = m; k >= 0; k--) /* count down to use data before we mutate */
88 220           (c_datap)[0+(__inc_c_n*(k+1))] -= (r_datap)[0+(__inc_r_m*(m))] * (c_datap)[0+(__inc_c_n*(k))];
89             }} /* Close m */
90 4 50         }PDL_BROADCASTLOOP_END_polyfromroots_readdata
    50          
91 4           } break;
92 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in polyfromroots: unhandled datatype(%d), only handles (C)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
93             }
94             #undef PDL_IF_BAD
95 4           return PDL_err;
96             }
97              
98             static pdl_datatypes pdl_polyfromroots_vtable_gentypes[] = { PDL_CD, -1 };
99             static PDL_Indx pdl_polyfromroots_vtable_realdims[] = { 1, 1 };
100             static char *pdl_polyfromroots_vtable_parnames[] = { "r","c" };
101             static short pdl_polyfromroots_vtable_parflags[] = {
102             0,
103             PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE
104             };
105             static pdl_datatypes pdl_polyfromroots_vtable_partypes[] = { -1, -1 };
106             static PDL_Indx pdl_polyfromroots_vtable_realdims_starts[] = { 0, 1 };
107             static PDL_Indx pdl_polyfromroots_vtable_realdims_ind_ids[] = { 0, 1 };
108             static char *pdl_polyfromroots_vtable_indnames[] = { "m","n" };
109             pdl_transvtable pdl_polyfromroots_vtable = {
110             PDL_TRANS_DO_BROADCAST, 0, pdl_polyfromroots_vtable_gentypes, 1, 2, NULL /*CORE21*/,
111             pdl_polyfromroots_vtable_realdims, pdl_polyfromroots_vtable_parnames,
112             pdl_polyfromroots_vtable_parflags, pdl_polyfromroots_vtable_partypes,
113             pdl_polyfromroots_vtable_realdims_starts, pdl_polyfromroots_vtable_realdims_ind_ids, 2,
114             2, pdl_polyfromroots_vtable_indnames,
115             pdl_polyfromroots_redodims, pdl_polyfromroots_readdata, NULL,
116             NULL,
117             0,"PDL::Math::polyfromroots"
118             };
119              
120              
121 4           pdl_error pdl_run_polyfromroots(pdl *r,pdl *c) {
122 4           pdl_error PDL_err = {0, NULL, 0};
123 4 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
124 4           pdl_trans *__privtrans = PDL->create_trans(&pdl_polyfromroots_vtable);
125 4 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
126 4           __privtrans->pdls[0] = r;
127 4           __privtrans->pdls[1] = c;
128 4 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
129 4 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
130 4           return PDL_err;
131             }