| 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-vsearch_bin_exclusive.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_vsearch_bin_exclusive_readdata(pdl_trans *__privtrans) { |
| 43 |
|
| pdl_error PDL_err = {0, NULL, 0}; |
| 44 |
|
| #line 45 "lib/PDL/Primitive-pp-vsearch_bin_exclusive.c" |
| 45 |
28 |
| register PDL_Indx __n_size = __privtrans->ind_sizes[0]; |
| 46 |
28 |
▶ | if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in vsearch_bin_exclusive:" "broadcast.incs NULL"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in vsearch_bin_exclusive:" "broadcast.incs NULL"); |
0 |
28 |
28 |
|
| 47 |
|
| /* broadcastloop declarations */ |
| 48 |
|
| int __brcloopval; |
| 49 |
|
| register PDL_Indx __tind0,__tind1; /* counters along dim */ |
| 50 |
28 |
| register PDL_Indx __tnpdls = __privtrans->broadcast.npdls; |
| 51 |
|
| /* dims here are how many steps along those dims */ |
| 52 |
28 |
| register PDL_Indx __tinc0_vals = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0); |
| 53 |
28 |
| register PDL_Indx __tinc0_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0); |
| 54 |
28 |
| register PDL_Indx __tinc0_idx = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0); |
| 55 |
28 |
| register PDL_Indx __tinc1_vals = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1); |
| 56 |
28 |
| register PDL_Indx __tinc1_x = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1); |
| 57 |
28 |
| register PDL_Indx __tinc1_idx = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1); |
| 58 |
|
| #define PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata PDL_BROADCASTLOOP_START( \ |
| 59 |
|
| readdata, \ |
| 60 |
|
| __privtrans->broadcast, \ |
| 61 |
|
| __privtrans->vtable, \ |
| 62 |
|
| vals_datap += __offsp[0]; \ |
| 63 |
|
| x_datap += __offsp[1]; \ |
| 64 |
|
| idx_datap += __offsp[2]; \ |
| 65 |
|
| , \ |
| 66 |
|
| ( ,vals_datap += __tinc1_vals - __tinc0_vals * __tdims0 \ |
| 67 |
|
| ,x_datap += __tinc1_x - __tinc0_x * __tdims0 \ |
| 68 |
|
| ,idx_datap += __tinc1_idx - __tinc0_idx * __tdims0 \ |
| 69 |
|
| ), \ |
| 70 |
|
| ( ,vals_datap += __tinc0_vals \ |
| 71 |
|
| ,x_datap += __tinc0_x \ |
| 72 |
|
| ,idx_datap += __tinc0_idx \ |
| 73 |
|
| ) \ |
| 74 |
|
| ) |
| 75 |
|
| #define PDL_BROADCASTLOOP_END_vsearch_bin_exclusive_readdata PDL_BROADCASTLOOP_END( \ |
| 76 |
|
| __privtrans->broadcast, \ |
| 77 |
|
| vals_datap -= __tinc1_vals * __tdims1 + __offsp[0]; \ |
| 78 |
|
| x_datap -= __tinc1_x * __tdims1 + __offsp[1]; \ |
| 79 |
|
| idx_datap -= __tinc1_idx * __tdims1 + __offsp[2]; \ |
| 80 |
|
| ) |
| 81 |
28 |
| register PDL_Indx __inc_x_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_x_n; |
| 82 |
|
| #ifndef PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1 |
| 83 |
|
| #define PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_idx,PDL_PPSYM_PARAM_idx) \ |
| 84 |
|
| PDL_DECLARE_PARAMETER_BADVAL(PDL_TYPE_OP, vals, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \ |
| 85 |
|
| PDL_DECLARE_PARAMETER_BADVAL(PDL_TYPE_OP, x, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \ |
| 86 |
|
| PDL_DECLARE_PARAMETER_BADVAL(PDL_TYPE_PARAM_idx, idx, (__privtrans->pdls[2]), 1, PDL_PPSYM_PARAM_idx) |
| 87 |
|
| #endif |
| 88 |
|
| #define PDL_IF_BAD(t,f) f |
| 89 |
28 |
| switch (__privtrans->__datatype) { /* Start generic switch */ |
| 90 |
0 |
| case PDL_F: { |
| 91 |
0 |
▶ | PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Float,F,PDL_Indx,N) |
Branch: 12 branches
| Branch | True | False | Total |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Float,F,PDL_Indx,N) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Float,F,PDL_Indx,N) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Float,F,PDL_Indx,N) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Float,F,PDL_Indx,N) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Float,F,PDL_Indx,N) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Float,F,PDL_Indx,N) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Float,F,PDL_Indx,N) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Float,F,PDL_Indx,N) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Float,F,PDL_Indx,N) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Float,F,PDL_Indx,N) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Float,F,PDL_Indx,N) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Float,F,PDL_Indx,N) |
0 |
0 |
0 |
|
| 92 |
0 |
▶ | PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
Branch: 7 branches
| Branch | True | False | Total |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
0 |
0 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
0 |
0 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
0 |
0 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
0 |
0 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
0 |
0 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
0 |
0 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
0 |
0 |
|
| 93 |
0 |
▶ | {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
Branch: 1 branch
| Branch | True | False | Total |
| {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
0 |
0 |
0 |
|
| 94 |
0 |
▶ | if ( !PDL_ISBAD2((vals_datap)[0],vals_badval,F,vals_badval_isnan) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( !PDL_ISBAD2((vals_datap)[0],vals_badval,F,vals_badval_isnan) ) { |
0 |
0 |
0 |
| if ( !PDL_ISBAD2((vals_datap)[0],vals_badval,F,vals_badval_isnan) ) { |
0 |
0 |
0 |
|
| 95 |
0 |
| PDL_Indx n1 = __privtrans->ind_sizes[0]-1; |
| 96 |
0 |
| PDL_Indx low = 0; |
| 97 |
0 |
| PDL_Indx high = n1; |
| 98 |
|
| PDL_Indx mid; |
| 99 |
|
| |
| 100 |
0 |
| PDL_Float value = (vals_datap)[0]; |
| 101 |
|
| |
| 102 |
|
| /* determine sort order of data */ |
| 103 |
0 |
| int up = (x_datap)[0+(__inc_x_n*(n1))] >= (x_datap)[0+(__inc_x_n*(0))]; |
| 104 |
|
| |
| 105 |
0 |
▶ | while (low <= high ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (low <= high ) { |
0 |
0 |
0 |
|
| 106 |
0 |
| mid = low + (( high - low )>> 1);; |
| 107 |
0 |
▶ | if ( ( (x_datap)[0+(__inc_x_n*(mid))] < value ) == up ) low = mid + 1; |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ( (x_datap)[0+(__inc_x_n*(mid))] < value ) == up ) low = mid + 1; |
0 |
0 |
0 |
|
| 108 |
0 |
| else high = mid - 1; |
| 109 |
|
| } |
| 110 |
0 |
▶ | (idx_datap)[0] = up ? high: low; |
Branch: 1 branch
| Branch | True | False | Total |
| (idx_datap)[0] = up ? high: low; |
0 |
0 |
0 |
|
| 111 |
|
| |
| 112 |
|
| } |
| 113 |
|
| |
| 114 |
|
| else { |
| 115 |
0 |
| (idx_datap)[0]=idx_badval; |
| 116 |
|
| } |
| 117 |
|
| }} /* Close n */ |
| 118 |
|
| |
| 119 |
0 |
▶ | }PDL_BROADCASTLOOP_END_vsearch_bin_exclusive_readdata |
Branch: 2 branches
| Branch | True | False | Total |
| }PDL_BROADCASTLOOP_END_vsearch_bin_exclusive_readdata |
0 |
0 |
0 |
| }PDL_BROADCASTLOOP_END_vsearch_bin_exclusive_readdata |
0 |
0 |
0 |
|
| 120 |
0 |
| } break; |
| 121 |
5 |
| case PDL_D: { |
| 122 |
5 |
▶ | PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Double,D,PDL_Indx,N) |
Branch: 12 branches
| Branch | True | False | Total |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Double,D,PDL_Indx,N) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Double,D,PDL_Indx,N) |
5 |
0 |
5 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Double,D,PDL_Indx,N) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Double,D,PDL_Indx,N) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Double,D,PDL_Indx,N) |
2 |
3 |
5 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Double,D,PDL_Indx,N) |
5 |
0 |
5 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Double,D,PDL_Indx,N) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Double,D,PDL_Indx,N) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Double,D,PDL_Indx,N) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Double,D,PDL_Indx,N) |
5 |
0 |
5 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Double,D,PDL_Indx,N) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_Double,D,PDL_Indx,N) |
0 |
5 |
5 |
|
| 123 |
1138 |
▶ | PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
Branch: 7 branches
| Branch | True | False | Total |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
5 |
5 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
5 |
5 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
5 |
5 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
5 |
5 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
5 |
5 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
1123 |
5 |
1128 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
5 |
5 |
10 |
|
| 124 |
803852 |
▶ | {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
Branch: 1 branch
| Branch | True | False | Total |
| {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
802729 |
1123 |
803852 |
|
| 125 |
802729 |
▶ | if ( !PDL_ISBAD2((vals_datap)[0],vals_badval,D,vals_badval_isnan) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( !PDL_ISBAD2((vals_datap)[0],vals_badval,D,vals_badval_isnan) ) { |
0 |
802729 |
802729 |
| if ( !PDL_ISBAD2((vals_datap)[0],vals_badval,D,vals_badval_isnan) ) { |
802729 |
0 |
802729 |
|
| 126 |
802729 |
| PDL_Indx n1 = __privtrans->ind_sizes[0]-1; |
| 127 |
802729 |
| PDL_Indx low = 0; |
| 128 |
802729 |
| PDL_Indx high = n1; |
| 129 |
|
| PDL_Indx mid; |
| 130 |
|
| |
| 131 |
802729 |
| PDL_Double value = (vals_datap)[0]; |
| 132 |
|
| |
| 133 |
|
| /* determine sort order of data */ |
| 134 |
802729 |
| int up = (x_datap)[0+(__inc_x_n*(n1))] >= (x_datap)[0+(__inc_x_n*(0))]; |
| 135 |
|
| |
| 136 |
8177090 |
▶ | while (low <= high ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (low <= high ) { |
7374361 |
802729 |
8177090 |
|
| 137 |
7374361 |
| mid = low + (( high - low )>> 1);; |
| 138 |
7374361 |
▶ | if ( ( (x_datap)[0+(__inc_x_n*(mid))] < value ) == up ) low = mid + 1; |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ( (x_datap)[0+(__inc_x_n*(mid))] < value ) == up ) low = mid + 1; |
1388800 |
5985561 |
7374361 |
|
| 139 |
5985561 |
| else high = mid - 1; |
| 140 |
|
| } |
| 141 |
802729 |
▶ | (idx_datap)[0] = up ? high: low; |
Branch: 1 branch
| Branch | True | False | Total |
| (idx_datap)[0] = up ? high: low; |
662729 |
140000 |
802729 |
|
| 142 |
|
| |
| 143 |
|
| } |
| 144 |
|
| |
| 145 |
|
| else { |
| 146 |
0 |
| (idx_datap)[0]=idx_badval; |
| 147 |
|
| } |
| 148 |
|
| }} /* Close n */ |
| 149 |
|
| |
| 150 |
5 |
▶ | }PDL_BROADCASTLOOP_END_vsearch_bin_exclusive_readdata |
Branch: 2 branches
| Branch | True | False | Total |
| }PDL_BROADCASTLOOP_END_vsearch_bin_exclusive_readdata |
0 |
5 |
5 |
| }PDL_BROADCASTLOOP_END_vsearch_bin_exclusive_readdata |
0 |
5 |
5 |
|
| 151 |
5 |
| } break; |
| 152 |
23 |
| case PDL_LD: { |
| 153 |
23 |
▶ | PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_LDouble,E,PDL_Indx,N) |
Branch: 12 branches
| Branch | True | False | Total |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_LDouble,E,PDL_Indx,N) |
0 |
23 |
23 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_LDouble,E,PDL_Indx,N) |
23 |
0 |
23 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_LDouble,E,PDL_Indx,N) |
0 |
23 |
23 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_LDouble,E,PDL_Indx,N) |
0 |
23 |
23 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_LDouble,E,PDL_Indx,N) |
0 |
23 |
23 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_LDouble,E,PDL_Indx,N) |
23 |
0 |
23 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_LDouble,E,PDL_Indx,N) |
0 |
23 |
23 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_LDouble,E,PDL_Indx,N) |
0 |
23 |
23 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_LDouble,E,PDL_Indx,N) |
0 |
23 |
23 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_LDouble,E,PDL_Indx,N) |
23 |
0 |
23 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_LDouble,E,PDL_Indx,N) |
0 |
23 |
23 |
| PDL_DECLARE_PARAMS_vsearch_bin_exclusive_1(PDL_LDouble,E,PDL_Indx,N) |
0 |
23 |
23 |
|
| 154 |
5868 |
▶ | PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
Branch: 7 branches
| Branch | True | False | Total |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
23 |
23 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
23 |
23 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
23 |
23 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
23 |
23 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
0 |
23 |
23 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
5799 |
23 |
5822 |
| PDL_BROADCASTLOOP_START_vsearch_bin_exclusive_readdata { |
23 |
23 |
46 |
|
| 155 |
4198476 |
▶ | {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
Branch: 1 branch
| Branch | True | False | Total |
| {/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
4192677 |
5799 |
4198476 |
|
| 156 |
4192677 |
▶ | if ( !PDL_ISBAD2((vals_datap)[0],vals_badval,E,vals_badval_isnan) ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ( !PDL_ISBAD2((vals_datap)[0],vals_badval,E,vals_badval_isnan) ) { |
0 |
4192677 |
4192677 |
| if ( !PDL_ISBAD2((vals_datap)[0],vals_badval,E,vals_badval_isnan) ) { |
3147219 |
1045458 |
4192677 |
|
| 157 |
3147219 |
| PDL_Indx n1 = __privtrans->ind_sizes[0]-1; |
| 158 |
3147219 |
| PDL_Indx low = 0; |
| 159 |
3147219 |
| PDL_Indx high = n1; |
| 160 |
|
| PDL_Indx mid; |
| 161 |
|
| |
| 162 |
3147219 |
| PDL_LDouble value = (vals_datap)[0]; |
| 163 |
|
| |
| 164 |
|
| /* determine sort order of data */ |
| 165 |
3147219 |
| int up = (x_datap)[0+(__inc_x_n*(n1))] >= (x_datap)[0+(__inc_x_n*(0))]; |
| 166 |
|
| |
| 167 |
33313671 |
▶ | while (low <= high ) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (low <= high ) { |
30166452 |
3147219 |
33313671 |
|
| 168 |
30166452 |
| mid = low + (( high - low )>> 1);; |
| 169 |
30166452 |
▶ | if ( ( (x_datap)[0+(__inc_x_n*(mid))] < value ) == up ) low = mid + 1; |
Branch: 1 branch
| Branch | True | False | Total |
| if ( ( (x_datap)[0+(__inc_x_n*(mid))] < value ) == up ) low = mid + 1; |
15814179 |
14352273 |
30166452 |
|
| 170 |
14352273 |
| else high = mid - 1; |
| 171 |
|
| } |
| 172 |
3147219 |
▶ | (idx_datap)[0] = up ? high: low; |
Branch: 1 branch
| Branch | True | False | Total |
| (idx_datap)[0] = up ? high: low; |
1574694 |
1572525 |
3147219 |
|
| 173 |
|
| |
| 174 |
|
| } |
| 175 |
|
| |
| 176 |
|
| else { |
| 177 |
1045458 |
| (idx_datap)[0]=idx_badval; |
| 178 |
|
| } |
| 179 |
|
| }} /* Close n */ |
| 180 |
|
| |
| 181 |
23 |
▶ | }PDL_BROADCASTLOOP_END_vsearch_bin_exclusive_readdata |
Branch: 2 branches
| Branch | True | False | Total |
| }PDL_BROADCASTLOOP_END_vsearch_bin_exclusive_readdata |
0 |
23 |
23 |
| }PDL_BROADCASTLOOP_END_vsearch_bin_exclusive_readdata |
0 |
23 |
23 |
|
| 182 |
23 |
| } break; |
| 183 |
0 |
| default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in vsearch_bin_exclusive: unhandled datatype(%d), only handles (FDE)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype); |
| 184 |
|
| } |
| 185 |
|
| #undef PDL_IF_BAD |
| 186 |
28 |
| return PDL_err; |
| 187 |
|
| } |
| 188 |
|
| |
| 189 |
|
| static pdl_datatypes pdl_vsearch_bin_exclusive_vtable_gentypes[] = { PDL_F, PDL_D, PDL_LD, -1 }; |
| 190 |
|
| static PDL_Indx pdl_vsearch_bin_exclusive_vtable_realdims[] = { 0, 1, 0 }; |
| 191 |
|
| static char *pdl_vsearch_bin_exclusive_vtable_parnames[] = { "vals","x","idx" }; |
| 192 |
|
| static short pdl_vsearch_bin_exclusive_vtable_parflags[] = { |
| 193 |
|
| 0, |
| 194 |
|
| 0, |
| 195 |
|
| PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISTYPED|PDL_PARAM_ISWRITE |
| 196 |
|
| }; |
| 197 |
|
| static pdl_datatypes pdl_vsearch_bin_exclusive_vtable_partypes[] = { -1, -1, PDL_IND }; |
| 198 |
|
| static PDL_Indx pdl_vsearch_bin_exclusive_vtable_realdims_starts[] = { 0, 0, 1 }; |
| 199 |
|
| static PDL_Indx pdl_vsearch_bin_exclusive_vtable_realdims_ind_ids[] = { 0 }; |
| 200 |
|
| static char *pdl_vsearch_bin_exclusive_vtable_indnames[] = { "n" }; |
| 201 |
|
| pdl_transvtable pdl_vsearch_bin_exclusive_vtable = { |
| 202 |
|
| PDL_TRANS_DO_BROADCAST|PDL_TRANS_BADPROCESS, 0, pdl_vsearch_bin_exclusive_vtable_gentypes, 2, 3, NULL /*CORE21*/, |
| 203 |
|
| pdl_vsearch_bin_exclusive_vtable_realdims, pdl_vsearch_bin_exclusive_vtable_parnames, |
| 204 |
|
| pdl_vsearch_bin_exclusive_vtable_parflags, pdl_vsearch_bin_exclusive_vtable_partypes, |
| 205 |
|
| pdl_vsearch_bin_exclusive_vtable_realdims_starts, pdl_vsearch_bin_exclusive_vtable_realdims_ind_ids, 1, |
| 206 |
|
| 1, pdl_vsearch_bin_exclusive_vtable_indnames, |
| 207 |
|
| NULL, pdl_vsearch_bin_exclusive_readdata, NULL, |
| 208 |
|
| NULL, |
| 209 |
|
| 0,"PDL::Primitive::vsearch_bin_exclusive" |
| 210 |
|
| }; |
| 211 |
|
| |
| 212 |
|
| |
| 213 |
28 |
| pdl_error pdl_run_vsearch_bin_exclusive(pdl *vals,pdl *x,pdl *idx) { |
| 214 |
28 |
| pdl_error PDL_err = {0, NULL, 0}; |
| 215 |
28 |
▶ | if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0}; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0}; |
0 |
28 |
28 |
|
| 216 |
28 |
| pdl_trans *__privtrans = PDL->create_trans(&pdl_vsearch_bin_exclusive_vtable); |
| 217 |
28 |
▶ | if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans"); |
0 |
28 |
28 |
|
| 218 |
28 |
| __privtrans->pdls[0] = vals; |
| 219 |
28 |
| __privtrans->pdls[1] = x; |
| 220 |
28 |
| __privtrans->pdls[2] = idx; |
| 221 |
28 |
▶ | PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); |
Branch: 1 branch
| Branch | True | False | Total |
| PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); |
0 |
28 |
28 |
|
| 222 |
28 |
▶ | PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); |
Branch: 1 branch
| Branch | True | False | Total |
| PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); |
0 |
28 |
28 |
|
| 223 |
28 |
| return PDL_err; |
| 224 |
|
| } |