File Coverage

lib/PDL/Math-pp-polyroots.c
Criterion Covered Total %
statement 38 39 97.4
branch 36 58 62.0
condition n/a
subroutine n/a
pod n/a
total 74 97 76.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/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-polyroots.c"
23              
24             #include
25             #include "protos.h"
26             #include "cpoly.h"
27              
28             #line 1857 "lib/PDL/PP.pm"
29             pdl_error pdl_polyroots_redodims(pdl_trans *__privtrans) {
30             pdl_error PDL_err = {0, NULL, 0};
31             #line 32 "lib/PDL/Math-pp-polyroots.c"
32 16           __privtrans->ind_sizes[0] = __privtrans->ind_sizes[1]-1;
33 16 100         PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans));
34 10           return PDL_err;
35             }
36              
37              
38             #line 1857 "lib/PDL/PP.pm"
39             pdl_error pdl_polyroots_readdata(pdl_trans *__privtrans) {
40             pdl_error PDL_err = {0, NULL, 0};
41             #line 42 "lib/PDL/Math-pp-polyroots.c"
42 10 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in polyroots:" "broadcast.incs NULL");
43             /* broadcastloop declarations */
44             int __brcloopval;
45             register PDL_Indx __tind0,__tind1; /* counters along dim */
46 10           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
47             /* dims here are how many steps along those dims */
48 10           register PDL_Indx __tinc0_cr = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
49 10           register PDL_Indx __tinc0_ci = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
50 10           register PDL_Indx __tinc0_rr = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
51 10           register PDL_Indx __tinc0_ri = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,0);
52 10           register PDL_Indx __tinc1_cr = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
53 10           register PDL_Indx __tinc1_ci = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
54 10           register PDL_Indx __tinc1_rr = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
55 10           register PDL_Indx __tinc1_ri = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,1);
56             #define PDL_BROADCASTLOOP_START_polyroots_readdata PDL_BROADCASTLOOP_START( \
57             readdata, \
58             __privtrans->broadcast, \
59             __privtrans->vtable, \
60             cr_datap += __offsp[0]; \
61             ci_datap += __offsp[1]; \
62             rr_datap += __offsp[2]; \
63             ri_datap += __offsp[3]; \
64             , \
65             ( ,cr_datap += __tinc1_cr - __tinc0_cr * __tdims0 \
66             ,ci_datap += __tinc1_ci - __tinc0_ci * __tdims0 \
67             ,rr_datap += __tinc1_rr - __tinc0_rr * __tdims0 \
68             ,ri_datap += __tinc1_ri - __tinc0_ri * __tdims0 \
69             ), \
70             ( ,cr_datap += __tinc0_cr \
71             ,ci_datap += __tinc0_ci \
72             ,rr_datap += __tinc0_rr \
73             ,ri_datap += __tinc0_ri \
74             ) \
75             )
76             #define PDL_BROADCASTLOOP_END_polyroots_readdata PDL_BROADCASTLOOP_END( \
77             __privtrans->broadcast, \
78             cr_datap -= __tinc1_cr * __tdims1 + __offsp[0]; \
79             ci_datap -= __tinc1_ci * __tdims1 + __offsp[1]; \
80             rr_datap -= __tinc1_rr * __tdims1 + __offsp[2]; \
81             ri_datap -= __tinc1_ri * __tdims1 + __offsp[3]; \
82             )
83 10           register PDL_Indx __inc_ci_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_ci_n;
84 10           register PDL_Indx __inc_cr_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_cr_n;
85 10           register PDL_Indx __inc_ri_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,3,0)]; (void)__inc_ri_m;
86 10           register PDL_Indx __inc_rr_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,2,0)]; (void)__inc_rr_m;
87             #ifndef PDL_DECLARE_PARAMS_polyroots_1
88             #define PDL_DECLARE_PARAMS_polyroots_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
89             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, cr, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
90             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, ci, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \
91             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, rr, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP) \
92             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, ri, (__privtrans->pdls[3]), 1, PDL_PPSYM_OP)
93             #endif
94             #define PDL_IF_BAD(t,f) f
95 10 50         switch (__privtrans->__datatype) { /* Start generic switch */
96 10           case PDL_D: {
97 10 50         PDL_DECLARE_PARAMS_polyroots_1(PDL_Double,D)
    50          
    50          
    50          
    50          
    50          
    50          
    100          
    50          
    50          
    100          
    50          
98 39 50         PDL_BROADCASTLOOP_START_polyroots_readdata { char *fail = cpoly(cr_datap, ci_datap, __privtrans->ind_sizes[0], rr_datap, ri_datap);
    50          
    50          
    50          
    50          
    100          
    100          
99 11 100         if (fail)
100 1           return PDL->make_error(PDL_EUSERERROR, "Error in polyroots:" "cpoly: %s",fail);
101 9 50         }PDL_BROADCASTLOOP_END_polyroots_readdata
    50          
102 9           } break;
103 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in polyroots: unhandled datatype(%d), only handles (D)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
104             }
105             #undef PDL_IF_BAD
106 9           return PDL_err;
107             }
108              
109             static pdl_datatypes pdl_polyroots_vtable_gentypes[] = { PDL_D, -1 };
110             static PDL_Indx pdl_polyroots_vtable_realdims[] = { 1, 1, 1, 1 };
111             static char *pdl_polyroots_vtable_parnames[] = { "cr","ci","rr","ri" };
112             static short pdl_polyroots_vtable_parflags[] = {
113             PDL_PARAM_ISPHYS,
114             PDL_PARAM_ISPHYS,
115             PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISPHYS|PDL_PARAM_ISWRITE,
116             PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISPHYS|PDL_PARAM_ISWRITE
117             };
118             static pdl_datatypes pdl_polyroots_vtable_partypes[] = { -1, -1, -1, -1 };
119             static PDL_Indx pdl_polyroots_vtable_realdims_starts[] = { 0, 1, 2, 3 };
120             static PDL_Indx pdl_polyroots_vtable_realdims_ind_ids[] = { 1, 1, 0, 0 };
121             static char *pdl_polyroots_vtable_indnames[] = { "m","n" };
122             pdl_transvtable pdl_polyroots_vtable = {
123             PDL_TRANS_DO_BROADCAST, 0, pdl_polyroots_vtable_gentypes, 2, 4, NULL /*CORE21*/,
124             pdl_polyroots_vtable_realdims, pdl_polyroots_vtable_parnames,
125             pdl_polyroots_vtable_parflags, pdl_polyroots_vtable_partypes,
126             pdl_polyroots_vtable_realdims_starts, pdl_polyroots_vtable_realdims_ind_ids, 4,
127             2, pdl_polyroots_vtable_indnames,
128             pdl_polyroots_redodims, pdl_polyroots_readdata, NULL,
129             NULL,
130             0,"PDL::Math::polyroots"
131             };
132              
133              
134 16           pdl_error pdl_run_polyroots(pdl *cr,pdl *ci,pdl *rr,pdl *ri) {
135 16           pdl_error PDL_err = {0, NULL, 0};
136 16 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
137 16           pdl_trans *__privtrans = PDL->create_trans(&pdl_polyroots_vtable);
138 16 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
139 16           __privtrans->pdls[0] = cr;
140 16           __privtrans->pdls[1] = ci;
141 16           __privtrans->pdls[2] = rr;
142 16           __privtrans->pdls[3] = ri;
143 16 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
144 16 100         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
145 9           return PDL_err;
146             }