pp-Cexp.c

filter: Statementstmt 61.1% 33 / 54 Branchbran 22.5% 23 / 102 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 35.9% 56 / 156 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« pp-Ccos.c ↑ Summary pp-Cp2r.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-Cexp.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_Cexp_redodims(pdl_trans *__privtrans) {
97 pdl_error PDL_err = {0, NULL, 0};
98 #line 99 "pp-Cexp.c"
99 3 __privtrans->ind_sizes[0] = 2;
100 3 ▶ PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans));
Branch: 1 branch
BranchTrueFalseTotal
PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans)); 0 3 3
101 3 return PDL_err;
102 }
103  
104  
105 #line 1888 "lib/PDL/PP.pm"
106 pdl_error pdl_Cexp_readdata(pdl_trans *__privtrans) {
107 pdl_error PDL_err = {0, NULL, 0};
108 #line 109 "pp-Cexp.c"
109 3 ▶ if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in Cexp:" "broadcast.incs NULL");
Branch: 1 branch
BranchTrueFalseTotal
if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in Cexp:" "broadcast.incs NULL"); 0 3 3
110 /* broadcastloop declarations */
111 int __brcloopval;
112 register PDL_Indx __tind0,__tind1; /* counters along dim */
113 3 register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
114 /* dims here are how many steps along those dims */
115 3 register PDL_Indx __tinc0_a = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
116 3 register PDL_Indx __tinc0_c = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
117 3 register PDL_Indx __tinc1_a = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
118 3 register PDL_Indx __tinc1_c = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
119 #define PDL_BROADCASTLOOP_START_Cexp_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_Cexp_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 3 register PDL_Indx __inc_a_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_a_m;
139 3 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_Cexp_1
141 #define PDL_DECLARE_PARAMS_Cexp_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 3 switch (__privtrans->__datatype) { /* Start generic switch */
147 0 case PDL_F: {
148 0 ▶ PDL_DECLARE_PARAMS_Cexp_1(PDL_Float,F)
Branch: 6 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_Cexp_1(PDL_Float,F) 0 0 0
PDL_DECLARE_PARAMS_Cexp_1(PDL_Float,F) 0 0 0
PDL_DECLARE_PARAMS_Cexp_1(PDL_Float,F) 0 0 0
PDL_DECLARE_PARAMS_Cexp_1(PDL_Float,F) 0 0 0
PDL_DECLARE_PARAMS_Cexp_1(PDL_Float,F) 0 0 0
PDL_DECLARE_PARAMS_Cexp_1(PDL_Float,F) 0 0 0
149 0 ▶ PDL_BROADCASTLOOP_START_Cexp_readdata {
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Cexp_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 0 PDL_Float ex = exp (ar);
152 double s, c;
153  
154 0 SINCOS (ai, s, c);
155 0 (c_datap)[0+(__inc_c_m*(0))] = ex * c;
156 0 (c_datap)[0+(__inc_c_m*(1))] = ex * s;
157 0 ▶ }PDL_BROADCASTLOOP_END_Cexp_readdata
Branch: 2 branches
BranchTrueFalseTotal
}PDL_BROADCASTLOOP_END_Cexp_readdata 0 0 0
}PDL_BROADCASTLOOP_END_Cexp_readdata 0 0 0
158 0 } break;
159 3 case PDL_D: {
160 3 ▶ PDL_DECLARE_PARAMS_Cexp_1(PDL_Double,D)
Branch: 6 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_Cexp_1(PDL_Double,D) 0 3 3
PDL_DECLARE_PARAMS_Cexp_1(PDL_Double,D) 3 0 3
PDL_DECLARE_PARAMS_Cexp_1(PDL_Double,D) 0 3 3
PDL_DECLARE_PARAMS_Cexp_1(PDL_Double,D) 0 3 3
PDL_DECLARE_PARAMS_Cexp_1(PDL_Double,D) 3 0 3
PDL_DECLARE_PARAMS_Cexp_1(PDL_Double,D) 0 3 3
161 11 ▶ PDL_BROADCASTLOOP_START_Cexp_readdata {
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 3 3
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 3 3
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 3 3
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 3 3
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 3 3
PDL_BROADCASTLOOP_START_Cexp_readdata { 5 3 8
PDL_BROADCASTLOOP_START_Cexp_readdata { 3 3 6
162 5 PDL_Double ar = (a_datap)[0+(__inc_a_m*(0))], ai = (a_datap)[0+(__inc_a_m*(1))];
163 5 PDL_Double ex = exp (ar);
164 double s, c;
165  
166 5 SINCOS (ai, s, c);
167 5 (c_datap)[0+(__inc_c_m*(0))] = ex * c;
168 5 (c_datap)[0+(__inc_c_m*(1))] = ex * s;
169 3 ▶ }PDL_BROADCASTLOOP_END_Cexp_readdata
Branch: 2 branches
BranchTrueFalseTotal
}PDL_BROADCASTLOOP_END_Cexp_readdata 0 3 3
}PDL_BROADCASTLOOP_END_Cexp_readdata 0 3 3
170 3 } break;
171 0 case PDL_LD: {
172 0 ▶ PDL_DECLARE_PARAMS_Cexp_1(PDL_LDouble,E)
Branch: 6 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_Cexp_1(PDL_LDouble,E) 0 0 0
PDL_DECLARE_PARAMS_Cexp_1(PDL_LDouble,E) 0 0 0
PDL_DECLARE_PARAMS_Cexp_1(PDL_LDouble,E) 0 0 0
PDL_DECLARE_PARAMS_Cexp_1(PDL_LDouble,E) 0 0 0
PDL_DECLARE_PARAMS_Cexp_1(PDL_LDouble,E) 0 0 0
PDL_DECLARE_PARAMS_Cexp_1(PDL_LDouble,E) 0 0 0
173 0 ▶ PDL_BROADCASTLOOP_START_Cexp_readdata {
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 0 0
PDL_BROADCASTLOOP_START_Cexp_readdata { 0 0 0
174 0 PDL_LDouble ar = (a_datap)[0+(__inc_a_m*(0))], ai = (a_datap)[0+(__inc_a_m*(1))];
175 0 PDL_LDouble ex = exp (ar);
176 double s, c;
177  
178 0 SINCOS (ai, s, c);
179 0 (c_datap)[0+(__inc_c_m*(0))] = ex * c;
180 0 (c_datap)[0+(__inc_c_m*(1))] = ex * s;
181 0 ▶ }PDL_BROADCASTLOOP_END_Cexp_readdata
Branch: 2 branches
BranchTrueFalseTotal
}PDL_BROADCASTLOOP_END_Cexp_readdata 0 0 0
}PDL_BROADCASTLOOP_END_Cexp_readdata 0 0 0
182 0 } break;
183 0 default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in Cexp: unhandled datatype(%d), only handles (FDE)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
184 }
185 #undef PDL_IF_BAD
186 3 return PDL_err;
187 }
188  
189 static pdl_datatypes pdl_Cexp_vtable_gentypes[] = { PDL_F, PDL_D, PDL_LD, -1 };
190 static PDL_Indx pdl_Cexp_vtable_realdims[] = { 1, 1 };
191 static char *pdl_Cexp_vtable_parnames[] = { "a","c" };
192 static short pdl_Cexp_vtable_parflags[] = {
193 0,
194 PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE
195 };
196 static pdl_datatypes pdl_Cexp_vtable_partypes[] = { -1, -1 };
197 static PDL_Indx pdl_Cexp_vtable_realdims_starts[] = { 0, 1 };
198 static PDL_Indx pdl_Cexp_vtable_realdims_ind_ids[] = { 0, 0 };
199 static char *pdl_Cexp_vtable_indnames[] = { "m" };
200 pdl_transvtable pdl_Cexp_vtable = {
201 PDL_TRANS_DO_BROADCAST, 0, pdl_Cexp_vtable_gentypes, 1, 2, NULL /*CORE21*/,
202 pdl_Cexp_vtable_realdims, pdl_Cexp_vtable_parnames,
203 pdl_Cexp_vtable_parflags, pdl_Cexp_vtable_partypes,
204 pdl_Cexp_vtable_realdims_starts, pdl_Cexp_vtable_realdims_ind_ids, 2,
205 1, pdl_Cexp_vtable_indnames,
206 pdl_Cexp_redodims, pdl_Cexp_readdata, NULL,
207 NULL,
208 0,"PDL::Complex::Cexp"
209 };
210  
211  
212 3 pdl_error pdl_run_Cexp(pdl *a,pdl *c) {
213 3 pdl_error PDL_err = {0, NULL, 0};
214 3 ▶ 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 3 3
215 3 pdl_trans *__privtrans = PDL->create_trans(&pdl_Cexp_vtable);
216 3 ▶ 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 3 3
217 3 __privtrans->pdls[0] = a;
218 3 __privtrans->pdls[1] = c;
219 3 ▶ PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
Branch: 1 branch
BranchTrueFalseTotal
PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); 0 3 3
220 3 ▶ PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
Branch: 1 branch
BranchTrueFalseTotal
PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); 0 3 3
221 3 return PDL_err;
222 }
« pp-Ccos.c ↑ Summary pp-Cp2r.c »