line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# GENERATED WITH PDL::PP! Don't modify! |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
package PDL::CCS::Ufunc; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
@EXPORT_OK = qw( PDL::PP ccs_accum_prod PDL::PP ccs_accum_dprod PDL::PP ccs_accum_sum PDL::PP ccs_accum_dsum PDL::PP ccs_accum_or PDL::PP ccs_accum_and PDL::PP ccs_accum_bor PDL::PP ccs_accum_band PDL::PP ccs_accum_maximum PDL::PP ccs_accum_minimum PDL::PP ccs_accum_maximum_nz_ind PDL::PP ccs_accum_minimum_nz_ind PDL::PP ccs_accum_nbad PDL::PP ccs_accum_ngood PDL::PP ccs_accum_nnz PDL::PP ccs_accum_average ); |
8
|
|
|
|
|
|
|
%EXPORT_TAGS = (Func=>[@EXPORT_OK]); |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
28
|
use PDL::Core; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
25
|
|
11
|
4
|
|
|
4
|
|
1035
|
use PDL::Exporter; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
22
|
|
12
|
4
|
|
|
4
|
|
124
|
use DynaLoader; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
253
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$PDL::CCS::Ufunc::VERSION = 1.23.12; |
17
|
|
|
|
|
|
|
@ISA = ( 'PDL::Exporter','DynaLoader' ); |
18
|
|
|
|
|
|
|
push @PDL::Core::PP, __PACKAGE__; |
19
|
|
|
|
|
|
|
bootstrap PDL::CCS::Ufunc $VERSION; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#use PDL::CCS::Version; |
26
|
4
|
|
|
4
|
|
23
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
14062
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=pod |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
PDL::CCS::Ufunc - Ufuncs for compressed storage sparse PDLs |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use PDL; |
37
|
|
|
|
|
|
|
use PDL::CCS::Ufunc; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
##--------------------------------------------------------------------- |
40
|
|
|
|
|
|
|
## ... stuff happens |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 FUNCTIONS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
*ccs_indx = \&PDL::indx; ##-- typecasting for CCS indices |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 ccs_accum_prod |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=for sig |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Signature: ( |
69
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
70
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
71
|
|
|
|
|
|
|
missing(); |
72
|
|
|
|
|
|
|
indx N(); |
73
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
74
|
|
|
|
|
|
|
[o]nzvalsOut(NnzOut); |
75
|
|
|
|
|
|
|
indx [o]nOut(); |
76
|
|
|
|
|
|
|
) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Accumulated product over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
80
|
|
|
|
|
|
|
On return, |
81
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
82
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
83
|
|
|
|
|
|
|
and |
84
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
If $N() is specified and greater than zero, then the quantity: |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
$missing ** ($N - (rlevec($ixIn))[0]) |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
is multiplied into $nzvalsOut: this is probably What You Want if you are computing the product over a virtual |
92
|
|
|
|
|
|
|
dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class). |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=for bad |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
ccs_accum_prod processes bad values. |
105
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub PDL::ccs_accum_prod { |
115
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
116
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
117
|
0
|
|
|
|
|
|
my (@nnzOut); |
118
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
119
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
120
|
0
|
|
|
|
|
|
shift(@nnzOut); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
125
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
126
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
127
|
|
|
|
|
|
|
|
128
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) |
129
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
130
|
|
|
|
|
|
|
|
131
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
132
|
|
|
|
|
|
|
## |
133
|
|
|
|
|
|
|
##-- guts |
134
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_prod_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
135
|
|
|
|
|
|
|
## |
136
|
|
|
|
|
|
|
##-- auto-trim |
137
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
138
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
139
|
|
|
|
|
|
|
## |
140
|
|
|
|
|
|
|
##-- return |
141
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
*ccs_accum_prod = \&PDL::ccs_accum_prod; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 ccs_accum_dprod |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=for sig |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Signature: ( |
156
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
157
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
158
|
|
|
|
|
|
|
missing(); |
159
|
|
|
|
|
|
|
indx N(); |
160
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
161
|
|
|
|
|
|
|
double [o]nzvalsOut(NnzOut); |
162
|
|
|
|
|
|
|
indx [o]nOut(); |
163
|
|
|
|
|
|
|
) |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Accumulated double-precision product over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
167
|
|
|
|
|
|
|
On return, |
168
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
169
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
170
|
|
|
|
|
|
|
and |
171
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
If $N() is specified and greater than zero, then the quantity: |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
$missing ** ($N - (rlevec($ixIn))[0]) |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
is multiplied into $nzvalsOut: this is probably What You Want if you are computing the product over a virtual |
179
|
|
|
|
|
|
|
dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class). |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=for bad |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
ccs_accum_dprod processes bad values. |
192
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub PDL::ccs_accum_dprod { |
202
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
203
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
204
|
0
|
|
|
|
|
|
my (@nnzOut); |
205
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
206
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
207
|
0
|
|
|
|
|
|
shift(@nnzOut); |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
211
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
212
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
213
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
214
|
|
|
|
|
|
|
|
215
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes((PDL::double()), @nnzOut) |
216
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
217
|
|
|
|
|
|
|
|
218
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
219
|
|
|
|
|
|
|
## |
220
|
|
|
|
|
|
|
##-- guts |
221
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_dprod_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
222
|
|
|
|
|
|
|
## |
223
|
|
|
|
|
|
|
##-- auto-trim |
224
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
225
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
226
|
|
|
|
|
|
|
## |
227
|
|
|
|
|
|
|
##-- return |
228
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
*ccs_accum_dprod = \&PDL::ccs_accum_dprod; |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head2 ccs_accum_sum |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=for sig |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Signature: ( |
243
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
244
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
245
|
|
|
|
|
|
|
missing(); |
246
|
|
|
|
|
|
|
indx N(); |
247
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
248
|
|
|
|
|
|
|
[o]nzvalsOut(NnzOut); |
249
|
|
|
|
|
|
|
indx [o]nOut(); |
250
|
|
|
|
|
|
|
) |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Accumulated sum over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
254
|
|
|
|
|
|
|
On return, |
255
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
256
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
257
|
|
|
|
|
|
|
and |
258
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
If $N() is specified and greater than zero, then the quantity: |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
$missing * ($N - (rlevec($ixIn))[0]) |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
is added to $nzvalsOut: this is probably What You Want if you are summing over a virtual |
266
|
|
|
|
|
|
|
dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class). |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=for bad |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
ccs_accum_sum processes bad values. |
279
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=cut |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
sub PDL::ccs_accum_sum { |
289
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
290
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
291
|
0
|
|
|
|
|
|
my (@nnzOut); |
292
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
293
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
294
|
0
|
|
|
|
|
|
shift(@nnzOut); |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
298
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
299
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
300
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
301
|
|
|
|
|
|
|
|
302
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) |
303
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
304
|
|
|
|
|
|
|
|
305
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
306
|
|
|
|
|
|
|
## |
307
|
|
|
|
|
|
|
##-- guts |
308
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_sum_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
309
|
|
|
|
|
|
|
## |
310
|
|
|
|
|
|
|
##-- auto-trim |
311
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
312
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
313
|
|
|
|
|
|
|
## |
314
|
|
|
|
|
|
|
##-- return |
315
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
*ccs_accum_sum = \&PDL::ccs_accum_sum; |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=head2 ccs_accum_dsum |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=for sig |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
Signature: ( |
330
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
331
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
332
|
|
|
|
|
|
|
missing(); |
333
|
|
|
|
|
|
|
indx N(); |
334
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
335
|
|
|
|
|
|
|
double [o]nzvalsOut(NnzOut); |
336
|
|
|
|
|
|
|
indx [o]nOut(); |
337
|
|
|
|
|
|
|
) |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
Accumulated double-precision sum over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
341
|
|
|
|
|
|
|
On return, |
342
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
343
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
344
|
|
|
|
|
|
|
and |
345
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
If $N() is specified and greater than zero, then the quantity: |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
$missing * ($N - (rlevec($ixIn))[0]) |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
is added to $nzvalsOut: this is probably What You Want if you are summing over a virtual |
353
|
|
|
|
|
|
|
dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class). |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
=for bad |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
ccs_accum_dsum processes bad values. |
366
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
=cut |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
sub PDL::ccs_accum_dsum { |
376
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
377
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
378
|
0
|
|
|
|
|
|
my (@nnzOut); |
379
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
380
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
381
|
0
|
|
|
|
|
|
shift(@nnzOut); |
382
|
|
|
|
|
|
|
} |
383
|
|
|
|
|
|
|
|
384
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
385
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
386
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
387
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
388
|
|
|
|
|
|
|
|
389
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes((PDL::double()), @nnzOut) |
390
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
391
|
|
|
|
|
|
|
|
392
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
393
|
|
|
|
|
|
|
## |
394
|
|
|
|
|
|
|
##-- guts |
395
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_dsum_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
396
|
|
|
|
|
|
|
## |
397
|
|
|
|
|
|
|
##-- auto-trim |
398
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
399
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
400
|
|
|
|
|
|
|
## |
401
|
|
|
|
|
|
|
##-- return |
402
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
403
|
|
|
|
|
|
|
} |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
*ccs_accum_dsum = \&PDL::ccs_accum_dsum; |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
=head2 ccs_accum_or |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
=for sig |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
Signature: ( |
417
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
418
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
419
|
|
|
|
|
|
|
missing(); |
420
|
|
|
|
|
|
|
indx N(); |
421
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
422
|
|
|
|
|
|
|
[o]nzvalsOut(NnzOut); |
423
|
|
|
|
|
|
|
indx [o]nOut(); |
424
|
|
|
|
|
|
|
) |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
Accumulated logical "or" over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
428
|
|
|
|
|
|
|
On return, |
429
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
430
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
431
|
|
|
|
|
|
|
and |
432
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
If $N() is specified and greater than zero, $missing() is logically (or)ed |
436
|
|
|
|
|
|
|
into each result value at each output index with a run length of less than $N() in $ixIn(). |
437
|
|
|
|
|
|
|
This is probably What You Want. |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
=for bad |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
ccs_accum_or processes bad values. |
450
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
=cut |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
sub PDL::ccs_accum_or { |
460
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
461
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
462
|
0
|
|
|
|
|
|
my (@nnzOut); |
463
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
464
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
465
|
0
|
|
|
|
|
|
shift(@nnzOut); |
466
|
|
|
|
|
|
|
} |
467
|
|
|
|
|
|
|
|
468
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
469
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
470
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
471
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
472
|
|
|
|
|
|
|
|
473
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) |
474
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
475
|
|
|
|
|
|
|
|
476
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
477
|
|
|
|
|
|
|
## |
478
|
|
|
|
|
|
|
##-- guts |
479
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_or_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
480
|
|
|
|
|
|
|
## |
481
|
|
|
|
|
|
|
##-- auto-trim |
482
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
483
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
484
|
|
|
|
|
|
|
## |
485
|
|
|
|
|
|
|
##-- return |
486
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
487
|
|
|
|
|
|
|
} |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
*ccs_accum_or = \&PDL::ccs_accum_or; |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
=head2 ccs_accum_and |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=for sig |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
Signature: ( |
501
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
502
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
503
|
|
|
|
|
|
|
missing(); |
504
|
|
|
|
|
|
|
indx N(); |
505
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
506
|
|
|
|
|
|
|
[o]nzvalsOut(NnzOut); |
507
|
|
|
|
|
|
|
indx [o]nOut(); |
508
|
|
|
|
|
|
|
) |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
Accumulated logical "and" over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
512
|
|
|
|
|
|
|
On return, |
513
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
514
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
515
|
|
|
|
|
|
|
and |
516
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
If $N() is specified and greater than zero, $missing() is logically (and)ed |
520
|
|
|
|
|
|
|
into each result value at each output index with a run length of less than $N() in $ixIn(). |
521
|
|
|
|
|
|
|
This is probably What You Want. |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
=for bad |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
ccs_accum_and processes bad values. |
534
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
=cut |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
sub PDL::ccs_accum_and { |
544
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
545
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
546
|
0
|
|
|
|
|
|
my (@nnzOut); |
547
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
548
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
549
|
0
|
|
|
|
|
|
shift(@nnzOut); |
550
|
|
|
|
|
|
|
} |
551
|
|
|
|
|
|
|
|
552
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
553
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
554
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
555
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
556
|
|
|
|
|
|
|
|
557
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) |
558
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
559
|
|
|
|
|
|
|
|
560
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
561
|
|
|
|
|
|
|
## |
562
|
|
|
|
|
|
|
##-- guts |
563
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_and_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
564
|
|
|
|
|
|
|
## |
565
|
|
|
|
|
|
|
##-- auto-trim |
566
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
567
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
568
|
|
|
|
|
|
|
## |
569
|
|
|
|
|
|
|
##-- return |
570
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
571
|
|
|
|
|
|
|
} |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
*ccs_accum_and = \&PDL::ccs_accum_and; |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
=head2 ccs_accum_bor |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
=for sig |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
Signature: ( |
585
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
586
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
587
|
|
|
|
|
|
|
missing(); |
588
|
|
|
|
|
|
|
indx N(); |
589
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
590
|
|
|
|
|
|
|
[o]nzvalsOut(NnzOut); |
591
|
|
|
|
|
|
|
indx [o]nOut(); |
592
|
|
|
|
|
|
|
) |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
Accumulated bitwise "or" over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
596
|
|
|
|
|
|
|
On return, |
597
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
598
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
599
|
|
|
|
|
|
|
and |
600
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
If $N() is specified and greater than zero, $missing() is bitwise (or)ed |
604
|
|
|
|
|
|
|
into each result value at each output index with a run length of less than $N() in $ixIn(). |
605
|
|
|
|
|
|
|
This is probably What You Want. |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
=for bad |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
ccs_accum_bor processes bad values. |
618
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
619
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
=cut |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
sub PDL::ccs_accum_bor { |
628
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
629
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
630
|
0
|
|
|
|
|
|
my (@nnzOut); |
631
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
632
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
633
|
0
|
|
|
|
|
|
shift(@nnzOut); |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
|
636
|
0
|
0
|
|
|
|
|
$nzvalsIn = ccs_indx($nzvalsIn) if ($nzvalsIn->type > ccs_indx()); ##-- max_type_perl=ccs_indx |
637
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
638
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
639
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
640
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
641
|
|
|
|
|
|
|
|
642
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) |
643
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
644
|
|
|
|
|
|
|
|
645
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
646
|
|
|
|
|
|
|
## |
647
|
|
|
|
|
|
|
##-- guts |
648
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_bor_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
649
|
|
|
|
|
|
|
## |
650
|
|
|
|
|
|
|
##-- auto-trim |
651
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
652
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
653
|
|
|
|
|
|
|
## |
654
|
|
|
|
|
|
|
##-- return |
655
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
656
|
|
|
|
|
|
|
} |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
*ccs_accum_bor = \&PDL::ccs_accum_bor; |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
=head2 ccs_accum_band |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
=for sig |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
Signature: ( |
670
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
671
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
672
|
|
|
|
|
|
|
missing(); |
673
|
|
|
|
|
|
|
indx N(); |
674
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
675
|
|
|
|
|
|
|
[o]nzvalsOut(NnzOut); |
676
|
|
|
|
|
|
|
indx [o]nOut(); |
677
|
|
|
|
|
|
|
) |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
Accumulated bitwise "and" over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
681
|
|
|
|
|
|
|
On return, |
682
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
683
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
684
|
|
|
|
|
|
|
and |
685
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
If $N() is specified and greater than zero, $missing() is bitwise (and)ed |
689
|
|
|
|
|
|
|
into each result value at each output index with a run length of less than $N() in $ixIn(). |
690
|
|
|
|
|
|
|
This is probably What You Want. |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
=for bad |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
ccs_accum_band processes bad values. |
703
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
=cut |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
sub PDL::ccs_accum_band { |
713
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
714
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
715
|
0
|
|
|
|
|
|
my (@nnzOut); |
716
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
717
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
718
|
0
|
|
|
|
|
|
shift(@nnzOut); |
719
|
|
|
|
|
|
|
} |
720
|
|
|
|
|
|
|
|
721
|
0
|
0
|
|
|
|
|
$nzvalsIn = ccs_indx($nzvalsIn) if ($nzvalsIn->type > ccs_indx()); ##-- max_type_perl=ccs_indx |
722
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
723
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
724
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
725
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
726
|
|
|
|
|
|
|
|
727
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) |
728
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
729
|
|
|
|
|
|
|
|
730
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
731
|
|
|
|
|
|
|
## |
732
|
|
|
|
|
|
|
##-- guts |
733
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_band_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
734
|
|
|
|
|
|
|
## |
735
|
|
|
|
|
|
|
##-- auto-trim |
736
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
737
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
738
|
|
|
|
|
|
|
## |
739
|
|
|
|
|
|
|
##-- return |
740
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
741
|
|
|
|
|
|
|
} |
742
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
*ccs_accum_band = \&PDL::ccs_accum_band; |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
|
750
|
|
|
|
|
|
|
=head2 ccs_accum_maximum |
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
=for sig |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
Signature: ( |
755
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
756
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
757
|
|
|
|
|
|
|
missing(); |
758
|
|
|
|
|
|
|
indx N(); |
759
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
760
|
|
|
|
|
|
|
[o]nzvalsOut(NnzOut); |
761
|
|
|
|
|
|
|
indx [o]nOut(); |
762
|
|
|
|
|
|
|
) |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
Accumulated maximum over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
766
|
|
|
|
|
|
|
On return, |
767
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
768
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
769
|
|
|
|
|
|
|
and |
770
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
771
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
If $N() is specified and greater than zero, |
774
|
|
|
|
|
|
|
and if $missing() is greater than any listed value for a vector key with a run-length |
775
|
|
|
|
|
|
|
of less than $N(), then $missing() is used as the output value for that key. |
776
|
|
|
|
|
|
|
This is probably What You Want. |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
=for bad |
787
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
ccs_accum_maximum processes bad values. |
789
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
|
792
|
|
|
|
|
|
|
=cut |
793
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
sub PDL::ccs_accum_maximum { |
799
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
800
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
801
|
0
|
|
|
|
|
|
my (@nnzOut); |
802
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
803
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
804
|
0
|
|
|
|
|
|
shift(@nnzOut); |
805
|
|
|
|
|
|
|
} |
806
|
|
|
|
|
|
|
|
807
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
808
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
809
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
810
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
811
|
|
|
|
|
|
|
|
812
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) |
813
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
814
|
|
|
|
|
|
|
|
815
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
816
|
|
|
|
|
|
|
## |
817
|
|
|
|
|
|
|
##-- guts |
818
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_maximum_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
819
|
|
|
|
|
|
|
## |
820
|
|
|
|
|
|
|
##-- auto-trim |
821
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
822
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
823
|
|
|
|
|
|
|
## |
824
|
|
|
|
|
|
|
##-- return |
825
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
826
|
|
|
|
|
|
|
} |
827
|
|
|
|
|
|
|
|
828
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
*ccs_accum_maximum = \&PDL::ccs_accum_maximum; |
830
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
|
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
=head2 ccs_accum_minimum |
836
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
=for sig |
838
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
Signature: ( |
840
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
841
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
842
|
|
|
|
|
|
|
missing(); |
843
|
|
|
|
|
|
|
indx N(); |
844
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
845
|
|
|
|
|
|
|
[o]nzvalsOut(NnzOut); |
846
|
|
|
|
|
|
|
indx [o]nOut(); |
847
|
|
|
|
|
|
|
) |
848
|
|
|
|
|
|
|
|
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
Accumulated minimum over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
851
|
|
|
|
|
|
|
On return, |
852
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
853
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
854
|
|
|
|
|
|
|
and |
855
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
856
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
If $N() is specified and greater than zero, |
859
|
|
|
|
|
|
|
and if $missing() is less than any listed value for a vector key with a run-length |
860
|
|
|
|
|
|
|
of less than $N(), then $missing() is used as the output value for that key. |
861
|
|
|
|
|
|
|
This is probably What You Want. |
862
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
|
864
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
866
|
|
|
|
|
|
|
|
867
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
868
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
=for bad |
872
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
ccs_accum_minimum processes bad values. |
874
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
875
|
|
|
|
|
|
|
|
876
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
=cut |
878
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
|
880
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
sub PDL::ccs_accum_minimum { |
884
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
885
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
886
|
0
|
|
|
|
|
|
my (@nnzOut); |
887
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
888
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
889
|
0
|
|
|
|
|
|
shift(@nnzOut); |
890
|
|
|
|
|
|
|
} |
891
|
|
|
|
|
|
|
|
892
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
893
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
894
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
895
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
896
|
|
|
|
|
|
|
|
897
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) |
898
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
899
|
|
|
|
|
|
|
|
900
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
901
|
|
|
|
|
|
|
## |
902
|
|
|
|
|
|
|
##-- guts |
903
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_minimum_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
904
|
|
|
|
|
|
|
## |
905
|
|
|
|
|
|
|
##-- auto-trim |
906
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
907
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
908
|
|
|
|
|
|
|
## |
909
|
|
|
|
|
|
|
##-- return |
910
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
911
|
|
|
|
|
|
|
} |
912
|
|
|
|
|
|
|
|
913
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
*ccs_accum_minimum = \&PDL::ccs_accum_minimum; |
915
|
|
|
|
|
|
|
|
916
|
|
|
|
|
|
|
|
917
|
|
|
|
|
|
|
|
918
|
|
|
|
|
|
|
|
919
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
=head2 ccs_accum_maximum_nz_ind |
921
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
=for sig |
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
Signature: ( |
925
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
926
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
927
|
|
|
|
|
|
|
missing(); |
928
|
|
|
|
|
|
|
indx N(); |
929
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
930
|
|
|
|
|
|
|
indx [o]nzvalsOut(NnzOut); |
931
|
|
|
|
|
|
|
indx [o]nOut(); |
932
|
|
|
|
|
|
|
) |
933
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
|
935
|
|
|
|
|
|
|
Accumulated maximum_nz_ind over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
936
|
|
|
|
|
|
|
On return, |
937
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
938
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
939
|
|
|
|
|
|
|
and |
940
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
941
|
|
|
|
|
|
|
|
942
|
|
|
|
|
|
|
|
943
|
|
|
|
|
|
|
Output indices index $nzvalsIn, -1 indicates that the missing value is maximal. |
944
|
|
|
|
|
|
|
|
945
|
|
|
|
|
|
|
|
946
|
|
|
|
|
|
|
|
947
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
948
|
|
|
|
|
|
|
|
949
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
950
|
|
|
|
|
|
|
|
951
|
|
|
|
|
|
|
|
952
|
|
|
|
|
|
|
|
953
|
|
|
|
|
|
|
=for bad |
954
|
|
|
|
|
|
|
|
955
|
|
|
|
|
|
|
ccs_accum_maximum_nz_ind processes bad values. |
956
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
|
959
|
|
|
|
|
|
|
=cut |
960
|
|
|
|
|
|
|
|
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
|
963
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
|
965
|
|
|
|
|
|
|
sub PDL::ccs_accum_maximum_nz_ind { |
966
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
967
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
968
|
0
|
|
|
|
|
|
my (@nnzOut); |
969
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
970
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
971
|
0
|
|
|
|
|
|
shift(@nnzOut); |
972
|
|
|
|
|
|
|
} |
973
|
|
|
|
|
|
|
|
974
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
975
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
976
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
977
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
978
|
|
|
|
|
|
|
|
979
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes((ccs_indx()), @nnzOut) |
980
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
981
|
|
|
|
|
|
|
|
982
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
983
|
|
|
|
|
|
|
## |
984
|
|
|
|
|
|
|
##-- guts |
985
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_maximum_nz_ind_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
986
|
|
|
|
|
|
|
## |
987
|
|
|
|
|
|
|
##-- auto-trim |
988
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
989
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
990
|
|
|
|
|
|
|
## |
991
|
|
|
|
|
|
|
##-- return |
992
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
993
|
|
|
|
|
|
|
} |
994
|
|
|
|
|
|
|
|
995
|
|
|
|
|
|
|
|
996
|
|
|
|
|
|
|
*ccs_accum_maximum_nz_ind = \&PDL::ccs_accum_maximum_nz_ind; |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
|
999
|
|
|
|
|
|
|
|
1000
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
=head2 ccs_accum_minimum_nz_ind |
1003
|
|
|
|
|
|
|
|
1004
|
|
|
|
|
|
|
=for sig |
1005
|
|
|
|
|
|
|
|
1006
|
|
|
|
|
|
|
Signature: ( |
1007
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
1008
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
1009
|
|
|
|
|
|
|
missing(); |
1010
|
|
|
|
|
|
|
indx N(); |
1011
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
1012
|
|
|
|
|
|
|
indx [o]nzvalsOut(NnzOut); |
1013
|
|
|
|
|
|
|
indx [o]nOut(); |
1014
|
|
|
|
|
|
|
) |
1015
|
|
|
|
|
|
|
|
1016
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
Accumulated minimum_nz_ind over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
1018
|
|
|
|
|
|
|
On return, |
1019
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
1020
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
1021
|
|
|
|
|
|
|
and |
1022
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
1023
|
|
|
|
|
|
|
|
1024
|
|
|
|
|
|
|
|
1025
|
|
|
|
|
|
|
Output indices index $nzvalsIn, -1 indicates that the missing value is minimal. |
1026
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
|
1028
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
1030
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
1032
|
|
|
|
|
|
|
|
1033
|
|
|
|
|
|
|
|
1034
|
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
=for bad |
1036
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
ccs_accum_minimum_nz_ind processes bad values. |
1038
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
1039
|
|
|
|
|
|
|
|
1040
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
=cut |
1042
|
|
|
|
|
|
|
|
1043
|
|
|
|
|
|
|
|
1044
|
|
|
|
|
|
|
|
1045
|
|
|
|
|
|
|
|
1046
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
sub PDL::ccs_accum_minimum_nz_ind { |
1048
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
1049
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
1050
|
0
|
|
|
|
|
|
my (@nnzOut); |
1051
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
1052
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
1053
|
0
|
|
|
|
|
|
shift(@nnzOut); |
1054
|
|
|
|
|
|
|
} |
1055
|
|
|
|
|
|
|
|
1056
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
1057
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
1058
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
1059
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
1060
|
|
|
|
|
|
|
|
1061
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes((ccs_indx()), @nnzOut) |
1062
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
1063
|
|
|
|
|
|
|
|
1064
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
1065
|
|
|
|
|
|
|
## |
1066
|
|
|
|
|
|
|
##-- guts |
1067
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_minimum_nz_ind_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
1068
|
|
|
|
|
|
|
## |
1069
|
|
|
|
|
|
|
##-- auto-trim |
1070
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
1071
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
1072
|
|
|
|
|
|
|
## |
1073
|
|
|
|
|
|
|
##-- return |
1074
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
1075
|
|
|
|
|
|
|
} |
1076
|
|
|
|
|
|
|
|
1077
|
|
|
|
|
|
|
|
1078
|
|
|
|
|
|
|
*ccs_accum_minimum_nz_ind = \&PDL::ccs_accum_minimum_nz_ind; |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
|
1081
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
|
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
=head2 ccs_accum_nbad |
1085
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
=for sig |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
Signature: ( |
1089
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
1090
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
1091
|
|
|
|
|
|
|
missing(); |
1092
|
|
|
|
|
|
|
indx N(); |
1093
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
1094
|
|
|
|
|
|
|
int+ [o]nzvalsOut(NnzOut); |
1095
|
|
|
|
|
|
|
indx [o]nOut(); |
1096
|
|
|
|
|
|
|
) |
1097
|
|
|
|
|
|
|
|
1098
|
|
|
|
|
|
|
|
1099
|
|
|
|
|
|
|
Accumulated number of bad values over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
1100
|
|
|
|
|
|
|
On return, |
1101
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
1102
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
1103
|
|
|
|
|
|
|
and |
1104
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
1105
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
Should handle missing values appropriately. |
1108
|
|
|
|
|
|
|
|
1109
|
|
|
|
|
|
|
|
1110
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
1112
|
|
|
|
|
|
|
|
1113
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
1114
|
|
|
|
|
|
|
|
1115
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
|
1117
|
|
|
|
|
|
|
=for bad |
1118
|
|
|
|
|
|
|
|
1119
|
|
|
|
|
|
|
ccs_accum_nbad processes bad values. |
1120
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
|
1123
|
|
|
|
|
|
|
=cut |
1124
|
|
|
|
|
|
|
|
1125
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
|
1127
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
|
1129
|
|
|
|
|
|
|
sub PDL::ccs_accum_nbad { |
1130
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
1131
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
1132
|
0
|
|
|
|
|
|
my (@nnzOut); |
1133
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
1134
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
1135
|
0
|
|
|
|
|
|
shift(@nnzOut); |
1136
|
|
|
|
|
|
|
} |
1137
|
|
|
|
|
|
|
|
1138
|
0
|
0
|
|
|
|
|
$nzvalsIn = ccs_indx($nzvalsIn) if ($nzvalsIn->type > ccs_indx()); ##-- max_type_perl=ccs_indx |
1139
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
1140
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
1141
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
1142
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
1143
|
|
|
|
|
|
|
|
1144
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) |
1145
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
1146
|
|
|
|
|
|
|
|
1147
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
1148
|
|
|
|
|
|
|
## |
1149
|
|
|
|
|
|
|
##-- guts |
1150
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_nbad_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
1151
|
|
|
|
|
|
|
## |
1152
|
|
|
|
|
|
|
##-- auto-trim |
1153
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
1154
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
1155
|
|
|
|
|
|
|
## |
1156
|
|
|
|
|
|
|
##-- return |
1157
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
1158
|
|
|
|
|
|
|
} |
1159
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
|
1161
|
|
|
|
|
|
|
*ccs_accum_nbad = \&PDL::ccs_accum_nbad; |
1162
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
|
1164
|
|
|
|
|
|
|
|
1165
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
|
1167
|
|
|
|
|
|
|
=head2 ccs_accum_ngood |
1168
|
|
|
|
|
|
|
|
1169
|
|
|
|
|
|
|
=for sig |
1170
|
|
|
|
|
|
|
|
1171
|
|
|
|
|
|
|
Signature: ( |
1172
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
1173
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
1174
|
|
|
|
|
|
|
missing(); |
1175
|
|
|
|
|
|
|
indx N(); |
1176
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
1177
|
|
|
|
|
|
|
int+ [o]nzvalsOut(NnzOut); |
1178
|
|
|
|
|
|
|
indx [o]nOut(); |
1179
|
|
|
|
|
|
|
) |
1180
|
|
|
|
|
|
|
|
1181
|
|
|
|
|
|
|
|
1182
|
|
|
|
|
|
|
Accumulated number of good values over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
1183
|
|
|
|
|
|
|
On return, |
1184
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
1185
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
1186
|
|
|
|
|
|
|
and |
1187
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
1188
|
|
|
|
|
|
|
|
1189
|
|
|
|
|
|
|
|
1190
|
|
|
|
|
|
|
Should handle missing values appropriately. |
1191
|
|
|
|
|
|
|
|
1192
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
|
1194
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
1195
|
|
|
|
|
|
|
|
1196
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
1197
|
|
|
|
|
|
|
|
1198
|
|
|
|
|
|
|
|
1199
|
|
|
|
|
|
|
|
1200
|
|
|
|
|
|
|
=for bad |
1201
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
ccs_accum_ngood processes bad values. |
1203
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
1204
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
|
1206
|
|
|
|
|
|
|
=cut |
1207
|
|
|
|
|
|
|
|
1208
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
|
1210
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
|
1212
|
|
|
|
|
|
|
sub PDL::ccs_accum_ngood { |
1213
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
1214
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
1215
|
0
|
|
|
|
|
|
my (@nnzOut); |
1216
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
1217
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
1218
|
0
|
|
|
|
|
|
shift(@nnzOut); |
1219
|
|
|
|
|
|
|
} |
1220
|
|
|
|
|
|
|
|
1221
|
0
|
0
|
|
|
|
|
$nzvalsIn = ccs_indx($nzvalsIn) if ($nzvalsIn->type > ccs_indx()); ##-- max_type_perl=ccs_indx |
1222
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
1223
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
1224
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
1225
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
1226
|
|
|
|
|
|
|
|
1227
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) |
1228
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
1229
|
|
|
|
|
|
|
|
1230
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
1231
|
|
|
|
|
|
|
## |
1232
|
|
|
|
|
|
|
##-- guts |
1233
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_ngood_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
1234
|
|
|
|
|
|
|
## |
1235
|
|
|
|
|
|
|
##-- auto-trim |
1236
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
1237
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
1238
|
|
|
|
|
|
|
## |
1239
|
|
|
|
|
|
|
##-- return |
1240
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
1241
|
|
|
|
|
|
|
} |
1242
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
|
1244
|
|
|
|
|
|
|
*ccs_accum_ngood = \&PDL::ccs_accum_ngood; |
1245
|
|
|
|
|
|
|
|
1246
|
|
|
|
|
|
|
|
1247
|
|
|
|
|
|
|
|
1248
|
|
|
|
|
|
|
|
1249
|
|
|
|
|
|
|
|
1250
|
|
|
|
|
|
|
=head2 ccs_accum_nnz |
1251
|
|
|
|
|
|
|
|
1252
|
|
|
|
|
|
|
=for sig |
1253
|
|
|
|
|
|
|
|
1254
|
|
|
|
|
|
|
Signature: ( |
1255
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
1256
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
1257
|
|
|
|
|
|
|
missing(); |
1258
|
|
|
|
|
|
|
indx N(); |
1259
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
1260
|
|
|
|
|
|
|
int+ [o]nzvalsOut(NnzOut); |
1261
|
|
|
|
|
|
|
indx [o]nOut(); |
1262
|
|
|
|
|
|
|
) |
1263
|
|
|
|
|
|
|
|
1264
|
|
|
|
|
|
|
|
1265
|
|
|
|
|
|
|
Accumulated number of non-zero values over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
1266
|
|
|
|
|
|
|
On return, |
1267
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
1268
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
1269
|
|
|
|
|
|
|
and |
1270
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
1271
|
|
|
|
|
|
|
|
1272
|
|
|
|
|
|
|
|
1273
|
|
|
|
|
|
|
Should handle missing values appropriately. |
1274
|
|
|
|
|
|
|
|
1275
|
|
|
|
|
|
|
|
1276
|
|
|
|
|
|
|
|
1277
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
1278
|
|
|
|
|
|
|
|
1279
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
1280
|
|
|
|
|
|
|
|
1281
|
|
|
|
|
|
|
|
1282
|
|
|
|
|
|
|
|
1283
|
|
|
|
|
|
|
=for bad |
1284
|
|
|
|
|
|
|
|
1285
|
|
|
|
|
|
|
ccs_accum_nnz processes bad values. |
1286
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
1287
|
|
|
|
|
|
|
|
1288
|
|
|
|
|
|
|
|
1289
|
|
|
|
|
|
|
=cut |
1290
|
|
|
|
|
|
|
|
1291
|
|
|
|
|
|
|
|
1292
|
|
|
|
|
|
|
|
1293
|
|
|
|
|
|
|
|
1294
|
|
|
|
|
|
|
|
1295
|
|
|
|
|
|
|
sub PDL::ccs_accum_nnz { |
1296
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
1297
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
1298
|
0
|
|
|
|
|
|
my (@nnzOut); |
1299
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
1300
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
1301
|
0
|
|
|
|
|
|
shift(@nnzOut); |
1302
|
|
|
|
|
|
|
} |
1303
|
|
|
|
|
|
|
|
1304
|
0
|
0
|
|
|
|
|
$nzvalsIn = ccs_indx($nzvalsIn) if ($nzvalsIn->type > ccs_indx()); ##-- max_type_perl=ccs_indx |
1305
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
1306
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
1307
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
1308
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
1309
|
|
|
|
|
|
|
|
1310
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) |
1311
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
1312
|
|
|
|
|
|
|
|
1313
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
1314
|
|
|
|
|
|
|
## |
1315
|
|
|
|
|
|
|
##-- guts |
1316
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_nnz_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
1317
|
|
|
|
|
|
|
## |
1318
|
|
|
|
|
|
|
##-- auto-trim |
1319
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
1320
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
1321
|
|
|
|
|
|
|
## |
1322
|
|
|
|
|
|
|
##-- return |
1323
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
1324
|
|
|
|
|
|
|
} |
1325
|
|
|
|
|
|
|
|
1326
|
|
|
|
|
|
|
|
1327
|
|
|
|
|
|
|
*ccs_accum_nnz = \&PDL::ccs_accum_nnz; |
1328
|
|
|
|
|
|
|
|
1329
|
|
|
|
|
|
|
|
1330
|
|
|
|
|
|
|
|
1331
|
|
|
|
|
|
|
|
1332
|
|
|
|
|
|
|
|
1333
|
|
|
|
|
|
|
=head2 ccs_accum_average |
1334
|
|
|
|
|
|
|
|
1335
|
|
|
|
|
|
|
=for sig |
1336
|
|
|
|
|
|
|
|
1337
|
|
|
|
|
|
|
Signature: ( |
1338
|
|
|
|
|
|
|
indx ixIn(Ndims,NnzIn); |
1339
|
|
|
|
|
|
|
nzvalsIn(NnzIn); |
1340
|
|
|
|
|
|
|
missing(); |
1341
|
|
|
|
|
|
|
indx N(); |
1342
|
|
|
|
|
|
|
indx [o]ixOut(Ndims,NnzOut); |
1343
|
|
|
|
|
|
|
float+ [o]nzvalsOut(NnzOut); |
1344
|
|
|
|
|
|
|
indx [o]nOut(); |
1345
|
|
|
|
|
|
|
) |
1346
|
|
|
|
|
|
|
|
1347
|
|
|
|
|
|
|
|
1348
|
|
|
|
|
|
|
Accumulated average over values $nzvalsIn() associated with vector-valued keys $ixIn(). |
1349
|
|
|
|
|
|
|
On return, |
1350
|
|
|
|
|
|
|
$ixOut() holds the unique non-"missing" values of $ixIn(), |
1351
|
|
|
|
|
|
|
$nzvalsOut() holds the associated values, |
1352
|
|
|
|
|
|
|
and |
1353
|
|
|
|
|
|
|
$nOut() stores the number of unique non-missing values computed. |
1354
|
|
|
|
|
|
|
|
1355
|
|
|
|
|
|
|
|
1356
|
|
|
|
|
|
|
If $N() is specified and greater than zero, then the quantity: |
1357
|
|
|
|
|
|
|
|
1358
|
|
|
|
|
|
|
$missing * ($N - (rlevec($ixIn))[0]) / $N |
1359
|
|
|
|
|
|
|
|
1360
|
|
|
|
|
|
|
is added to $nzvalsOut: this is probably What You Want if you are averaging over a virtual |
1361
|
|
|
|
|
|
|
dimension in a sparse index-encoded PDL (see PDL::CCS::Nd for a wrapper class). |
1362
|
|
|
|
|
|
|
|
1363
|
|
|
|
|
|
|
|
1364
|
|
|
|
|
|
|
|
1365
|
|
|
|
|
|
|
Returned PDLs are implicitly sliced such that NnzOut==$nOut(). |
1366
|
|
|
|
|
|
|
|
1367
|
|
|
|
|
|
|
In scalar context, returns only $nzvalsOut(). |
1368
|
|
|
|
|
|
|
|
1369
|
|
|
|
|
|
|
|
1370
|
|
|
|
|
|
|
|
1371
|
|
|
|
|
|
|
=for bad |
1372
|
|
|
|
|
|
|
|
1373
|
|
|
|
|
|
|
ccs_accum_average processes bad values. |
1374
|
|
|
|
|
|
|
The state of the bad-value flag of the output piddles is unknown. |
1375
|
|
|
|
|
|
|
|
1376
|
|
|
|
|
|
|
|
1377
|
|
|
|
|
|
|
=cut |
1378
|
|
|
|
|
|
|
|
1379
|
|
|
|
|
|
|
|
1380
|
|
|
|
|
|
|
|
1381
|
|
|
|
|
|
|
|
1382
|
|
|
|
|
|
|
|
1383
|
|
|
|
|
|
|
sub PDL::ccs_accum_average { |
1384
|
0
|
|
|
0
|
0
|
|
my ($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut) = @_; |
1385
|
0
|
|
|
|
|
|
my ($ndims,@nnzIn) = $ixIn->dims; |
1386
|
0
|
|
|
|
|
|
my (@nnzOut); |
1387
|
0
|
0
|
|
|
|
|
if (defined($ixOut)) { |
1388
|
0
|
|
|
|
|
|
@nnzOut = $ixOut->dims; |
1389
|
0
|
|
|
|
|
|
shift(@nnzOut); |
1390
|
|
|
|
|
|
|
} |
1391
|
|
|
|
|
|
|
|
1392
|
0
|
0
|
0
|
|
|
|
@nnzOut = $nzvalsOut->dims if (!@nnzOut && defined($nzvalsOut) && !$nzvalsOut->isempty); |
|
|
|
0
|
|
|
|
|
1393
|
0
|
0
|
|
|
|
|
@nnzOut = @nnzIn if (!@nnzOut); |
1394
|
0
|
0
|
0
|
|
|
|
$ixOut = PDL->zeroes(ccs_indx(), $ndims,@nnzOut) |
1395
|
|
|
|
|
|
|
if (!defined($ixOut) || $ixOut->isempty); |
1396
|
|
|
|
|
|
|
|
1397
|
0
|
0
|
0
|
|
|
|
$nzvalsOut = PDL->zeroes(($nzvalsIn->type), @nnzOut) |
1398
|
|
|
|
|
|
|
if (!defined($nzvalsOut) || $nzvalsOut->isempty); |
1399
|
|
|
|
|
|
|
|
1400
|
0
|
0
|
0
|
|
|
|
$nOut = PDL->pdl(ccs_indx(),0) if (!defined($nOut) || $nOut->isempty); |
1401
|
|
|
|
|
|
|
## |
1402
|
|
|
|
|
|
|
##-- guts |
1403
|
0
|
|
|
|
|
|
&PDL::_ccs_accum_average_int($ixIn,$nzvalsIn, $missing,$N, $ixOut,$nzvalsOut,$nOut); |
1404
|
|
|
|
|
|
|
## |
1405
|
|
|
|
|
|
|
##-- auto-trim |
1406
|
0
|
|
|
|
|
|
$ixOut = $ixOut->slice(",0:".($nOut->max-1)); |
1407
|
0
|
|
|
|
|
|
$nzvalsOut = $nzvalsOut->slice("0:".($nOut->max-1)); |
1408
|
|
|
|
|
|
|
## |
1409
|
|
|
|
|
|
|
##-- return |
1410
|
0
|
0
|
|
|
|
|
return wantarray ? ($ixOut,$nzvalsOut,$nOut) : $nzvalsOut; |
1411
|
|
|
|
|
|
|
} |
1412
|
|
|
|
|
|
|
|
1413
|
|
|
|
|
|
|
|
1414
|
|
|
|
|
|
|
*ccs_accum_average = \&PDL::ccs_accum_average; |
1415
|
|
|
|
|
|
|
|
1416
|
|
|
|
|
|
|
|
1417
|
|
|
|
|
|
|
|
1418
|
|
|
|
|
|
|
|
1419
|
|
|
|
|
|
|
=pod |
1420
|
|
|
|
|
|
|
|
1421
|
|
|
|
|
|
|
=head1 TODO / NOT YET IMPLEMENTED |
1422
|
|
|
|
|
|
|
|
1423
|
|
|
|
|
|
|
=over 4 |
1424
|
|
|
|
|
|
|
|
1425
|
|
|
|
|
|
|
=item extrema indices |
1426
|
|
|
|
|
|
|
|
1427
|
|
|
|
|
|
|
maximum_ind, minimum_ind: not quite compatible... |
1428
|
|
|
|
|
|
|
|
1429
|
|
|
|
|
|
|
=item statistical aggregates |
1430
|
|
|
|
|
|
|
|
1431
|
|
|
|
|
|
|
daverage, medover, oddmedover, pctover, ... |
1432
|
|
|
|
|
|
|
|
1433
|
|
|
|
|
|
|
=item cumulative functions |
1434
|
|
|
|
|
|
|
|
1435
|
|
|
|
|
|
|
cumusumover, cumuprodover, ... |
1436
|
|
|
|
|
|
|
|
1437
|
|
|
|
|
|
|
=item other stuff |
1438
|
|
|
|
|
|
|
|
1439
|
|
|
|
|
|
|
zcover, intover, minmaximum |
1440
|
|
|
|
|
|
|
|
1441
|
|
|
|
|
|
|
=back |
1442
|
|
|
|
|
|
|
|
1443
|
|
|
|
|
|
|
=cut |
1444
|
|
|
|
|
|
|
|
1445
|
|
|
|
|
|
|
|
1446
|
|
|
|
|
|
|
|
1447
|
|
|
|
|
|
|
|
1448
|
|
|
|
|
|
|
##--------------------------------------------------------------------- |
1449
|
|
|
|
|
|
|
=pod |
1450
|
|
|
|
|
|
|
|
1451
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
1452
|
|
|
|
|
|
|
|
1453
|
|
|
|
|
|
|
Perl by Larry Wall. |
1454
|
|
|
|
|
|
|
|
1455
|
|
|
|
|
|
|
PDL by Karl Glazebrook, Tuomas J. Lukka, Christian Soeller, and others. |
1456
|
|
|
|
|
|
|
|
1457
|
|
|
|
|
|
|
=cut |
1458
|
|
|
|
|
|
|
|
1459
|
|
|
|
|
|
|
##---------------------------------------------------------------------- |
1460
|
|
|
|
|
|
|
=pod |
1461
|
|
|
|
|
|
|
|
1462
|
|
|
|
|
|
|
=head1 KNOWN BUGS |
1463
|
|
|
|
|
|
|
|
1464
|
|
|
|
|
|
|
Probably many. |
1465
|
|
|
|
|
|
|
|
1466
|
|
|
|
|
|
|
=cut |
1467
|
|
|
|
|
|
|
|
1468
|
|
|
|
|
|
|
|
1469
|
|
|
|
|
|
|
##--------------------------------------------------------------------- |
1470
|
|
|
|
|
|
|
=pod |
1471
|
|
|
|
|
|
|
|
1472
|
|
|
|
|
|
|
=head1 AUTHOR |
1473
|
|
|
|
|
|
|
|
1474
|
|
|
|
|
|
|
Bryan Jurish Emoocow@cpan.orgE |
1475
|
|
|
|
|
|
|
|
1476
|
|
|
|
|
|
|
=head2 Copyright Policy |
1477
|
|
|
|
|
|
|
|
1478
|
|
|
|
|
|
|
Copyright (C) 2007-2013, Bryan Jurish. All rights reserved. |
1479
|
|
|
|
|
|
|
|
1480
|
|
|
|
|
|
|
This package is free software, and entirely without warranty. |
1481
|
|
|
|
|
|
|
You may redistribute it and/or modify it under the same terms |
1482
|
|
|
|
|
|
|
as Perl itself. |
1483
|
|
|
|
|
|
|
|
1484
|
|
|
|
|
|
|
=head1 SEE ALSO |
1485
|
|
|
|
|
|
|
|
1486
|
|
|
|
|
|
|
perl(1), PDL(3perl) |
1487
|
|
|
|
|
|
|
|
1488
|
|
|
|
|
|
|
=cut |
1489
|
|
|
|
|
|
|
|
1490
|
|
|
|
|
|
|
|
1491
|
|
|
|
|
|
|
|
1492
|
|
|
|
|
|
|
; |
1493
|
|
|
|
|
|
|
|
1494
|
|
|
|
|
|
|
|
1495
|
|
|
|
|
|
|
|
1496
|
|
|
|
|
|
|
# Exit with OK status |
1497
|
|
|
|
|
|
|
|
1498
|
|
|
|
|
|
|
1; |
1499
|
|
|
|
|
|
|
|
1500
|
|
|
|
|
|
|
|