lib/PDL/Primitive-pp-pchip_bvalu.c

filter: Statementstmt 68.0% 51 / 75 Branchbran 19.1% 47 / 246 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 30.5% 98 / 321 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« lib/PDL/Primitive-pp-pchip_chia.c ↑ Summary lib/PDL/Primitive-pp-append.c »
1  
2 #line 453 "lib/PDL/PP.pm"
3 /*
4 * THIS FILE WAS GENERATED BY PDL::PP from lib/PDL/Primitive.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_Primitive
21 extern Core* PDL; /* Structure hold core C functions */
22 #line 23 "lib/PDL/Primitive-pp-pchip_bvalu.c"
23 extern int pdl_srand_threads;
24 extern uint64_t *pdl_rand_state;
25 void pdl_srand(uint64_t **s, uint64_t seed, int n);
26 double pdl_drand(uint64_t *s);
27 #define PDL_MAYBE_SRAND \
28 if (pdl_srand_threads < 0) \
29 pdl_srand(&pdl_rand_state, PDL->pdl_seed(), PDL->online_cpus());
30 #define PDL_RAND_SET_OFFSET(v, thr, pdl) \
31 if (v < 0) { \
32 if (thr.mag_nthr >= 0) { \
33 int thr_no = PDL->magic_get_thread(pdl); \
34 if (thr_no < 0) return PDL->make_error_simple(PDL_EFATAL, "Invalid pdl_magic_get_thread!"); \
35 v = thr_no == 0 ? thr_no : thr_no % PDL->online_cpus(); \
36 } else { \
37 v = 0; \
38 } \
39 }
40  
41 #line 1888 "lib/PDL/PP.pm"
42 pdl_error pdl_pchip_bvalu_redodims(pdl_trans *__privtrans) {
43 pdl_error PDL_err = {0, NULL, 0};
44 #line 45 "lib/PDL/Primitive-pp-pchip_bvalu.c"
45 1 __privtrans->ind_sizes[0] = 3*(__privtrans->ind_sizes[2]-__privtrans->ind_sizes[1]);
46 #ifndef PDL_DECLARE_PARAMS_pchip_bvalu_0
47 #define PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_ideriv,PDL_PPSYM_PARAM_ideriv,PDL_TYPE_PARAM_inbv,PDL_PPSYM_PARAM_inbv) \
48 PDL_DECLARE_PARAMETER(PDL_TYPE_OP, t, (__privtrans->pdls[0]), 0, PDL_PPSYM_OP) \
49 PDL_DECLARE_PARAMETER(PDL_TYPE_OP, a, (__privtrans->pdls[1]), 0, PDL_PPSYM_OP) \
50 PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_ideriv, ideriv, (__privtrans->pdls[2]), 0, PDL_PPSYM_PARAM_ideriv) \
51 PDL_DECLARE_PARAMETER(PDL_TYPE_OP, x, (__privtrans->pdls[3]), 0, PDL_PPSYM_OP) \
52 PDL_DECLARE_PARAMETER(PDL_TYPE_OP, ans, (__privtrans->pdls[4]), 0, PDL_PPSYM_OP) \
53 PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_inbv, inbv, (__privtrans->pdls[5]), 0, PDL_PPSYM_PARAM_inbv) \
54 PDL_DECLARE_PARAMETER(PDL_TYPE_OP, work, (__privtrans->pdls[6]), 0, PDL_PPSYM_OP)
55 #endif
56 #define PDL_IF_BAD(t,f) f
57 1 switch (__privtrans->__datatype) { /* Start generic switch */
58 0 case PDL_F: {
59 0 ▶ PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Float,F,PDL_Indx,N,PDL_Indx,N)
Branch: 7 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
60 0 {PDL_Indx k = __privtrans->ind_sizes[2] - __privtrans->ind_sizes[1];
61 0 ▶ if (k < 1) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "K DOES NOT SATISFY K.GE.1");
Branch: 1 branch
BranchTrueFalseTotal
if (k < 1) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "K DOES NOT SATISFY K.GE.1"); 0 0 0
62 0 ▶ if (__privtrans->ind_sizes[1] < k) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "N DOES NOT SATISFY N.GE.K");
Branch: 1 branch
BranchTrueFalseTotal
if (__privtrans->ind_sizes[1] < k) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "N DOES NOT SATISFY N.GE.K"); 0 0 0
63 }
64 0 } break;
65 1 case PDL_D: {
66 1 ▶ PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Double,D,PDL_Indx,N,PDL_Indx,N)
Branch: 7 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 1 0 1
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
67 1 {PDL_Indx k = __privtrans->ind_sizes[2] - __privtrans->ind_sizes[1];
68 1 ▶ if (k < 1) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "K DOES NOT SATISFY K.GE.1");
Branch: 1 branch
BranchTrueFalseTotal
if (k < 1) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "K DOES NOT SATISFY K.GE.1"); 0 1 1
69 1 ▶ if (__privtrans->ind_sizes[1] < k) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "N DOES NOT SATISFY N.GE.K");
Branch: 1 branch
BranchTrueFalseTotal
if (__privtrans->ind_sizes[1] < k) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "N DOES NOT SATISFY N.GE.K"); 0 1 1
70 }
71 1 } break;
72 0 case PDL_LD: {
73 0 ▶ PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N)
Branch: 7 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_0(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
74 0 {PDL_Indx k = __privtrans->ind_sizes[2] - __privtrans->ind_sizes[1];
75 0 ▶ if (k < 1) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "K DOES NOT SATISFY K.GE.1");
Branch: 1 branch
BranchTrueFalseTotal
if (k < 1) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "K DOES NOT SATISFY K.GE.1"); 0 0 0
76 0 ▶ if (__privtrans->ind_sizes[1] < k) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "N DOES NOT SATISFY N.GE.K");
Branch: 1 branch
BranchTrueFalseTotal
if (__privtrans->ind_sizes[1] < k) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "N DOES NOT SATISFY N.GE.K"); 0 0 0
77 }
78 0 } break;
79 0 default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in pchip_bvalu: unhandled datatype(%d), only handles (FDE)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
80 }
81 #undef PDL_IF_BAD
82  
83 1 ▶ PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans));
Branch: 1 branch
BranchTrueFalseTotal
PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans)); 0 1 1
84 1 return PDL_err;
85 }
86  
87  
88 #line 1888 "lib/PDL/PP.pm"
89 pdl_error pdl_pchip_bvalu_readdata(pdl_trans *__privtrans) {
90 pdl_error PDL_err = {0, NULL, 0};
91 #line 92 "lib/PDL/Primitive-pp-pchip_bvalu.c"
92 1 register PDL_Indx __k3_size = __privtrans->ind_sizes[0];
93 1 ▶ if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "broadcast.incs NULL");
Branch: 1 branch
BranchTrueFalseTotal
if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "broadcast.incs NULL"); 0 1 1
94 /* broadcastloop declarations */
95 int __brcloopval;
96 register PDL_Indx __tind0,__tind1; /* counters along dim */
97 1 register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
98 /* dims here are how many steps along those dims */
99 1 register PDL_Indx __tinc0_t = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
100 1 register PDL_Indx __tinc0_a = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
101 1 register PDL_Indx __tinc0_ideriv = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
102 1 register PDL_Indx __tinc0_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,0);
103 1 register PDL_Indx __tinc0_ans = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,4,0);
104 1 register PDL_Indx __tinc0_inbv = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,5,0);
105 1 register PDL_Indx __tinc0_work = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,6,0);
106 1 register PDL_Indx __tinc1_t = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
107 1 register PDL_Indx __tinc1_a = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
108 1 register PDL_Indx __tinc1_ideriv = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
109 1 register PDL_Indx __tinc1_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,1);
110 1 register PDL_Indx __tinc1_ans = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,4,1);
111 1 register PDL_Indx __tinc1_inbv = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,5,1);
112 1 register PDL_Indx __tinc1_work = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,6,1);
113 #define PDL_BROADCASTLOOP_START_pchip_bvalu_readdata PDL_BROADCASTLOOP_START( \
114 readdata, \
115 __privtrans->broadcast, \
116 __privtrans->vtable, \
117 t_datap += __offsp[0]; \
118 a_datap += __offsp[1]; \
119 ideriv_datap += __offsp[2]; \
120 x_datap += __offsp[3]; \
121 ans_datap += __offsp[4]; \
122 inbv_datap += __offsp[5]; \
123 work_datap += __offsp[6]; \
124 , \
125 ( ,t_datap += __tinc1_t - __tinc0_t * __tdims0 \
126 ,a_datap += __tinc1_a - __tinc0_a * __tdims0 \
127 ,ideriv_datap += __tinc1_ideriv - __tinc0_ideriv * __tdims0 \
128 ,x_datap += __tinc1_x - __tinc0_x * __tdims0 \
129 ,ans_datap += __tinc1_ans - __tinc0_ans * __tdims0 \
130 ,inbv_datap += __tinc1_inbv - __tinc0_inbv * __tdims0 \
131 ,work_datap += __tinc1_work - __tinc0_work * __tdims0 \
132 ), \
133 ( ,t_datap += __tinc0_t \
134 ,a_datap += __tinc0_a \
135 ,ideriv_datap += __tinc0_ideriv \
136 ,x_datap += __tinc0_x \
137 ,ans_datap += __tinc0_ans \
138 ,inbv_datap += __tinc0_inbv \
139 ,work_datap += __tinc0_work \
140 ) \
141 )
142 #define PDL_BROADCASTLOOP_END_pchip_bvalu_readdata PDL_BROADCASTLOOP_END( \
143 __privtrans->broadcast, \
144 t_datap -= __tinc1_t * __tdims1 + __offsp[0]; \
145 a_datap -= __tinc1_a * __tdims1 + __offsp[1]; \
146 ideriv_datap -= __tinc1_ideriv * __tdims1 + __offsp[2]; \
147 x_datap -= __tinc1_x * __tdims1 + __offsp[3]; \
148 ans_datap -= __tinc1_ans * __tdims1 + __offsp[4]; \
149 inbv_datap -= __tinc1_inbv * __tdims1 + __offsp[5]; \
150 work_datap -= __tinc1_work * __tdims1 + __offsp[6]; \
151 )
152 1 register PDL_Indx __inc_a_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_a_n;
153 1 register PDL_Indx __inc_t_nplusk = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_t_nplusk;
154 1 register PDL_Indx __inc_work_k3 = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,6,0)]; (void)__inc_work_k3;
155 #ifndef PDL_DECLARE_PARAMS_pchip_bvalu_1
156 #define PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_ideriv,PDL_PPSYM_PARAM_ideriv,PDL_TYPE_PARAM_inbv,PDL_PPSYM_PARAM_inbv) \
157 PDL_DECLARE_PARAMETER(PDL_TYPE_OP, t, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
158 PDL_DECLARE_PARAMETER(PDL_TYPE_OP, a, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \
159 PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_ideriv, ideriv, (__privtrans->pdls[2]), 1, PDL_PPSYM_PARAM_ideriv) \
160 PDL_DECLARE_PARAMETER(PDL_TYPE_OP, x, (__privtrans->pdls[3]), 1, PDL_PPSYM_OP) \
161 PDL_DECLARE_PARAMETER(PDL_TYPE_OP, ans, (__privtrans->pdls[4]), 1, PDL_PPSYM_OP) \
162 PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_inbv, inbv, (__privtrans->pdls[5]), 1, PDL_PPSYM_PARAM_inbv) \
163 PDL_DECLARE_PARAMETER(PDL_TYPE_OP, work, (__privtrans->pdls[6]), 1, PDL_PPSYM_OP)
164 #endif
165 #define PDL_IF_BAD(t,f) f
166 1 switch (__privtrans->__datatype) { /* Start generic switch */
167 0 case PDL_F: {
168 0 ▶ PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N)
Branch: 21 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Float,F,PDL_Indx,N,PDL_Indx,N) 0 0 0
169 0 ▶ PDL_BROADCASTLOOP_START_pchip_bvalu_readdata {
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
170 #line 6104 "lib/PDL/Primitive.pd"
171 PDL_Indx k = __privtrans->ind_sizes[2] - __privtrans->ind_sizes[1];
172 if ((ideriv_datap)[0] < 0 || (ideriv_datap)[0] >= k)
173 return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "IDERIV DOES NOT SATISFY 0.LE.IDERIV.LT.K");
174 PDL_Indx i;
175 int mflag;
176 /* *** FIND *I* IN (K,N) SUCH THAT T(I) .LE. X .LT. T(I+1) */
177 /* (OR, .LE. T(I+1) IF T(I) .LT. T(I+1) = T(N+1)). */
178 do { /* inlined dintrv */
179 PDL_Indx ihi = (inbv_datap)[0] + 1, lxt = __privtrans->ind_sizes[1];
180 if (ihi >= lxt) {
181 if ((x_datap)[0] >= (t_datap)[0+(__inc_t_nplusk*(lxt))]) {
182 mflag = 1; i = lxt; break;
183 }
184 if (lxt <= 0) {
185 mflag = -1; i = 0; break;
186 }
187 ihi = (inbv_datap)[0] = lxt;
188 }
189 char skipflag = 0;
190 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(ihi))]) {
191 PDL_Indx inbv = (inbv_datap)[0];
192 if ((x_datap)[0] >= (t_datap)[0+(__inc_t_nplusk*(inbv))]) {
193 mflag = 0; i = (inbv_datap)[0]; break;
194 }
195 /* *** NOW X .LT. XT(IHI) . FIND LOWER BOUND */
196 PDL_Indx istep = 1;
197 while (1) {
198 ihi = (inbv_datap)[0];
199 (inbv_datap)[0] = ihi - istep;
200 if ((inbv_datap)[0] <= 0) {
201 break;
202 }
203 PDL_Indx inbv = (inbv_datap)[0];
204 if ((x_datap)[0] >= (t_datap)[0+(__inc_t_nplusk*(inbv))]) {
205 skipflag = 1;
206 break;
207 }
208 istep <<= 1;
209 }
210 if (!skipflag) {
211 (inbv_datap)[0] = 0;
212 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(0))]) {
213 mflag = -1; i = 0; break;
214 }
215 }
216 skipflag = 1;
217 /* *** NOW X .GE. XT(ILO) . FIND UPPER BOUND */
218 }
219 if (!skipflag) {
220 PDL_Indx istep = 1;
221 while (1) {
222 (inbv_datap)[0] = ihi;
223 ihi = (inbv_datap)[0] + istep;
224 if (ihi >= lxt) break;
225 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(ihi))]) {
226 skipflag = 1;
227 break;
228 }
229 istep <<= 1;
230 }
231 if (!skipflag) {
232 if ((x_datap)[0] >= (t_datap)[0+(__inc_t_nplusk*(lxt))]) {
233 mflag = 1; i = lxt; break;
234 }
235 ihi = lxt;
236 }
237 }
238 /* *** NOW XT(ILO) .LE. X .LT. XT(IHI) . NARROW THE INTERVAL */
239 while (1) {
240 PDL_Indx middle = ((inbv_datap)[0] + ihi) / 2;
241 if (middle == (inbv_datap)[0]) {
242 mflag = 0; i = (inbv_datap)[0]; break;
243 }
244 /* NOTE. IT IS ASSUMED THAT MIDDLE = ILO IN CASE IHI = ILO+1 */
245 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(middle))])
246 ihi = middle;
247 else
248 (inbv_datap)[0] = middle;
249 }
250 } while (0); /* end dintrv inlined */
251 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(k-1))]) {
252 return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "X IS N0T GREATER THAN OR EQUAL TO T(K)");
253 }
254 if (mflag != 0) {
255 if ((x_datap)[0] > (t_datap)[0+(__inc_t_nplusk*(i))]) {
256 return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "X IS NOT LESS THAN OR EQUAL TO T(N+1)");
257 }
258 while (1) {
259 if (i == k-1) {
260 return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "A LEFT LIMITING VALUE CANNOT BE OBTAINED AT T(K)");
261 }
262 --i;
263 if ((x_datap)[0] != (t_datap)[0+(__inc_t_nplusk*(i))]) {
264 break;
265 }
266 }
267 /* *** DIFFERENCE THE COEFFICIENTS *IDERIV* TIMES */
268 /* WORK(I) = AJ(I), WORK(K+I) = DP(I), WORK(K+K+I) = DM(I), I=1.K */
269 }
270 PDL_Indx imk = i+1 - k, j;
271 {/* Open k3=:k */ PDL_EXPAND2(register PDL_Indx k3=0, __k3_stop=PDLMIN(k, (__k3_size))); for(; k3<__k3_stop; k3+=1) {
272 #line 6205 "lib/PDL/Primitive.pd"
273 (work_datap)[0+(__inc_work_k3*(k3))] = (a_datap)[0+(__inc_a_n*(imk+k3))];
274 }} /* Close k3=:k */
275 #line 6207 "lib/PDL/Primitive.pd"
276 if ((ideriv_datap)[0] != 0) {
277 for (j = 0; j < (ideriv_datap)[0]; ++j) {
278 PDL_Indx kmj = k - j - 1;
279 PDL_Float fkmj = kmj;
280 {/* Open k3=0:kmj */ PDL_EXPAND2(register PDL_Indx k3=0, __k3_stop=PDLMIN(kmj, (__k3_size))); for(; k3<__k3_stop; k3+=1) {
281 #line 6212 "lib/PDL/Primitive.pd"
282 PDL_Indx ihi = i+1 + k3;
283 (work_datap)[0+(__inc_work_k3*(k3))] = ((work_datap)[0+(__inc_work_k3*(k3+1))] - (work_datap)[0+(__inc_work_k3*(k3))]) / ((t_datap)[0+(__inc_t_nplusk*(ihi))] - (t_datap)[0+(__inc_t_nplusk*(ihi-kmj))]) * fkmj;
284 }} /* Close k3=0:kmj */
285 #line 6215 "lib/PDL/Primitive.pd"
286 }
287 /* *** COMPUTE VALUE AT *X* IN (T(I),T(I+1)) OF IDERIV-TH DERIVATIVE, */
288 /* GIVEN ITS RELEVANT B-SPLINE COEFF. IN AJ(1),...,AJ(K-IDERIV). */
289 }
290 PDL_Indx km1 = k - 1;
291 if ((ideriv_datap)[0] != km1) {
292 PDL_Indx j, j1 = k, kpk = k + k, j2 = kpk, kmider = k - (ideriv_datap)[0];
293 for (j = 0; j < kmider; ++j) {
294 PDL_Indx ipj = i + j + 1;
295 (work_datap)[0+(__inc_work_k3*(j1))] = (t_datap)[0+(__inc_t_nplusk*(ipj))] - (x_datap)[0];
296 (work_datap)[0+(__inc_work_k3*(j2))] = (x_datap)[0] - (t_datap)[0+(__inc_t_nplusk*(i-j))];
297 ++j1;
298 ++j2;
299 }
300 for (j = (ideriv_datap)[0]; j < km1; ++j) {
301 PDL_Indx kmj = k - j - 1, ilo = kpk + kmj - 1;
302 {/* Open k3=0:kmj */ PDL_EXPAND2(register PDL_Indx k3=0, __k3_stop=PDLMIN(kmj, (__k3_size))); for(; k3<__k3_stop; k3+=1) {
303 #line 6232 "lib/PDL/Primitive.pd"
304 (work_datap)[0+(__inc_work_k3*(k3))] = ((work_datap)[0+(__inc_work_k3*(k3+1))] * (work_datap)[0+(__inc_work_k3*(ilo))] + (work_datap)[0+(__inc_work_k3*(k3))] *
305 (work_datap)[0+(__inc_work_k3*(k+k3))]) / ((work_datap)[0+(__inc_work_k3*(ilo))] + (work_datap)[0+(__inc_work_k3*(k+k3))]);
306 --ilo;
307 }} /* Close k3=0:kmj */
308 #line 6236 "lib/PDL/Primitive.pd"
309 }
310 }
311 (ans_datap)[0] = (work_datap)[0+(__inc_work_k3*(0))];
312 #line 313 "lib/PDL/Primitive-pp-pchip_bvalu.c"
313 0 ▶ }PDL_BROADCASTLOOP_END_pchip_bvalu_readdata
Branch: 2 branches
BranchTrueFalseTotal
}PDL_BROADCASTLOOP_END_pchip_bvalu_readdata 0 0 0
}PDL_BROADCASTLOOP_END_pchip_bvalu_readdata 0 0 0
314 0 } break;
315 1 case PDL_D: {
316 1 ▶ PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N)
Branch: 21 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 1 0 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 1 0 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 1 0 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 1 0 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 1 0 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 1 0 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 1 0 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 1 0 1
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_Double,D,PDL_Indx,N,PDL_Indx,N) 0 1 1
317 29 ▶ PDL_BROADCASTLOOP_START_pchip_bvalu_readdata {
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 1 1
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 1 1
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 1 1
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 1 1
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 1 1
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 18 9 27
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 9 1 10
318 #line 6104 "lib/PDL/Primitive.pd"
319 PDL_Indx k = __privtrans->ind_sizes[2] - __privtrans->ind_sizes[1];
320 if ((ideriv_datap)[0] < 0 || (ideriv_datap)[0] >= k)
321 return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "IDERIV DOES NOT SATISFY 0.LE.IDERIV.LT.K");
322 PDL_Indx i;
323 int mflag;
324 /* *** FIND *I* IN (K,N) SUCH THAT T(I) .LE. X .LT. T(I+1) */
325 /* (OR, .LE. T(I+1) IF T(I) .LT. T(I+1) = T(N+1)). */
326 do { /* inlined dintrv */
327 PDL_Indx ihi = (inbv_datap)[0] + 1, lxt = __privtrans->ind_sizes[1];
328 if (ihi >= lxt) {
329 if ((x_datap)[0] >= (t_datap)[0+(__inc_t_nplusk*(lxt))]) {
330 mflag = 1; i = lxt; break;
331 }
332 if (lxt <= 0) {
333 mflag = -1; i = 0; break;
334 }
335 ihi = (inbv_datap)[0] = lxt;
336 }
337 char skipflag = 0;
338 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(ihi))]) {
339 PDL_Indx inbv = (inbv_datap)[0];
340 if ((x_datap)[0] >= (t_datap)[0+(__inc_t_nplusk*(inbv))]) {
341 mflag = 0; i = (inbv_datap)[0]; break;
342 }
343 /* *** NOW X .LT. XT(IHI) . FIND LOWER BOUND */
344 PDL_Indx istep = 1;
345 while (1) {
346 ihi = (inbv_datap)[0];
347 (inbv_datap)[0] = ihi - istep;
348 if ((inbv_datap)[0] <= 0) {
349 break;
350 }
351 PDL_Indx inbv = (inbv_datap)[0];
352 if ((x_datap)[0] >= (t_datap)[0+(__inc_t_nplusk*(inbv))]) {
353 skipflag = 1;
354 break;
355 }
356 istep <<= 1;
357 }
358 if (!skipflag) {
359 (inbv_datap)[0] = 0;
360 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(0))]) {
361 mflag = -1; i = 0; break;
362 }
363 }
364 skipflag = 1;
365 /* *** NOW X .GE. XT(ILO) . FIND UPPER BOUND */
366 }
367 if (!skipflag) {
368 PDL_Indx istep = 1;
369 while (1) {
370 (inbv_datap)[0] = ihi;
371 ihi = (inbv_datap)[0] + istep;
372 if (ihi >= lxt) break;
373 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(ihi))]) {
374 skipflag = 1;
375 break;
376 }
377 istep <<= 1;
378 }
379 if (!skipflag) {
380 if ((x_datap)[0] >= (t_datap)[0+(__inc_t_nplusk*(lxt))]) {
381 mflag = 1; i = lxt; break;
382 }
383 ihi = lxt;
384 }
385 }
386 /* *** NOW XT(ILO) .LE. X .LT. XT(IHI) . NARROW THE INTERVAL */
387 while (1) {
388 PDL_Indx middle = ((inbv_datap)[0] + ihi) / 2;
389 if (middle == (inbv_datap)[0]) {
390 mflag = 0; i = (inbv_datap)[0]; break;
391 }
392 /* NOTE. IT IS ASSUMED THAT MIDDLE = ILO IN CASE IHI = ILO+1 */
393 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(middle))])
394 ihi = middle;
395 else
396 (inbv_datap)[0] = middle;
397 }
398 } while (0); /* end dintrv inlined */
399 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(k-1))]) {
400 return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "X IS N0T GREATER THAN OR EQUAL TO T(K)");
401 }
402 if (mflag != 0) {
403 if ((x_datap)[0] > (t_datap)[0+(__inc_t_nplusk*(i))]) {
404 return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "X IS NOT LESS THAN OR EQUAL TO T(N+1)");
405 }
406 while (1) {
407 if (i == k-1) {
408 return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "A LEFT LIMITING VALUE CANNOT BE OBTAINED AT T(K)");
409 }
410 --i;
411 if ((x_datap)[0] != (t_datap)[0+(__inc_t_nplusk*(i))]) {
412 break;
413 }
414 }
415 /* *** DIFFERENCE THE COEFFICIENTS *IDERIV* TIMES */
416 /* WORK(I) = AJ(I), WORK(K+I) = DP(I), WORK(K+K+I) = DM(I), I=1.K */
417 }
418 PDL_Indx imk = i+1 - k, j;
419 {/* Open k3=:k */ PDL_EXPAND2(register PDL_Indx k3=0, __k3_stop=PDLMIN(k, (__k3_size))); for(; k3<__k3_stop; k3+=1) {
420 #line 6205 "lib/PDL/Primitive.pd"
421 (work_datap)[0+(__inc_work_k3*(k3))] = (a_datap)[0+(__inc_a_n*(imk+k3))];
422 }} /* Close k3=:k */
423 #line 6207 "lib/PDL/Primitive.pd"
424 if ((ideriv_datap)[0] != 0) {
425 for (j = 0; j < (ideriv_datap)[0]; ++j) {
426 PDL_Indx kmj = k - j - 1;
427 PDL_Double fkmj = kmj;
428 {/* Open k3=0:kmj */ PDL_EXPAND2(register PDL_Indx k3=0, __k3_stop=PDLMIN(kmj, (__k3_size))); for(; k3<__k3_stop; k3+=1) {
429 #line 6212 "lib/PDL/Primitive.pd"
430 PDL_Indx ihi = i+1 + k3;
431 (work_datap)[0+(__inc_work_k3*(k3))] = ((work_datap)[0+(__inc_work_k3*(k3+1))] - (work_datap)[0+(__inc_work_k3*(k3))]) / ((t_datap)[0+(__inc_t_nplusk*(ihi))] - (t_datap)[0+(__inc_t_nplusk*(ihi-kmj))]) * fkmj;
432 }} /* Close k3=0:kmj */
433 #line 6215 "lib/PDL/Primitive.pd"
434 }
435 /* *** COMPUTE VALUE AT *X* IN (T(I),T(I+1)) OF IDERIV-TH DERIVATIVE, */
436 /* GIVEN ITS RELEVANT B-SPLINE COEFF. IN AJ(1),...,AJ(K-IDERIV). */
437 }
438 PDL_Indx km1 = k - 1;
439 if ((ideriv_datap)[0] != km1) {
440 PDL_Indx j, j1 = k, kpk = k + k, j2 = kpk, kmider = k - (ideriv_datap)[0];
441 for (j = 0; j < kmider; ++j) {
442 PDL_Indx ipj = i + j + 1;
443 (work_datap)[0+(__inc_work_k3*(j1))] = (t_datap)[0+(__inc_t_nplusk*(ipj))] - (x_datap)[0];
444 (work_datap)[0+(__inc_work_k3*(j2))] = (x_datap)[0] - (t_datap)[0+(__inc_t_nplusk*(i-j))];
445 ++j1;
446 ++j2;
447 }
448 for (j = (ideriv_datap)[0]; j < km1; ++j) {
449 PDL_Indx kmj = k - j - 1, ilo = kpk + kmj - 1;
450 {/* Open k3=0:kmj */ PDL_EXPAND2(register PDL_Indx k3=0, __k3_stop=PDLMIN(kmj, (__k3_size))); for(; k3<__k3_stop; k3+=1) {
451 #line 6232 "lib/PDL/Primitive.pd"
452 (work_datap)[0+(__inc_work_k3*(k3))] = ((work_datap)[0+(__inc_work_k3*(k3+1))] * (work_datap)[0+(__inc_work_k3*(ilo))] + (work_datap)[0+(__inc_work_k3*(k3))] *
453 (work_datap)[0+(__inc_work_k3*(k+k3))]) / ((work_datap)[0+(__inc_work_k3*(ilo))] + (work_datap)[0+(__inc_work_k3*(k+k3))]);
454 --ilo;
455 }} /* Close k3=0:kmj */
456 #line 6236 "lib/PDL/Primitive.pd"
457 }
458 }
459 (ans_datap)[0] = (work_datap)[0+(__inc_work_k3*(0))];
460 #line 461 "lib/PDL/Primitive-pp-pchip_bvalu.c"
461 1 ▶ }PDL_BROADCASTLOOP_END_pchip_bvalu_readdata
Branch: 2 branches
BranchTrueFalseTotal
}PDL_BROADCASTLOOP_END_pchip_bvalu_readdata 0 1 1
}PDL_BROADCASTLOOP_END_pchip_bvalu_readdata 0 1 1
462 1 } break;
463 0 case PDL_LD: {
464 0 ▶ PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N)
Branch: 21 branches
BranchTrueFalseTotal
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
PDL_DECLARE_PARAMS_pchip_bvalu_1(PDL_LDouble,E,PDL_Indx,N,PDL_Indx,N) 0 0 0
465 0 ▶ PDL_BROADCASTLOOP_START_pchip_bvalu_readdata {
Branch: 7 branches
BranchTrueFalseTotal
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
PDL_BROADCASTLOOP_START_pchip_bvalu_readdata { 0 0 0
466 #line 6104 "lib/PDL/Primitive.pd"
467 PDL_Indx k = __privtrans->ind_sizes[2] - __privtrans->ind_sizes[1];
468 if ((ideriv_datap)[0] < 0 || (ideriv_datap)[0] >= k)
469 return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "IDERIV DOES NOT SATISFY 0.LE.IDERIV.LT.K");
470 PDL_Indx i;
471 int mflag;
472 /* *** FIND *I* IN (K,N) SUCH THAT T(I) .LE. X .LT. T(I+1) */
473 /* (OR, .LE. T(I+1) IF T(I) .LT. T(I+1) = T(N+1)). */
474 do { /* inlined dintrv */
475 PDL_Indx ihi = (inbv_datap)[0] + 1, lxt = __privtrans->ind_sizes[1];
476 if (ihi >= lxt) {
477 if ((x_datap)[0] >= (t_datap)[0+(__inc_t_nplusk*(lxt))]) {
478 mflag = 1; i = lxt; break;
479 }
480 if (lxt <= 0) {
481 mflag = -1; i = 0; break;
482 }
483 ihi = (inbv_datap)[0] = lxt;
484 }
485 char skipflag = 0;
486 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(ihi))]) {
487 PDL_Indx inbv = (inbv_datap)[0];
488 if ((x_datap)[0] >= (t_datap)[0+(__inc_t_nplusk*(inbv))]) {
489 mflag = 0; i = (inbv_datap)[0]; break;
490 }
491 /* *** NOW X .LT. XT(IHI) . FIND LOWER BOUND */
492 PDL_Indx istep = 1;
493 while (1) {
494 ihi = (inbv_datap)[0];
495 (inbv_datap)[0] = ihi - istep;
496 if ((inbv_datap)[0] <= 0) {
497 break;
498 }
499 PDL_Indx inbv = (inbv_datap)[0];
500 if ((x_datap)[0] >= (t_datap)[0+(__inc_t_nplusk*(inbv))]) {
501 skipflag = 1;
502 break;
503 }
504 istep <<= 1;
505 }
506 if (!skipflag) {
507 (inbv_datap)[0] = 0;
508 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(0))]) {
509 mflag = -1; i = 0; break;
510 }
511 }
512 skipflag = 1;
513 /* *** NOW X .GE. XT(ILO) . FIND UPPER BOUND */
514 }
515 if (!skipflag) {
516 PDL_Indx istep = 1;
517 while (1) {
518 (inbv_datap)[0] = ihi;
519 ihi = (inbv_datap)[0] + istep;
520 if (ihi >= lxt) break;
521 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(ihi))]) {
522 skipflag = 1;
523 break;
524 }
525 istep <<= 1;
526 }
527 if (!skipflag) {
528 if ((x_datap)[0] >= (t_datap)[0+(__inc_t_nplusk*(lxt))]) {
529 mflag = 1; i = lxt; break;
530 }
531 ihi = lxt;
532 }
533 }
534 /* *** NOW XT(ILO) .LE. X .LT. XT(IHI) . NARROW THE INTERVAL */
535 while (1) {
536 PDL_Indx middle = ((inbv_datap)[0] + ihi) / 2;
537 if (middle == (inbv_datap)[0]) {
538 mflag = 0; i = (inbv_datap)[0]; break;
539 }
540 /* NOTE. IT IS ASSUMED THAT MIDDLE = ILO IN CASE IHI = ILO+1 */
541 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(middle))])
542 ihi = middle;
543 else
544 (inbv_datap)[0] = middle;
545 }
546 } while (0); /* end dintrv inlined */
547 if ((x_datap)[0] < (t_datap)[0+(__inc_t_nplusk*(k-1))]) {
548 return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "X IS N0T GREATER THAN OR EQUAL TO T(K)");
549 }
550 if (mflag != 0) {
551 if ((x_datap)[0] > (t_datap)[0+(__inc_t_nplusk*(i))]) {
552 return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "X IS NOT LESS THAN OR EQUAL TO T(N+1)");
553 }
554 while (1) {
555 if (i == k-1) {
556 return PDL->make_error(PDL_EUSERERROR, "Error in pchip_bvalu:" "A LEFT LIMITING VALUE CANNOT BE OBTAINED AT T(K)");
557 }
558 --i;
559 if ((x_datap)[0] != (t_datap)[0+(__inc_t_nplusk*(i))]) {
560 break;
561 }
562 }
563 /* *** DIFFERENCE THE COEFFICIENTS *IDERIV* TIMES */
564 /* WORK(I) = AJ(I), WORK(K+I) = DP(I), WORK(K+K+I) = DM(I), I=1.K */
565 }
566 PDL_Indx imk = i+1 - k, j;
567 {/* Open k3=:k */ PDL_EXPAND2(register PDL_Indx k3=0, __k3_stop=PDLMIN(k, (__k3_size))); for(; k3<__k3_stop; k3+=1) {
568 #line 6205 "lib/PDL/Primitive.pd"
569 (work_datap)[0+(__inc_work_k3*(k3))] = (a_datap)[0+(__inc_a_n*(imk+k3))];
570 }} /* Close k3=:k */
571 #line 6207 "lib/PDL/Primitive.pd"
572 if ((ideriv_datap)[0] != 0) {
573 for (j = 0; j < (ideriv_datap)[0]; ++j) {
574 PDL_Indx kmj = k - j - 1;
575 PDL_LDouble fkmj = kmj;
576 {/* Open k3=0:kmj */ PDL_EXPAND2(register PDL_Indx k3=0, __k3_stop=PDLMIN(kmj, (__k3_size))); for(; k3<__k3_stop; k3+=1) {
577 #line 6212 "lib/PDL/Primitive.pd"
578 PDL_Indx ihi = i+1 + k3;
579 (work_datap)[0+(__inc_work_k3*(k3))] = ((work_datap)[0+(__inc_work_k3*(k3+1))] - (work_datap)[0+(__inc_work_k3*(k3))]) / ((t_datap)[0+(__inc_t_nplusk*(ihi))] - (t_datap)[0+(__inc_t_nplusk*(ihi-kmj))]) * fkmj;
580 }} /* Close k3=0:kmj */
581 #line 6215 "lib/PDL/Primitive.pd"
582 }
583 /* *** COMPUTE VALUE AT *X* IN (T(I),T(I+1)) OF IDERIV-TH DERIVATIVE, */
584 /* GIVEN ITS RELEVANT B-SPLINE COEFF. IN AJ(1),...,AJ(K-IDERIV). */
585 }
586 PDL_Indx km1 = k - 1;
587 if ((ideriv_datap)[0] != km1) {
588 PDL_Indx j, j1 = k, kpk = k + k, j2 = kpk, kmider = k - (ideriv_datap)[0];
589 for (j = 0; j < kmider; ++j) {
590 PDL_Indx ipj = i + j + 1;
591 (work_datap)[0+(__inc_work_k3*(j1))] = (t_datap)[0+(__inc_t_nplusk*(ipj))] - (x_datap)[0];
592 (work_datap)[0+(__inc_work_k3*(j2))] = (x_datap)[0] - (t_datap)[0+(__inc_t_nplusk*(i-j))];
593 ++j1;
594 ++j2;
595 }
596 for (j = (ideriv_datap)[0]; j < km1; ++j) {
597 PDL_Indx kmj = k - j - 1, ilo = kpk + kmj - 1;
598 {/* Open k3=0:kmj */ PDL_EXPAND2(register PDL_Indx k3=0, __k3_stop=PDLMIN(kmj, (__k3_size))); for(; k3<__k3_stop; k3+=1) {
599 #line 6232 "lib/PDL/Primitive.pd"
600 (work_datap)[0+(__inc_work_k3*(k3))] = ((work_datap)[0+(__inc_work_k3*(k3+1))] * (work_datap)[0+(__inc_work_k3*(ilo))] + (work_datap)[0+(__inc_work_k3*(k3))] *
601 (work_datap)[0+(__inc_work_k3*(k+k3))]) / ((work_datap)[0+(__inc_work_k3*(ilo))] + (work_datap)[0+(__inc_work_k3*(k+k3))]);
602 --ilo;
603 }} /* Close k3=0:kmj */
604 #line 6236 "lib/PDL/Primitive.pd"
605 }
606 }
607 (ans_datap)[0] = (work_datap)[0+(__inc_work_k3*(0))];
608 #line 609 "lib/PDL/Primitive-pp-pchip_bvalu.c"
609 0 ▶ }PDL_BROADCASTLOOP_END_pchip_bvalu_readdata
Branch: 2 branches
BranchTrueFalseTotal
}PDL_BROADCASTLOOP_END_pchip_bvalu_readdata 0 0 0
}PDL_BROADCASTLOOP_END_pchip_bvalu_readdata 0 0 0
610 0 } break;
611 0 default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in pchip_bvalu: unhandled datatype(%d), only handles (FDE)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
612 }
613 #undef PDL_IF_BAD
614 1 return PDL_err;
615 }
616  
617 static pdl_datatypes pdl_pchip_bvalu_vtable_gentypes[] = { PDL_F, PDL_D, PDL_LD, -1 };
618 static PDL_Indx pdl_pchip_bvalu_vtable_realdims[] = { 1, 1, 0, 0, 0, 0, 1 };
619 static char *pdl_pchip_bvalu_vtable_parnames[] = { "t","a","ideriv","x","ans","inbv","work" };
620 static short pdl_pchip_bvalu_vtable_parflags[] = {
621 0,
622 0,
623 PDL_PARAM_ISTYPED,
624 0,
625 PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE,
626 PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISTYPED|PDL_PARAM_ISWRITE,
627 PDL_PARAM_ISCREAT|PDL_PARAM_ISTEMP|PDL_PARAM_ISWRITE
628 };
629 static pdl_datatypes pdl_pchip_bvalu_vtable_partypes[] = { -1, -1, PDL_IND, -1, -1, PDL_IND, -1 };
630 static PDL_Indx pdl_pchip_bvalu_vtable_realdims_starts[] = { 0, 1, 2, 2, 2, 2, 2 };
631 static PDL_Indx pdl_pchip_bvalu_vtable_realdims_ind_ids[] = { 2, 1, 0 };
632 static char *pdl_pchip_bvalu_vtable_indnames[] = { "k3","n","nplusk" };
633 pdl_transvtable pdl_pchip_bvalu_vtable = {
634 PDL_TRANS_DO_BROADCAST, 0, pdl_pchip_bvalu_vtable_gentypes, 4, 7, NULL /*CORE21*/,
635 pdl_pchip_bvalu_vtable_realdims, pdl_pchip_bvalu_vtable_parnames,
636 pdl_pchip_bvalu_vtable_parflags, pdl_pchip_bvalu_vtable_partypes,
637 pdl_pchip_bvalu_vtable_realdims_starts, pdl_pchip_bvalu_vtable_realdims_ind_ids, 3,
638 3, pdl_pchip_bvalu_vtable_indnames,
639 pdl_pchip_bvalu_redodims, pdl_pchip_bvalu_readdata, NULL,
640 NULL,
641 0,"PDL::Primitive::pchip_bvalu"
642 };
643  
644  
645 1 pdl_error pdl_run_pchip_bvalu(pdl *t,pdl *a,pdl *ideriv,pdl *x,pdl *ans,pdl *inbv) {
646 1 pdl_error PDL_err = {0, NULL, 0};
647 1 ▶ 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 1 1
648 1 pdl_trans *__privtrans = PDL->create_trans(&pdl_pchip_bvalu_vtable);
649 1 ▶ 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 1 1
650 1 __privtrans->pdls[0] = t;
651 1 __privtrans->pdls[1] = a;
652 1 __privtrans->pdls[2] = ideriv;
653 1 __privtrans->pdls[3] = x;
654 1 __privtrans->pdls[4] = ans;
655 1 __privtrans->pdls[5] = inbv;
656 1 ▶ PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
Branch: 1 branch
BranchTrueFalseTotal
PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); 0 1 1
657 1 ▶ PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
Branch: 1 branch
BranchTrueFalseTotal
PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); 0 1 1
658 1 return PDL_err;
659 }
« lib/PDL/Primitive-pp-pchip_chia.c ↑ Summary lib/PDL/Primitive-pp-append.c »