File Coverage

lib/PDL/Math-pp-csqrt_up.c
Criterion Covered Total %
statement 48 49 97.9
branch 107 190 56.3
condition n/a
subroutine n/a
pod n/a
total 155 239 64.8


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-csqrt_up.c"
23              
24             #include
25             #include "protos.h"
26             #include "cpoly.h"
27              
28             #line 1857 "lib/PDL/PP.pm"
29             pdl_error pdl_csqrt_up_readdata(pdl_trans *__privtrans) {
30             pdl_error PDL_err = {0, NULL, 0};
31             #line 32 "lib/PDL/Math-pp-csqrt_up.c"
32 11 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in csqrt_up:" "broadcast.incs NULL");
33             /* broadcastloop declarations */
34             int __brcloopval;
35             register PDL_Indx __tind0,__tind1; /* counters along dim */
36 11           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
37             /* dims here are how many steps along those dims */
38 11           register PDL_Indx __tinc0_i = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
39 11           register PDL_Indx __tinc0_o = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
40 11           register PDL_Indx __tinc1_i = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
41 11           register PDL_Indx __tinc1_o = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
42             #define PDL_BROADCASTLOOP_START_csqrt_up_readdata PDL_BROADCASTLOOP_START( \
43             readdata, \
44             __privtrans->broadcast, \
45             __privtrans->vtable, \
46             i_datap += __offsp[0]; \
47             o_datap += __offsp[1]; \
48             , \
49             ( ,i_datap += __tinc1_i - __tinc0_i * __tdims0 \
50             ,o_datap += __tinc1_o - __tinc0_o * __tdims0 \
51             ), \
52             ( ,i_datap += __tinc0_i \
53             ,o_datap += __tinc0_o \
54             ) \
55             )
56             #define PDL_BROADCASTLOOP_END_csqrt_up_readdata PDL_BROADCASTLOOP_END( \
57             __privtrans->broadcast, \
58             i_datap -= __tinc1_i * __tdims1 + __offsp[0]; \
59             o_datap -= __tinc1_o * __tdims1 + __offsp[1]; \
60             )
61             #ifndef PDL_DECLARE_PARAMS_csqrt_up_1
62             #define PDL_DECLARE_PARAMS_csqrt_up_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_o,PDL_PPSYM_PARAM_o) \
63             PDL_DECLARE_PARAMETER(PDL_TYPE_OP, i, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
64             PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_o, o, (__privtrans->pdls[1]), 1, PDL_PPSYM_PARAM_o)
65             #endif
66             #define PDL_IF_BAD(t,f) f
67 11           switch (__privtrans->__datatype) { /* Start generic switch */
68 1           case PDL_F: {
69 1 50         PDL_DECLARE_PARAMS_csqrt_up_1(PDL_Float,F,PDL_CFloat,G)
    50          
    50          
    50          
    50          
    50          
70 9 50         PDL_BROADCASTLOOP_START_csqrt_up_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
71             #line 522 "lib/PDL/Math.pd"
72             PDL_CFloat tmp = (i_datap)[0];
73             tmp = csqrt(tmp);
74             if (cimag(tmp)<0)
75             tmp = -tmp;
76             (o_datap)[0] = tmp;
77             #line 78 "lib/PDL/Math-pp-csqrt_up.c"
78 1 50         }PDL_BROADCASTLOOP_END_csqrt_up_readdata
    50          
79 1           } break;
80 4           case PDL_D: {
81 4 50         PDL_DECLARE_PARAMS_csqrt_up_1(PDL_Double,D,PDL_CDouble,C)
    50          
    50          
    50          
    50          
    50          
82 30 50         PDL_BROADCASTLOOP_START_csqrt_up_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
83             #line 522 "lib/PDL/Math.pd"
84             PDL_CDouble tmp = (i_datap)[0];
85             tmp = csqrt(tmp);
86             if (cimag(tmp)<0)
87             tmp = -tmp;
88             (o_datap)[0] = tmp;
89             #line 90 "lib/PDL/Math-pp-csqrt_up.c"
90 4 50         }PDL_BROADCASTLOOP_END_csqrt_up_readdata
    50          
91 4           } break;
92 1           case PDL_LD: {
93 1 50         PDL_DECLARE_PARAMS_csqrt_up_1(PDL_LDouble,E,PDL_CLDouble,H)
    50          
    50          
    50          
    50          
    50          
94 9 50         PDL_BROADCASTLOOP_START_csqrt_up_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
95             #line 522 "lib/PDL/Math.pd"
96             PDL_CLDouble tmp = (i_datap)[0];
97             tmp = csqrt(tmp);
98             if (cimag(tmp)<0)
99             tmp = -tmp;
100             (o_datap)[0] = tmp;
101             #line 102 "lib/PDL/Math-pp-csqrt_up.c"
102 1 50         }PDL_BROADCASTLOOP_END_csqrt_up_readdata
    50          
103 1           } break;
104 1           case PDL_CF: {
105 1 50         PDL_DECLARE_PARAMS_csqrt_up_1(PDL_CFloat,G,PDL_CFloat,G)
    50          
    50          
    50          
    50          
    50          
106 9 50         PDL_BROADCASTLOOP_START_csqrt_up_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
107             #line 522 "lib/PDL/Math.pd"
108             PDL_CFloat tmp = (i_datap)[0];
109             tmp = csqrt(tmp);
110             if (cimag(tmp)<0)
111             tmp = -tmp;
112             (o_datap)[0] = tmp;
113             #line 114 "lib/PDL/Math-pp-csqrt_up.c"
114 1 50         }PDL_BROADCASTLOOP_END_csqrt_up_readdata
    50          
115 1           } break;
116 3           case PDL_CD: {
117 3 50         PDL_DECLARE_PARAMS_csqrt_up_1(PDL_CDouble,C,PDL_CDouble,C)
    50          
    50          
    50          
    50          
    50          
118 22 50         PDL_BROADCASTLOOP_START_csqrt_up_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
119             #line 522 "lib/PDL/Math.pd"
120             PDL_CDouble tmp = (i_datap)[0];
121             tmp = csqrt(tmp);
122             if (cimag(tmp)<0)
123             tmp = -tmp;
124             (o_datap)[0] = tmp;
125             #line 126 "lib/PDL/Math-pp-csqrt_up.c"
126 3 50         }PDL_BROADCASTLOOP_END_csqrt_up_readdata
    50          
127 3           } break;
128 1           case PDL_CLD: {
129 1 50         PDL_DECLARE_PARAMS_csqrt_up_1(PDL_CLDouble,H,PDL_CLDouble,H)
    50          
    50          
    50          
    50          
    50          
130 9 50         PDL_BROADCASTLOOP_START_csqrt_up_readdata {
    50          
    50          
    50          
    50          
    100          
    100          
131             #line 522 "lib/PDL/Math.pd"
132             PDL_CLDouble tmp = (i_datap)[0];
133             tmp = csqrt(tmp);
134             if (cimag(tmp)<0)
135             tmp = -tmp;
136             (o_datap)[0] = tmp;
137             #line 138 "lib/PDL/Math-pp-csqrt_up.c"
138 1 50         }PDL_BROADCASTLOOP_END_csqrt_up_readdata
    50          
139 1           } break;
140 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in csqrt_up: unhandled datatype(%d), only handles (FDEGCH)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
141             }
142             #undef PDL_IF_BAD
143 11           return PDL_err;
144             }
145              
146             static pdl_datatypes pdl_csqrt_up_vtable_gentypes[] = { PDL_F, PDL_LD, PDL_CF, PDL_CD, PDL_CLD, PDL_D, -1 };
147             static PDL_Indx pdl_csqrt_up_vtable_realdims[] = { 0, 0 };
148             static char *pdl_csqrt_up_vtable_parnames[] = { "i","o" };
149             static short pdl_csqrt_up_vtable_parflags[] = {
150             0,
151             PDL_PARAM_ISCOMPLEX|PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE
152             };
153             static pdl_datatypes pdl_csqrt_up_vtable_partypes[] = { -1, -1 };
154             static PDL_Indx pdl_csqrt_up_vtable_realdims_starts[] = { 0, 0 };
155             static PDL_Indx pdl_csqrt_up_vtable_realdims_ind_ids[] = { 0 };
156             static char *pdl_csqrt_up_vtable_indnames[] = { "" };
157             pdl_transvtable pdl_csqrt_up_vtable = {
158             PDL_TRANS_DO_BROADCAST, 0, pdl_csqrt_up_vtable_gentypes, 1, 2, NULL /*CORE21*/,
159             pdl_csqrt_up_vtable_realdims, pdl_csqrt_up_vtable_parnames,
160             pdl_csqrt_up_vtable_parflags, pdl_csqrt_up_vtable_partypes,
161             pdl_csqrt_up_vtable_realdims_starts, pdl_csqrt_up_vtable_realdims_ind_ids, 0,
162             0, pdl_csqrt_up_vtable_indnames,
163             NULL, pdl_csqrt_up_readdata, NULL,
164             NULL,
165             0,"PDL::Math::csqrt_up"
166             };
167              
168              
169 11           pdl_error pdl_run_csqrt_up(pdl *i,pdl *o) {
170 11           pdl_error PDL_err = {0, NULL, 0};
171 11 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
172 11           pdl_trans *__privtrans = PDL->create_trans(&pdl_csqrt_up_vtable);
173 11 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
174 11           __privtrans->pdls[0] = i;
175 11           __privtrans->pdls[1] = o;
176 11 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
177 11 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
178 11           return PDL_err;
179             }