pp-Clog.c

filter: Statementstmt 66.6% 30 / 45 Branchbran 23.5% 24 / 102 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 36.7% 54 / 147 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« pp-Csinh.c ↑ Summary pp-Croots.c »
1  
2 #line 453 "lib/PDL/PP.pm"
3 /*
4 * THIS FILE WAS GENERATED BY PDL::PP from complex.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_Complex
21 extern Core* PDL; /* Structure hold core C functions */
22 #line 23 "pp-Clog.c"
23  
24 #include <math.h>
25  
26 #ifndef M_PI
27 # define M_PI 3.1415926535897932384626433832795029
28 #endif
29 #ifndef M_2PI
30 # define M_2PI (2. * M_PI)
31 #endif
32  
33 #if __GLIBC__ > 1 && (defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC9X)
34 # define CABS(r,i) hypot (r, i)
35 #else
36 static double
37 CABS (double r, double i)
38 {
39 double t;
40  
41 if (r < 0) r = - r;
42 if (i < 0) i = - i;
43  
44 if (i > r)
45 {
46 t = r; r = i; i = t;
47 }
48  
49 if (r + i == r)
50 return r;
51  
52 t = i / r;
53 return r * sqrt (1 + t*t);
54 }
55 #endif
56  
57 #if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 && defined __USE_GNU
58 # define SINCOS(x,s,c) sincos ((x), &(s), &(c))
59 #else
60 # define SINCOS(x,s,c) \
61 (s) = sin (x); \
62 (c) = cos (x);
63 #endif
64  
65  
66 #define CSQRT(type,ar,ai,cr,ci) \
67 type mag = CABS ((ar), (ai)); \
68 type t; \
69 \
70 if (mag == 0) \
71 (cr) = (ci) = 0; \
72 else if ((ar) > 0) \
73 { \
74 t = sqrt (0.5 * (mag + (ar))); \
75 (cr) = t; \
76 (ci) = 0.5 * (ai) / t; \
77 } \
78 else \
79 { \
80 t = sqrt (0.5 * (mag - (ar))); \
81 \
82 if ((ai) < 0) \
83 t = -t; \
84 \
85 (cr) = 0.5 * (ai) / t; \
86 (ci) = t; \
87 }
88  
89  
90 #define CLOG(ar,ai,cr,ci) \
91 (cr) = log (CABS ((ar), (ai))); \
92 (ci) = atan2 ((ai), (ar));
93  
94  
95 #line 1888 "lib/PDL/PP.pm"
96 pdl_error pdl_Clog_redodims(pdl_trans *__privtrans) {
97 pdl_error PDL_err = {0, NULL, 0};
98 #line 99 "pp-Clog.c"
99 5 __privtrans->ind_sizes[0] = 2;
100 5 ▶ PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans));
Branch: 1 branch
BranchTrueFalseTotal
PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans)); 0 5 5
101 5 return PDL_err;
102 }
103  
104  
105 #line 1888 "lib/PDL/PP.pm"
106 pdl_error pdl_Clog_readdata(pdl_trans *__privtrans) {
107 pdl_error PDL_err = {0, NULL, 0};
108 #line 109 "pp-Clog.c"
109 5 ▶ if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in Clog:" "broadcast.incs NULL");
Branch: 1 branch
BranchTrueFalseTotal
if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in Clog:" "broadcast.incs NULL"); 0 5 5
110 /* broadcastloop declarations */
111 int __brcloopval;
112 register PDL_Indx __tind0,__tind1; /* counters along dim */
113 5 register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
114 /* dims here are how many steps along those dims */
115 5 register PDL_Indx __tinc0_a = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
116 5 register PDL_Indx __tinc0_c = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
117 5 register PDL_Indx __tinc1_a = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
118 5 register PDL_Indx __tinc1_c = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
119 #define PDL_BROADCASTLOOP_START_Clog_readdata PDL_BROADCASTLOOP_START( \
120 readdata, \
121 __privtrans->broadcast, \
122 __privtrans->vtable, \
123 a_datap += __offsp[0]; \
124 c_datap += __offsp[1]; \
125 , \
126 ( ,a_datap += __tinc1_a - __tinc0_a * __tdims0 \
127 ,c_datap += __tinc1_c - __tinc0_c * __tdims0 \
128 ), \
129 ( ,a_datap += __tinc0_a \
130 ,c_datap += __tinc0_c \
131 ) \
132 )
133 #define PDL_BROADCASTLOOP_END_Clog_readdata PDL_BROADCASTLOOP_END( \
134 __privtrans->broadcast, \
135 a_datap -= __tinc1_a * __tdims1 + __offsp[0]; \
136 c_datap -= __tinc1_c * __tdims1 + __offsp[1]; \
137 )
138 5 register PDL_Indx __inc_a_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_a_m;
139 5 register PDL_Indx __inc_c_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_c_m;
140 #ifndef PDL_DECLARE_PARAMS_Clog_1
141 #define PDL_DECLARE_PARAMS_Clog_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
142 PDL_DECLARE_PARAMETER(PDL_TYPE_OP, a, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
143 PDL_DECLARE_PARAMETER(PDL_TYPE_OP, c, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP)
144 #endif
145 #define PDL_IF_BAD(t,f) f
146 5 switch (__privtrans->__datatype) { /* Start generic switch */
147 0 case PDL_F: {
148 0 ▶ PDL_DECLARE_PARAMS_Clog_1(PDL_Float,F)
Branch: 6 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_Clog_1(PDL_Float,F) 0 0 0
PDL_DECLARE_PARAMS_Clog_1(PDL_Float,F) 0 0 0
PDL_DECLARE_PARAMS_Clog_1(PDL_Float,F) 0 0 0
PDL_DECLARE_PARAMS_Clog_1(PDL_Float,F) 0 0 0
PDL_DECLARE_PARAMS_Clog_1(PDL_Float,F) 0 0 0
PDL_DECLARE_PARAMS_Clog_1(PDL_Float,F) 0 0 0
149 0 ▶ PDL_BROADCASTLOOP_START_Clog_readdata {
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
150 0 PDL_Float ar = (a_datap)[0+(__inc_a_m*(0))], ai = (a_datap)[0+(__inc_a_m*(1))];
151  
152 0 CLOG (ar, ai, (c_datap)[0+(__inc_c_m*(0))], (c_datap)[0+(__inc_c_m*(1))]);
153 0 ▶ }PDL_BROADCASTLOOP_END_Clog_readdata
Branch: 2 branches
BranchTrueFalseTotal
}PDL_BROADCASTLOOP_END_Clog_readdata 0 0 0
}PDL_BROADCASTLOOP_END_Clog_readdata 0 0 0
154 0 } break;
155 5 case PDL_D: {
156 5 ▶ PDL_DECLARE_PARAMS_Clog_1(PDL_Double,D)
Branch: 6 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_Clog_1(PDL_Double,D) 1 4 5
PDL_DECLARE_PARAMS_Clog_1(PDL_Double,D) 5 0 5
PDL_DECLARE_PARAMS_Clog_1(PDL_Double,D) 0 5 5
PDL_DECLARE_PARAMS_Clog_1(PDL_Double,D) 0 5 5
PDL_DECLARE_PARAMS_Clog_1(PDL_Double,D) 5 0 5
PDL_DECLARE_PARAMS_Clog_1(PDL_Double,D) 0 5 5
157 23 ▶ PDL_BROADCASTLOOP_START_Clog_readdata {
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_Clog_readdata { 0 5 5
PDL_BROADCASTLOOP_START_Clog_readdata { 0 5 5
PDL_BROADCASTLOOP_START_Clog_readdata { 0 5 5
PDL_BROADCASTLOOP_START_Clog_readdata { 0 5 5
PDL_BROADCASTLOOP_START_Clog_readdata { 0 5 5
PDL_BROADCASTLOOP_START_Clog_readdata { 8 5 13
PDL_BROADCASTLOOP_START_Clog_readdata { 5 5 10
158 8 PDL_Double ar = (a_datap)[0+(__inc_a_m*(0))], ai = (a_datap)[0+(__inc_a_m*(1))];
159  
160 8 CLOG (ar, ai, (c_datap)[0+(__inc_c_m*(0))], (c_datap)[0+(__inc_c_m*(1))]);
161 5 ▶ }PDL_BROADCASTLOOP_END_Clog_readdata
Branch: 2 branches
BranchTrueFalseTotal
}PDL_BROADCASTLOOP_END_Clog_readdata 0 5 5
}PDL_BROADCASTLOOP_END_Clog_readdata 0 5 5
162 5 } break;
163 0 case PDL_LD: {
164 0 ▶ PDL_DECLARE_PARAMS_Clog_1(PDL_LDouble,E)
Branch: 6 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_Clog_1(PDL_LDouble,E) 0 0 0
PDL_DECLARE_PARAMS_Clog_1(PDL_LDouble,E) 0 0 0
PDL_DECLARE_PARAMS_Clog_1(PDL_LDouble,E) 0 0 0
PDL_DECLARE_PARAMS_Clog_1(PDL_LDouble,E) 0 0 0
PDL_DECLARE_PARAMS_Clog_1(PDL_LDouble,E) 0 0 0
PDL_DECLARE_PARAMS_Clog_1(PDL_LDouble,E) 0 0 0
165 0 ▶ PDL_BROADCASTLOOP_START_Clog_readdata {
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Clog_readdata { 0 0 0
166 0 PDL_LDouble ar = (a_datap)[0+(__inc_a_m*(0))], ai = (a_datap)[0+(__inc_a_m*(1))];
167  
168 0 CLOG (ar, ai, (c_datap)[0+(__inc_c_m*(0))], (c_datap)[0+(__inc_c_m*(1))]);
169 0 ▶ }PDL_BROADCASTLOOP_END_Clog_readdata
Branch: 2 branches
BranchTrueFalseTotal
}PDL_BROADCASTLOOP_END_Clog_readdata 0 0 0
}PDL_BROADCASTLOOP_END_Clog_readdata 0 0 0
170 0 } break;
171 0 default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in Clog: unhandled datatype(%d), only handles (FDE)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
172 }
173 #undef PDL_IF_BAD
174 5 return PDL_err;
175 }
176  
177 static pdl_datatypes pdl_Clog_vtable_gentypes[] = { PDL_F, PDL_D, PDL_LD, -1 };
178 static PDL_Indx pdl_Clog_vtable_realdims[] = { 1, 1 };
179 static char *pdl_Clog_vtable_parnames[] = { "a","c" };
180 static short pdl_Clog_vtable_parflags[] = {
181 0,
182 PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE
183 };
184 static pdl_datatypes pdl_Clog_vtable_partypes[] = { -1, -1 };
185 static PDL_Indx pdl_Clog_vtable_realdims_starts[] = { 0, 1 };
186 static PDL_Indx pdl_Clog_vtable_realdims_ind_ids[] = { 0, 0 };
187 static char *pdl_Clog_vtable_indnames[] = { "m" };
188 pdl_transvtable pdl_Clog_vtable = {
189 PDL_TRANS_DO_BROADCAST, 0, pdl_Clog_vtable_gentypes, 1, 2, NULL /*CORE21*/,
190 pdl_Clog_vtable_realdims, pdl_Clog_vtable_parnames,
191 pdl_Clog_vtable_parflags, pdl_Clog_vtable_partypes,
192 pdl_Clog_vtable_realdims_starts, pdl_Clog_vtable_realdims_ind_ids, 2,
193 1, pdl_Clog_vtable_indnames,
194 pdl_Clog_redodims, pdl_Clog_readdata, NULL,
195 NULL,
196 0,"PDL::Complex::Clog"
197 };
198  
199  
200 5 pdl_error pdl_run_Clog(pdl *a,pdl *c) {
201 5 pdl_error PDL_err = {0, NULL, 0};
202 5 ▶ if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
Branch: 1 branch
BranchTrueFalseTotal
if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0}; 0 5 5
203 5 pdl_trans *__privtrans = PDL->create_trans(&pdl_Clog_vtable);
204 5 ▶ if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
Branch: 1 branch
BranchTrueFalseTotal
if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans"); 0 5 5
205 5 __privtrans->pdls[0] = a;
206 5 __privtrans->pdls[1] = c;
207 5 ▶ PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
Branch: 1 branch
BranchTrueFalseTotal
PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); 0 5 5
208 5 ▶ PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
Branch: 1 branch
BranchTrueFalseTotal
PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); 0 5 5
209 5 return PDL_err;
210 }
« pp-Csinh.c ↑ Summary pp-Croots.c »