| 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/Ufunc.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_Ufunc |
|
21
|
|
|
|
|
|
|
extern Core* PDL; /* Structure hold core C functions */ |
|
22
|
|
|
|
|
|
|
#line 23 "lib/PDL/Ufunc-pp-modeover.c" |
|
23
|
64
|
100
|
|
|
|
|
PDL_TYPELIST_INTEGER(PDL_QSORT) |
|
|
64
|
100
|
|
|
|
|
|
|
|
0
|
100
|
|
|
|
|
|
|
|
0
|
100
|
|
|
|
|
|
|
|
0
|
100
|
|
|
|
|
|
|
|
0
|
100
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#line 1857 "lib/PDL/PP.pm" |
|
27
|
|
|
|
|
|
|
pdl_error pdl_modeover_readdata(pdl_trans *__privtrans) { |
|
28
|
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
29
|
|
|
|
|
|
|
#line 30 "lib/PDL/Ufunc-pp-modeover.c" |
|
30
|
2
|
|
|
|
|
|
register PDL_Indx __n_size = __privtrans->ind_sizes[0]; |
|
31
|
2
|
50
|
|
|
|
|
if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in modeover:" "broadcast.incs NULL"); |
|
32
|
|
|
|
|
|
|
/* broadcastloop declarations */ |
|
33
|
|
|
|
|
|
|
int __brcloopval; |
|
34
|
|
|
|
|
|
|
register PDL_Indx __tind0,__tind1; /* counters along dim */ |
|
35
|
2
|
|
|
|
|
|
register PDL_Indx __tnpdls = __privtrans->broadcast.npdls; |
|
36
|
|
|
|
|
|
|
/* dims here are how many steps along those dims */ |
|
37
|
2
|
|
|
|
|
|
register PDL_Indx __tinc0_data = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0); |
|
38
|
2
|
|
|
|
|
|
register PDL_Indx __tinc0_out = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0); |
|
39
|
2
|
|
|
|
|
|
register PDL_Indx __tinc0_sorted = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0); |
|
40
|
2
|
|
|
|
|
|
register PDL_Indx __tinc1_data = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1); |
|
41
|
2
|
|
|
|
|
|
register PDL_Indx __tinc1_out = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1); |
|
42
|
2
|
|
|
|
|
|
register PDL_Indx __tinc1_sorted = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1); |
|
43
|
|
|
|
|
|
|
#define PDL_BROADCASTLOOP_START_modeover_readdata PDL_BROADCASTLOOP_START( \ |
|
44
|
|
|
|
|
|
|
readdata, \ |
|
45
|
|
|
|
|
|
|
__privtrans->broadcast, \ |
|
46
|
|
|
|
|
|
|
__privtrans->vtable, \ |
|
47
|
|
|
|
|
|
|
data_datap += __offsp[0]; \ |
|
48
|
|
|
|
|
|
|
out_datap += __offsp[1]; \ |
|
49
|
|
|
|
|
|
|
sorted_datap += __offsp[2]; \ |
|
50
|
|
|
|
|
|
|
, \ |
|
51
|
|
|
|
|
|
|
( ,data_datap += __tinc1_data - __tinc0_data * __tdims0 \ |
|
52
|
|
|
|
|
|
|
,out_datap += __tinc1_out - __tinc0_out * __tdims0 \ |
|
53
|
|
|
|
|
|
|
,sorted_datap += __tinc1_sorted - __tinc0_sorted * __tdims0 \ |
|
54
|
|
|
|
|
|
|
), \ |
|
55
|
|
|
|
|
|
|
( ,data_datap += __tinc0_data \ |
|
56
|
|
|
|
|
|
|
,out_datap += __tinc0_out \ |
|
57
|
|
|
|
|
|
|
,sorted_datap += __tinc0_sorted \ |
|
58
|
|
|
|
|
|
|
) \ |
|
59
|
|
|
|
|
|
|
) |
|
60
|
|
|
|
|
|
|
#define PDL_BROADCASTLOOP_END_modeover_readdata PDL_BROADCASTLOOP_END( \ |
|
61
|
|
|
|
|
|
|
__privtrans->broadcast, \ |
|
62
|
|
|
|
|
|
|
data_datap -= __tinc1_data * __tdims1 + __offsp[0]; \ |
|
63
|
|
|
|
|
|
|
out_datap -= __tinc1_out * __tdims1 + __offsp[1]; \ |
|
64
|
|
|
|
|
|
|
sorted_datap -= __tinc1_sorted * __tdims1 + __offsp[2]; \ |
|
65
|
|
|
|
|
|
|
) |
|
66
|
2
|
|
|
|
|
|
register PDL_Indx __inc_data_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_data_n; |
|
67
|
2
|
|
|
|
|
|
register PDL_Indx __inc_sorted_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,2,0)]; (void)__inc_sorted_n; |
|
68
|
|
|
|
|
|
|
#ifndef PDL_DECLARE_PARAMS_modeover_1 |
|
69
|
|
|
|
|
|
|
#define PDL_DECLARE_PARAMS_modeover_1(PDL_TYPE_OP,PDL_PPSYM_OP) \ |
|
70
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_OP, data, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \ |
|
71
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_OP, out, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \ |
|
72
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_OP, sorted, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP) |
|
73
|
|
|
|
|
|
|
#endif |
|
74
|
|
|
|
|
|
|
#define PDL_IF_BAD(t,f) f |
|
75
|
2
|
|
|
|
|
|
switch (__privtrans->__datatype) { /* Start generic switch */ |
|
76
|
0
|
|
|
|
|
|
case PDL_SB: { |
|
77
|
0
|
0
|
|
|
|
|
PDL_DECLARE_PARAMS_modeover_1(PDL_SByte,A) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
PDL_BROADCASTLOOP_START_modeover_readdata { PDL_Indx i = 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
PDL_Indx most = 0; |
|
80
|
0
|
|
|
|
|
|
PDL_SByte curmode = 0; |
|
81
|
0
|
|
|
|
|
|
PDL_SByte curval = 0; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
/* Copy input to buffer for sorting, and sort it */ |
|
84
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { (sorted_datap)[0+(__inc_sorted_n*(n))] = (data_datap)[0+(__inc_data_n*(n))]; }} /* Close n */ |
|
85
|
0
|
|
|
|
|
|
qsort_A(sorted_datap,0,__privtrans->ind_sizes[0]-1); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
/* Walk through the sorted data and find the most common elemen */ |
|
88
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
|
89
|
0
|
0
|
|
|
|
|
if( n==0 || curval != (sorted_datap)[0+(__inc_sorted_n*(n))] ) { |
|
|
|
0
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
curval = (sorted_datap)[0+(__inc_sorted_n*(n))]; |
|
91
|
0
|
|
|
|
|
|
i=0; |
|
92
|
|
|
|
|
|
|
} else { |
|
93
|
0
|
|
|
|
|
|
i++; |
|
94
|
0
|
0
|
|
|
|
|
if(i>most){ |
|
95
|
0
|
|
|
|
|
|
most=i; |
|
96
|
0
|
|
|
|
|
|
curmode = curval; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
}} /* Close n */ |
|
100
|
0
|
|
|
|
|
|
(out_datap)[0] = curmode; |
|
101
|
0
|
0
|
|
|
|
|
}PDL_BROADCASTLOOP_END_modeover_readdata |
|
|
|
0
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
} break; |
|
103
|
0
|
|
|
|
|
|
case PDL_B: { |
|
104
|
0
|
0
|
|
|
|
|
PDL_DECLARE_PARAMS_modeover_1(PDL_Byte,B) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
105
|
0
|
0
|
|
|
|
|
PDL_BROADCASTLOOP_START_modeover_readdata { PDL_Indx i = 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
PDL_Indx most = 0; |
|
107
|
0
|
|
|
|
|
|
PDL_Byte curmode = 0; |
|
108
|
0
|
|
|
|
|
|
PDL_Byte curval = 0; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
/* Copy input to buffer for sorting, and sort it */ |
|
111
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { (sorted_datap)[0+(__inc_sorted_n*(n))] = (data_datap)[0+(__inc_data_n*(n))]; }} /* Close n */ |
|
112
|
0
|
|
|
|
|
|
qsort_B(sorted_datap,0,__privtrans->ind_sizes[0]-1); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
/* Walk through the sorted data and find the most common elemen */ |
|
115
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
|
116
|
0
|
0
|
|
|
|
|
if( n==0 || curval != (sorted_datap)[0+(__inc_sorted_n*(n))] ) { |
|
|
|
0
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
curval = (sorted_datap)[0+(__inc_sorted_n*(n))]; |
|
118
|
0
|
|
|
|
|
|
i=0; |
|
119
|
|
|
|
|
|
|
} else { |
|
120
|
0
|
|
|
|
|
|
i++; |
|
121
|
0
|
0
|
|
|
|
|
if(i>most){ |
|
122
|
0
|
|
|
|
|
|
most=i; |
|
123
|
0
|
|
|
|
|
|
curmode = curval; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
}} /* Close n */ |
|
127
|
0
|
|
|
|
|
|
(out_datap)[0] = curmode; |
|
128
|
0
|
0
|
|
|
|
|
}PDL_BROADCASTLOOP_END_modeover_readdata |
|
|
|
0
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
} break; |
|
130
|
0
|
|
|
|
|
|
case PDL_S: { |
|
131
|
0
|
0
|
|
|
|
|
PDL_DECLARE_PARAMS_modeover_1(PDL_Short,S) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
132
|
0
|
0
|
|
|
|
|
PDL_BROADCASTLOOP_START_modeover_readdata { PDL_Indx i = 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
PDL_Indx most = 0; |
|
134
|
0
|
|
|
|
|
|
PDL_Short curmode = 0; |
|
135
|
0
|
|
|
|
|
|
PDL_Short curval = 0; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
/* Copy input to buffer for sorting, and sort it */ |
|
138
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { (sorted_datap)[0+(__inc_sorted_n*(n))] = (data_datap)[0+(__inc_data_n*(n))]; }} /* Close n */ |
|
139
|
0
|
|
|
|
|
|
qsort_S(sorted_datap,0,__privtrans->ind_sizes[0]-1); |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
/* Walk through the sorted data and find the most common elemen */ |
|
142
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
|
143
|
0
|
0
|
|
|
|
|
if( n==0 || curval != (sorted_datap)[0+(__inc_sorted_n*(n))] ) { |
|
|
|
0
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
curval = (sorted_datap)[0+(__inc_sorted_n*(n))]; |
|
145
|
0
|
|
|
|
|
|
i=0; |
|
146
|
|
|
|
|
|
|
} else { |
|
147
|
0
|
|
|
|
|
|
i++; |
|
148
|
0
|
0
|
|
|
|
|
if(i>most){ |
|
149
|
0
|
|
|
|
|
|
most=i; |
|
150
|
0
|
|
|
|
|
|
curmode = curval; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
}} /* Close n */ |
|
154
|
0
|
|
|
|
|
|
(out_datap)[0] = curmode; |
|
155
|
0
|
0
|
|
|
|
|
}PDL_BROADCASTLOOP_END_modeover_readdata |
|
|
|
0
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
} break; |
|
157
|
0
|
|
|
|
|
|
case PDL_US: { |
|
158
|
0
|
0
|
|
|
|
|
PDL_DECLARE_PARAMS_modeover_1(PDL_Ushort,U) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
159
|
0
|
0
|
|
|
|
|
PDL_BROADCASTLOOP_START_modeover_readdata { PDL_Indx i = 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
PDL_Indx most = 0; |
|
161
|
0
|
|
|
|
|
|
PDL_Ushort curmode = 0; |
|
162
|
0
|
|
|
|
|
|
PDL_Ushort curval = 0; |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
/* Copy input to buffer for sorting, and sort it */ |
|
165
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { (sorted_datap)[0+(__inc_sorted_n*(n))] = (data_datap)[0+(__inc_data_n*(n))]; }} /* Close n */ |
|
166
|
0
|
|
|
|
|
|
qsort_U(sorted_datap,0,__privtrans->ind_sizes[0]-1); |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
/* Walk through the sorted data and find the most common elemen */ |
|
169
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
|
170
|
0
|
0
|
|
|
|
|
if( n==0 || curval != (sorted_datap)[0+(__inc_sorted_n*(n))] ) { |
|
|
|
0
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
curval = (sorted_datap)[0+(__inc_sorted_n*(n))]; |
|
172
|
0
|
|
|
|
|
|
i=0; |
|
173
|
|
|
|
|
|
|
} else { |
|
174
|
0
|
|
|
|
|
|
i++; |
|
175
|
0
|
0
|
|
|
|
|
if(i>most){ |
|
176
|
0
|
|
|
|
|
|
most=i; |
|
177
|
0
|
|
|
|
|
|
curmode = curval; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
}} /* Close n */ |
|
181
|
0
|
|
|
|
|
|
(out_datap)[0] = curmode; |
|
182
|
0
|
0
|
|
|
|
|
}PDL_BROADCASTLOOP_END_modeover_readdata |
|
|
|
0
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
} break; |
|
184
|
0
|
|
|
|
|
|
case PDL_L: { |
|
185
|
0
|
0
|
|
|
|
|
PDL_DECLARE_PARAMS_modeover_1(PDL_Long,L) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
186
|
0
|
0
|
|
|
|
|
PDL_BROADCASTLOOP_START_modeover_readdata { PDL_Indx i = 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
PDL_Indx most = 0; |
|
188
|
0
|
|
|
|
|
|
PDL_Long curmode = 0; |
|
189
|
0
|
|
|
|
|
|
PDL_Long curval = 0; |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
/* Copy input to buffer for sorting, and sort it */ |
|
192
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { (sorted_datap)[0+(__inc_sorted_n*(n))] = (data_datap)[0+(__inc_data_n*(n))]; }} /* Close n */ |
|
193
|
0
|
|
|
|
|
|
qsort_L(sorted_datap,0,__privtrans->ind_sizes[0]-1); |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
/* Walk through the sorted data and find the most common elemen */ |
|
196
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
|
197
|
0
|
0
|
|
|
|
|
if( n==0 || curval != (sorted_datap)[0+(__inc_sorted_n*(n))] ) { |
|
|
|
0
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
curval = (sorted_datap)[0+(__inc_sorted_n*(n))]; |
|
199
|
0
|
|
|
|
|
|
i=0; |
|
200
|
|
|
|
|
|
|
} else { |
|
201
|
0
|
|
|
|
|
|
i++; |
|
202
|
0
|
0
|
|
|
|
|
if(i>most){ |
|
203
|
0
|
|
|
|
|
|
most=i; |
|
204
|
0
|
|
|
|
|
|
curmode = curval; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
}} /* Close n */ |
|
208
|
0
|
|
|
|
|
|
(out_datap)[0] = curmode; |
|
209
|
0
|
0
|
|
|
|
|
}PDL_BROADCASTLOOP_END_modeover_readdata |
|
|
|
0
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
} break; |
|
211
|
0
|
|
|
|
|
|
case PDL_UL: { |
|
212
|
0
|
0
|
|
|
|
|
PDL_DECLARE_PARAMS_modeover_1(PDL_ULong,K) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
213
|
0
|
0
|
|
|
|
|
PDL_BROADCASTLOOP_START_modeover_readdata { PDL_Indx i = 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
PDL_Indx most = 0; |
|
215
|
0
|
|
|
|
|
|
PDL_ULong curmode = 0; |
|
216
|
0
|
|
|
|
|
|
PDL_ULong curval = 0; |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
/* Copy input to buffer for sorting, and sort it */ |
|
219
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { (sorted_datap)[0+(__inc_sorted_n*(n))] = (data_datap)[0+(__inc_data_n*(n))]; }} /* Close n */ |
|
220
|
0
|
|
|
|
|
|
qsort_K(sorted_datap,0,__privtrans->ind_sizes[0]-1); |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
/* Walk through the sorted data and find the most common elemen */ |
|
223
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
|
224
|
0
|
0
|
|
|
|
|
if( n==0 || curval != (sorted_datap)[0+(__inc_sorted_n*(n))] ) { |
|
|
|
0
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
curval = (sorted_datap)[0+(__inc_sorted_n*(n))]; |
|
226
|
0
|
|
|
|
|
|
i=0; |
|
227
|
|
|
|
|
|
|
} else { |
|
228
|
0
|
|
|
|
|
|
i++; |
|
229
|
0
|
0
|
|
|
|
|
if(i>most){ |
|
230
|
0
|
|
|
|
|
|
most=i; |
|
231
|
0
|
|
|
|
|
|
curmode = curval; |
|
232
|
|
|
|
|
|
|
} |
|
233
|
|
|
|
|
|
|
} |
|
234
|
|
|
|
|
|
|
}} /* Close n */ |
|
235
|
0
|
|
|
|
|
|
(out_datap)[0] = curmode; |
|
236
|
0
|
0
|
|
|
|
|
}PDL_BROADCASTLOOP_END_modeover_readdata |
|
|
|
0
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
} break; |
|
238
|
0
|
|
|
|
|
|
case PDL_IND: { |
|
239
|
0
|
0
|
|
|
|
|
PDL_DECLARE_PARAMS_modeover_1(PDL_Indx,N) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
240
|
0
|
0
|
|
|
|
|
PDL_BROADCASTLOOP_START_modeover_readdata { PDL_Indx i = 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
241
|
0
|
|
|
|
|
|
PDL_Indx most = 0; |
|
242
|
0
|
|
|
|
|
|
PDL_Indx curmode = 0; |
|
243
|
0
|
|
|
|
|
|
PDL_Indx curval = 0; |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
/* Copy input to buffer for sorting, and sort it */ |
|
246
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { (sorted_datap)[0+(__inc_sorted_n*(n))] = (data_datap)[0+(__inc_data_n*(n))]; }} /* Close n */ |
|
247
|
0
|
|
|
|
|
|
qsort_N(sorted_datap,0,__privtrans->ind_sizes[0]-1); |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
/* Walk through the sorted data and find the most common elemen */ |
|
250
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
|
251
|
0
|
0
|
|
|
|
|
if( n==0 || curval != (sorted_datap)[0+(__inc_sorted_n*(n))] ) { |
|
|
|
0
|
|
|
|
|
|
|
252
|
0
|
|
|
|
|
|
curval = (sorted_datap)[0+(__inc_sorted_n*(n))]; |
|
253
|
0
|
|
|
|
|
|
i=0; |
|
254
|
|
|
|
|
|
|
} else { |
|
255
|
0
|
|
|
|
|
|
i++; |
|
256
|
0
|
0
|
|
|
|
|
if(i>most){ |
|
257
|
0
|
|
|
|
|
|
most=i; |
|
258
|
0
|
|
|
|
|
|
curmode = curval; |
|
259
|
|
|
|
|
|
|
} |
|
260
|
|
|
|
|
|
|
} |
|
261
|
|
|
|
|
|
|
}} /* Close n */ |
|
262
|
0
|
|
|
|
|
|
(out_datap)[0] = curmode; |
|
263
|
0
|
0
|
|
|
|
|
}PDL_BROADCASTLOOP_END_modeover_readdata |
|
|
|
0
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
|
} break; |
|
265
|
0
|
|
|
|
|
|
case PDL_ULL: { |
|
266
|
0
|
0
|
|
|
|
|
PDL_DECLARE_PARAMS_modeover_1(PDL_ULongLong,P) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
267
|
0
|
0
|
|
|
|
|
PDL_BROADCASTLOOP_START_modeover_readdata { PDL_Indx i = 0; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
268
|
0
|
|
|
|
|
|
PDL_Indx most = 0; |
|
269
|
0
|
|
|
|
|
|
PDL_ULongLong curmode = 0; |
|
270
|
0
|
|
|
|
|
|
PDL_ULongLong curval = 0; |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
/* Copy input to buffer for sorting, and sort it */ |
|
273
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { (sorted_datap)[0+(__inc_sorted_n*(n))] = (data_datap)[0+(__inc_data_n*(n))]; }} /* Close n */ |
|
274
|
0
|
|
|
|
|
|
qsort_P(sorted_datap,0,__privtrans->ind_sizes[0]-1); |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
/* Walk through the sorted data and find the most common elemen */ |
|
277
|
0
|
0
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
|
278
|
0
|
0
|
|
|
|
|
if( n==0 || curval != (sorted_datap)[0+(__inc_sorted_n*(n))] ) { |
|
|
|
0
|
|
|
|
|
|
|
279
|
0
|
|
|
|
|
|
curval = (sorted_datap)[0+(__inc_sorted_n*(n))]; |
|
280
|
0
|
|
|
|
|
|
i=0; |
|
281
|
|
|
|
|
|
|
} else { |
|
282
|
0
|
|
|
|
|
|
i++; |
|
283
|
0
|
0
|
|
|
|
|
if(i>most){ |
|
284
|
0
|
|
|
|
|
|
most=i; |
|
285
|
0
|
|
|
|
|
|
curmode = curval; |
|
286
|
|
|
|
|
|
|
} |
|
287
|
|
|
|
|
|
|
} |
|
288
|
|
|
|
|
|
|
}} /* Close n */ |
|
289
|
0
|
|
|
|
|
|
(out_datap)[0] = curmode; |
|
290
|
0
|
0
|
|
|
|
|
}PDL_BROADCASTLOOP_END_modeover_readdata |
|
|
|
0
|
|
|
|
|
|
|
291
|
0
|
|
|
|
|
|
} break; |
|
292
|
2
|
|
|
|
|
|
case PDL_LL: { |
|
293
|
2
|
50
|
|
|
|
|
PDL_DECLARE_PARAMS_modeover_1(PDL_LongLong,Q) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
294
|
9
|
50
|
|
|
|
|
PDL_BROADCASTLOOP_START_modeover_readdata { PDL_Indx i = 0; |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
295
|
3
|
|
|
|
|
|
PDL_Indx most = 0; |
|
296
|
3
|
|
|
|
|
|
PDL_LongLong curmode = 0; |
|
297
|
3
|
|
|
|
|
|
PDL_LongLong curval = 0; |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
/* Copy input to buffer for sorting, and sort it */ |
|
300
|
31
|
100
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { (sorted_datap)[0+(__inc_sorted_n*(n))] = (data_datap)[0+(__inc_data_n*(n))]; }} /* Close n */ |
|
301
|
3
|
|
|
|
|
|
qsort_Q(sorted_datap,0,__privtrans->ind_sizes[0]-1); |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
/* Walk through the sorted data and find the most common elemen */ |
|
304
|
31
|
100
|
|
|
|
|
{/* Open n */ PDL_EXPAND2(register PDL_Indx n=0, __n_stop=(__n_size)); for(; n<__n_stop; n+=1) { |
|
305
|
28
|
100
|
|
|
|
|
if( n==0 || curval != (sorted_datap)[0+(__inc_sorted_n*(n))] ) { |
|
|
|
100
|
|
|
|
|
|
|
306
|
11
|
|
|
|
|
|
curval = (sorted_datap)[0+(__inc_sorted_n*(n))]; |
|
307
|
11
|
|
|
|
|
|
i=0; |
|
308
|
|
|
|
|
|
|
} else { |
|
309
|
17
|
|
|
|
|
|
i++; |
|
310
|
17
|
100
|
|
|
|
|
if(i>most){ |
|
311
|
12
|
|
|
|
|
|
most=i; |
|
312
|
12
|
|
|
|
|
|
curmode = curval; |
|
313
|
|
|
|
|
|
|
} |
|
314
|
|
|
|
|
|
|
} |
|
315
|
|
|
|
|
|
|
}} /* Close n */ |
|
316
|
3
|
|
|
|
|
|
(out_datap)[0] = curmode; |
|
317
|
2
|
50
|
|
|
|
|
}PDL_BROADCASTLOOP_END_modeover_readdata |
|
|
|
50
|
|
|
|
|
|
|
318
|
2
|
|
|
|
|
|
} break; |
|
319
|
0
|
|
|
|
|
|
default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in modeover: unhandled datatype(%d), only handles (ABSULKNPQ)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype); |
|
320
|
|
|
|
|
|
|
} |
|
321
|
|
|
|
|
|
|
#undef PDL_IF_BAD |
|
322
|
2
|
|
|
|
|
|
return PDL_err; |
|
323
|
|
|
|
|
|
|
} |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
static pdl_datatypes pdl_modeover_vtable_gentypes[] = { PDL_SB, PDL_B, PDL_S, PDL_US, PDL_L, PDL_UL, PDL_IND, PDL_ULL, PDL_LL, -1 }; |
|
326
|
|
|
|
|
|
|
static PDL_Indx pdl_modeover_vtable_realdims[] = { 1, 0, 1 }; |
|
327
|
|
|
|
|
|
|
static char *pdl_modeover_vtable_parnames[] = { "data","out","sorted" }; |
|
328
|
|
|
|
|
|
|
static short pdl_modeover_vtable_parflags[] = { |
|
329
|
|
|
|
|
|
|
0, |
|
330
|
|
|
|
|
|
|
PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE, |
|
331
|
|
|
|
|
|
|
PDL_PARAM_ISCREAT|PDL_PARAM_ISPHYS|PDL_PARAM_ISTEMP|PDL_PARAM_ISWRITE |
|
332
|
|
|
|
|
|
|
}; |
|
333
|
|
|
|
|
|
|
static pdl_datatypes pdl_modeover_vtable_partypes[] = { -1, -1, -1 }; |
|
334
|
|
|
|
|
|
|
static PDL_Indx pdl_modeover_vtable_realdims_starts[] = { 0, 1, 1 }; |
|
335
|
|
|
|
|
|
|
static PDL_Indx pdl_modeover_vtable_realdims_ind_ids[] = { 0, 0 }; |
|
336
|
|
|
|
|
|
|
static char *pdl_modeover_vtable_indnames[] = { "n" }; |
|
337
|
|
|
|
|
|
|
pdl_transvtable pdl_modeover_vtable = { |
|
338
|
|
|
|
|
|
|
PDL_TRANS_DO_BROADCAST, 0, pdl_modeover_vtable_gentypes, 1, 3, NULL /*CORE21*/, |
|
339
|
|
|
|
|
|
|
pdl_modeover_vtable_realdims, pdl_modeover_vtable_parnames, |
|
340
|
|
|
|
|
|
|
pdl_modeover_vtable_parflags, pdl_modeover_vtable_partypes, |
|
341
|
|
|
|
|
|
|
pdl_modeover_vtable_realdims_starts, pdl_modeover_vtable_realdims_ind_ids, 2, |
|
342
|
|
|
|
|
|
|
1, pdl_modeover_vtable_indnames, |
|
343
|
|
|
|
|
|
|
NULL, pdl_modeover_readdata, NULL, |
|
344
|
|
|
|
|
|
|
NULL, |
|
345
|
|
|
|
|
|
|
0,"PDL::Ufunc::modeover" |
|
346
|
|
|
|
|
|
|
}; |
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
|
|
349
|
2
|
|
|
|
|
|
pdl_error pdl_run_modeover(pdl *data,pdl *out) { |
|
350
|
2
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
351
|
2
|
50
|
|
|
|
|
if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0}; |
|
352
|
2
|
|
|
|
|
|
pdl_trans *__privtrans = PDL->create_trans(&pdl_modeover_vtable); |
|
353
|
2
|
50
|
|
|
|
|
if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans"); |
|
354
|
2
|
|
|
|
|
|
__privtrans->pdls[0] = data; |
|
355
|
2
|
|
|
|
|
|
__privtrans->pdls[1] = out; |
|
356
|
2
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); |
|
357
|
2
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); |
|
358
|
2
|
|
|
|
|
|
return PDL_err; |
|
359
|
|
|
|
|
|
|
} |