| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# GENERATED WITH PDL::PP from lib/PDL/Ufunc.pd! Don't modify! |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
package PDL::Ufunc; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our @EXPORT_OK = qw(prodover dprodover cumuprodover dcumuprodover sumover dsumover cumusumover dcumusumover andover bandover borover bxorover firstnonzeroover orover xorover zcover numdiff diffcentred partial diff2 intover average avgover caverage cavgover daverage davgover minimum minover minimum_ind minover_ind minimum_n_ind minover_n_ind maximum maxover maximum_ind maxover_ind maximum_n_ind maxover_n_ind minmaximum minmaxover avg sum prod davg dsum dprod zcheck and band or bor xorall bxor min max median mode oddmedian any all minmax medover oddmedover modeover pctover oddpctover pct oddpct qsort qsorti qsortvec qsortveci magnover ); |
|
7
|
|
|
|
|
|
|
our %EXPORT_TAGS = (Func=>\@EXPORT_OK); |
|
8
|
|
|
|
|
|
|
|
|
9
|
70
|
|
|
70
|
|
470
|
use PDL::Core; |
|
|
70
|
|
|
|
|
159
|
|
|
|
70
|
|
|
|
|
528
|
|
|
10
|
70
|
|
|
70
|
|
526
|
use PDL::Exporter; |
|
|
70
|
|
|
|
|
186
|
|
|
|
70
|
|
|
|
|
504
|
|
|
11
|
70
|
|
|
70
|
|
367
|
use DynaLoader; |
|
|
70
|
|
|
|
|
127
|
|
|
|
70
|
|
|
|
|
34574
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @ISA = ( 'PDL::Exporter','DynaLoader' ); |
|
16
|
|
|
|
|
|
|
push @PDL::Core::PP, __PACKAGE__; |
|
17
|
|
|
|
|
|
|
bootstrap PDL::Ufunc ; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#line 9 "lib/PDL/Ufunc.pd" |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use strict; |
|
29
|
|
|
|
|
|
|
use warnings; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=encoding utf8 |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
PDL::Ufunc - primitive ufunc operations for pdl |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This module provides some primitive and useful functions defined |
|
40
|
|
|
|
|
|
|
using PDL::PP based on functionality of what are sometimes called |
|
41
|
|
|
|
|
|
|
I (for example NumPY and Mathematica talk about these). |
|
42
|
|
|
|
|
|
|
It collects all the functions generally used to C or |
|
43
|
|
|
|
|
|
|
C along a dimension. These all do their job across the |
|
44
|
|
|
|
|
|
|
first dimension but by using the slicing functions you can do it |
|
45
|
|
|
|
|
|
|
on any dimension. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
The L module provides an alternative interface |
|
48
|
|
|
|
|
|
|
to many of the functions in this module. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
use PDL::Ufunc; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
use PDL::Slices; |
|
57
|
|
|
|
|
|
|
use Carp; |
|
58
|
|
|
|
|
|
|
#line 59 "lib/PDL/Ufunc.pm" |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 prodover |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=for sig |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Signature: (a(n); int+ [o]b()) |
|
75
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
76
|
|
|
|
|
|
|
float double ldouble cfloat cdouble cldouble) |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=for usage |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$b = prodover($a); |
|
81
|
|
|
|
|
|
|
prodover($a, $b); # all arguments given |
|
82
|
|
|
|
|
|
|
$b = $a->prodover; # method call |
|
83
|
|
|
|
|
|
|
$a->prodover($b); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=for ref |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Project via product to N-1 dimensions |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
90
|
|
|
|
|
|
|
by one by taking the product along the 1st dimension. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
93
|
|
|
|
|
|
|
I dimension. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=pod |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=for bad |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
C processes bad values. |
|
102
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
*prodover = \&PDL::prodover; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 dprodover |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=for sig |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Signature: (a(n); double [o]b()) |
|
121
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
122
|
|
|
|
|
|
|
float double ldouble) |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=for usage |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
$b = dprodover($a); |
|
127
|
|
|
|
|
|
|
dprodover($a, $b); # all arguments given |
|
128
|
|
|
|
|
|
|
$b = $a->dprodover; # method call |
|
129
|
|
|
|
|
|
|
$a->dprodover($b); |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=for ref |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Project via product to N-1 dimensions |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
136
|
|
|
|
|
|
|
by one by taking the product along the 1st dimension. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
139
|
|
|
|
|
|
|
I dimension. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Unlike L, the calculations are performed in double precision. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=pod |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=for bad |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
C processes bad values. |
|
150
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
*dprodover = \&PDL::dprodover; |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 cumuprodover |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=for sig |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Signature: (a(n); int+ [o]b(n)) |
|
169
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
170
|
|
|
|
|
|
|
float double ldouble cfloat cdouble cldouble) |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=for usage |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
$b = cumuprodover($a); |
|
175
|
|
|
|
|
|
|
cumuprodover($a, $b); # all arguments given |
|
176
|
|
|
|
|
|
|
$b = $a->cumuprodover; # method call |
|
177
|
|
|
|
|
|
|
$a->cumuprodover($b); |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=for ref |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Cumulative product |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This function calculates the cumulative product |
|
184
|
|
|
|
|
|
|
along the 1st dimension. |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
187
|
|
|
|
|
|
|
I dimension. |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
The sum is started so that the first element in the cumulative product |
|
190
|
|
|
|
|
|
|
is the first element of the parameter. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=pod |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=for bad |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
C processes bad values. |
|
199
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=cut |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
*cumuprodover = \&PDL::cumuprodover; |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head2 dcumuprodover |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=for sig |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Signature: (a(n); double [o]b(n)) |
|
218
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
219
|
|
|
|
|
|
|
float double ldouble) |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=for usage |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
$b = dcumuprodover($a); |
|
224
|
|
|
|
|
|
|
dcumuprodover($a, $b); # all arguments given |
|
225
|
|
|
|
|
|
|
$b = $a->dcumuprodover; # method call |
|
226
|
|
|
|
|
|
|
$a->dcumuprodover($b); |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=for ref |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Cumulative product |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
This function calculates the cumulative product |
|
233
|
|
|
|
|
|
|
along the 1st dimension. |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
236
|
|
|
|
|
|
|
I dimension. |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
The sum is started so that the first element in the cumulative product |
|
239
|
|
|
|
|
|
|
is the first element of the parameter. |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
Unlike L, the calculations are performed in double precision. |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=pod |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=for bad |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
C processes bad values. |
|
250
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=cut |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
*dcumuprodover = \&PDL::dcumuprodover; |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head2 sumover |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=for sig |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
Signature: (a(n); int+ [o]b()) |
|
269
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
270
|
|
|
|
|
|
|
float double ldouble cfloat cdouble cldouble) |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=for usage |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
$b = sumover($a); |
|
275
|
|
|
|
|
|
|
sumover($a, $b); # all arguments given |
|
276
|
|
|
|
|
|
|
$b = $a->sumover; # method call |
|
277
|
|
|
|
|
|
|
$a->sumover($b); |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=for ref |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
Project via sum to N-1 dimensions |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
284
|
|
|
|
|
|
|
by one by taking the sum along the 1st dimension. |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
287
|
|
|
|
|
|
|
I dimension. |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=pod |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=for bad |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
C processes bad values. |
|
296
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=cut |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
*sumover = \&PDL::sumover; |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=head2 dsumover |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=for sig |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
Signature: (a(n); double [o]b()) |
|
315
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
316
|
|
|
|
|
|
|
float double ldouble) |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=for usage |
|
319
|
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
$b = dsumover($a); |
|
321
|
|
|
|
|
|
|
dsumover($a, $b); # all arguments given |
|
322
|
|
|
|
|
|
|
$b = $a->dsumover; # method call |
|
323
|
|
|
|
|
|
|
$a->dsumover($b); |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=for ref |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
Project via sum to N-1 dimensions |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
330
|
|
|
|
|
|
|
by one by taking the sum along the 1st dimension. |
|
331
|
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
333
|
|
|
|
|
|
|
I dimension. |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
Unlike L, the calculations are performed in double precision. |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
=pod |
|
338
|
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
340
|
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=for bad |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
C processes bad values. |
|
344
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
345
|
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
=cut |
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
*dsumover = \&PDL::dsumover; |
|
352
|
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
=head2 cumusumover |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=for sig |
|
361
|
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
Signature: (a(n); int+ [o]b(n)) |
|
363
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
364
|
|
|
|
|
|
|
float double ldouble cfloat cdouble cldouble) |
|
365
|
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
=for usage |
|
367
|
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
$b = cumusumover($a); |
|
369
|
|
|
|
|
|
|
cumusumover($a, $b); # all arguments given |
|
370
|
|
|
|
|
|
|
$b = $a->cumusumover; # method call |
|
371
|
|
|
|
|
|
|
$a->cumusumover($b); |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
=for ref |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
Cumulative sum |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
This function calculates the cumulative sum |
|
378
|
|
|
|
|
|
|
along the 1st dimension. |
|
379
|
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
381
|
|
|
|
|
|
|
I dimension. |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
The sum is started so that the first element in the cumulative sum |
|
384
|
|
|
|
|
|
|
is the first element of the parameter. |
|
385
|
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
=pod |
|
387
|
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
389
|
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
=for bad |
|
391
|
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
C processes bad values. |
|
393
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
394
|
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
=cut |
|
396
|
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
*cumusumover = \&PDL::cumusumover; |
|
401
|
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
=head2 dcumusumover |
|
408
|
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
=for sig |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
Signature: (a(n); double [o]b(n)) |
|
412
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
413
|
|
|
|
|
|
|
float double ldouble) |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
=for usage |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
$b = dcumusumover($a); |
|
418
|
|
|
|
|
|
|
dcumusumover($a, $b); # all arguments given |
|
419
|
|
|
|
|
|
|
$b = $a->dcumusumover; # method call |
|
420
|
|
|
|
|
|
|
$a->dcumusumover($b); |
|
421
|
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
=for ref |
|
423
|
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
Cumulative sum |
|
425
|
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
This function calculates the cumulative sum |
|
427
|
|
|
|
|
|
|
along the 1st dimension. |
|
428
|
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
430
|
|
|
|
|
|
|
I dimension. |
|
431
|
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
The sum is started so that the first element in the cumulative sum |
|
433
|
|
|
|
|
|
|
is the first element of the parameter. |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
Unlike L, the calculations are performed in double precision. |
|
436
|
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
=pod |
|
438
|
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
440
|
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
=for bad |
|
442
|
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
C processes bad values. |
|
444
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
445
|
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
=cut |
|
447
|
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
*dcumusumover = \&PDL::dcumusumover; |
|
452
|
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
=head2 andover |
|
459
|
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
=for sig |
|
461
|
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
Signature: (a(n); [o] b()) |
|
463
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
464
|
|
|
|
|
|
|
float double ldouble cfloat cdouble cldouble) |
|
465
|
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
=for usage |
|
467
|
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
$b = andover($a); |
|
469
|
|
|
|
|
|
|
andover($a, $b); # all arguments given |
|
470
|
|
|
|
|
|
|
$b = $a->andover; # method call |
|
471
|
|
|
|
|
|
|
$a->andover($b); |
|
472
|
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
=for ref |
|
474
|
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
Project via logical and to N-1 dimensions |
|
476
|
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
478
|
|
|
|
|
|
|
by one by taking the logical and along the 1st dimension. |
|
479
|
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
481
|
|
|
|
|
|
|
I dimension. |
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
=pod |
|
484
|
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
486
|
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
=for bad |
|
488
|
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
If C contains only bad data (and its bad flag is set), |
|
490
|
|
|
|
|
|
|
C is set bad. Otherwise C will have its bad flag cleared, |
|
491
|
|
|
|
|
|
|
as it will not contain any bad values. |
|
492
|
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=cut |
|
494
|
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
*andover = \&PDL::andover; |
|
499
|
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
=head2 bandover |
|
506
|
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
=for sig |
|
508
|
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
Signature: (a(n); [o] b()) |
|
510
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong) |
|
511
|
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=for usage |
|
513
|
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
$b = bandover($a); |
|
515
|
|
|
|
|
|
|
bandover($a, $b); # all arguments given |
|
516
|
|
|
|
|
|
|
$b = $a->bandover; # method call |
|
517
|
|
|
|
|
|
|
$a->bandover($b); |
|
518
|
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
=for ref |
|
520
|
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
Project via bitwise and to N-1 dimensions |
|
522
|
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
524
|
|
|
|
|
|
|
by one by taking the bitwise and along the 1st dimension. |
|
525
|
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
527
|
|
|
|
|
|
|
I dimension. |
|
528
|
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
=pod |
|
530
|
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
532
|
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
=for bad |
|
534
|
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
If C contains only bad data (and its bad flag is set), |
|
536
|
|
|
|
|
|
|
C is set bad. Otherwise C will have its bad flag cleared, |
|
537
|
|
|
|
|
|
|
as it will not contain any bad values. |
|
538
|
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=cut |
|
540
|
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
*bandover = \&PDL::bandover; |
|
545
|
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
=head2 borover |
|
552
|
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
=for sig |
|
554
|
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
Signature: (a(n); [o] b()) |
|
556
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong) |
|
557
|
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
=for usage |
|
559
|
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
$b = borover($a); |
|
561
|
|
|
|
|
|
|
borover($a, $b); # all arguments given |
|
562
|
|
|
|
|
|
|
$b = $a->borover; # method call |
|
563
|
|
|
|
|
|
|
$a->borover($b); |
|
564
|
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
=for ref |
|
566
|
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
Project via bitwise or to N-1 dimensions |
|
568
|
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
570
|
|
|
|
|
|
|
by one by taking the bitwise or along the 1st dimension. |
|
571
|
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
573
|
|
|
|
|
|
|
I dimension. |
|
574
|
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
=pod |
|
576
|
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
578
|
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=for bad |
|
580
|
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
If C contains only bad data (and its bad flag is set), |
|
582
|
|
|
|
|
|
|
C is set bad. Otherwise C will have its bad flag cleared, |
|
583
|
|
|
|
|
|
|
as it will not contain any bad values. |
|
584
|
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
=cut |
|
586
|
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
*borover = \&PDL::borover; |
|
591
|
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=head2 bxorover |
|
598
|
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
=for sig |
|
600
|
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
Signature: (a(n); [o] b()) |
|
602
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong) |
|
603
|
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
=for usage |
|
605
|
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
$b = bxorover($a); |
|
607
|
|
|
|
|
|
|
bxorover($a, $b); # all arguments given |
|
608
|
|
|
|
|
|
|
$b = $a->bxorover; # method call |
|
609
|
|
|
|
|
|
|
$a->bxorover($b); |
|
610
|
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
=for ref |
|
612
|
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
Project via bitwise xor to N-1 dimensions |
|
614
|
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
616
|
|
|
|
|
|
|
by one by taking the bitwise xor along the 1st dimension. |
|
617
|
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
619
|
|
|
|
|
|
|
I dimension. |
|
620
|
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
=pod |
|
622
|
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
624
|
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
=for bad |
|
626
|
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
If C contains only bad data (and its bad flag is set), |
|
628
|
|
|
|
|
|
|
C is set bad. Otherwise C will have its bad flag cleared, |
|
629
|
|
|
|
|
|
|
as it will not contain any bad values. |
|
630
|
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
=cut |
|
632
|
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
*bxorover = \&PDL::bxorover; |
|
637
|
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
=head2 firstnonzeroover |
|
644
|
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
=for sig |
|
646
|
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
Signature: (a(n); [o] b()) |
|
648
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
649
|
|
|
|
|
|
|
float double ldouble cfloat cdouble cldouble) |
|
650
|
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
=for usage |
|
652
|
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
$b = firstnonzeroover($a); |
|
654
|
|
|
|
|
|
|
firstnonzeroover($a, $b); # all arguments given |
|
655
|
|
|
|
|
|
|
$b = $a->firstnonzeroover; # method call |
|
656
|
|
|
|
|
|
|
$a->firstnonzeroover($b); |
|
657
|
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
=for ref |
|
659
|
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
Project via first non-zero value to N-1 dimensions |
|
661
|
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
663
|
|
|
|
|
|
|
by one by taking the first non-zero value along the 1st dimension. |
|
664
|
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
666
|
|
|
|
|
|
|
I dimension. |
|
667
|
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
=pod |
|
669
|
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
671
|
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
=for bad |
|
673
|
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
If C contains only bad data (and its bad flag is set), |
|
675
|
|
|
|
|
|
|
C is set bad. Otherwise C will have its bad flag cleared, |
|
676
|
|
|
|
|
|
|
as it will not contain any bad values. |
|
677
|
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
=cut |
|
679
|
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
*firstnonzeroover = \&PDL::firstnonzeroover; |
|
684
|
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
=head2 orover |
|
691
|
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
=for sig |
|
693
|
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
Signature: (a(n); [o] b()) |
|
695
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
696
|
|
|
|
|
|
|
float double ldouble cfloat cdouble cldouble) |
|
697
|
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
=for usage |
|
699
|
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
$b = orover($a); |
|
701
|
|
|
|
|
|
|
orover($a, $b); # all arguments given |
|
702
|
|
|
|
|
|
|
$b = $a->orover; # method call |
|
703
|
|
|
|
|
|
|
$a->orover($b); |
|
704
|
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
=for ref |
|
706
|
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
Project via logical or to N-1 dimensions |
|
708
|
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
710
|
|
|
|
|
|
|
by one by taking the logical or along the 1st dimension. |
|
711
|
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
713
|
|
|
|
|
|
|
I dimension. |
|
714
|
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
=pod |
|
716
|
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
718
|
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
=for bad |
|
720
|
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
If C contains only bad data (and its bad flag is set), |
|
722
|
|
|
|
|
|
|
C is set bad. Otherwise C will have its bad flag cleared, |
|
723
|
|
|
|
|
|
|
as it will not contain any bad values. |
|
724
|
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
=cut |
|
726
|
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
*orover = \&PDL::orover; |
|
731
|
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
|
|
733
|
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
=head2 xorover |
|
738
|
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
=for sig |
|
740
|
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
Signature: (a(n); [o] b()) |
|
742
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
743
|
|
|
|
|
|
|
float double ldouble cfloat cdouble cldouble) |
|
744
|
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
=for usage |
|
746
|
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
$b = xorover($a); |
|
748
|
|
|
|
|
|
|
xorover($a, $b); # all arguments given |
|
749
|
|
|
|
|
|
|
$b = $a->xorover; # method call |
|
750
|
|
|
|
|
|
|
$a->xorover($b); |
|
751
|
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
=for ref |
|
753
|
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
Project via logical xor to N-1 dimensions |
|
755
|
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
757
|
|
|
|
|
|
|
by one by taking the logical xor along the 1st dimension. |
|
758
|
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
760
|
|
|
|
|
|
|
I dimension. |
|
761
|
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
=pod |
|
763
|
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
765
|
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
=for bad |
|
767
|
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
If C contains only bad data (and its bad flag is set), |
|
769
|
|
|
|
|
|
|
C is set bad. Otherwise C will have its bad flag cleared, |
|
770
|
|
|
|
|
|
|
as it will not contain any bad values. |
|
771
|
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
=cut |
|
773
|
|
|
|
|
|
|
|
|
774
|
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
*xorover = \&PDL::xorover; |
|
778
|
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
=head2 zcover |
|
785
|
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
=for sig |
|
787
|
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
Signature: (a(n); [o] b()) |
|
789
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
790
|
|
|
|
|
|
|
float double ldouble cfloat cdouble cldouble) |
|
791
|
|
|
|
|
|
|
|
|
792
|
|
|
|
|
|
|
=for usage |
|
793
|
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
$b = zcover($a); |
|
795
|
|
|
|
|
|
|
zcover($a, $b); # all arguments given |
|
796
|
|
|
|
|
|
|
$b = $a->zcover; # method call |
|
797
|
|
|
|
|
|
|
$a->zcover($b); |
|
798
|
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
=for ref |
|
800
|
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
Project via == 0 to N-1 dimensions |
|
802
|
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
804
|
|
|
|
|
|
|
by one by taking the == 0 along the 1st dimension. |
|
805
|
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
807
|
|
|
|
|
|
|
I dimension. |
|
808
|
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
=pod |
|
810
|
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
812
|
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
=for bad |
|
814
|
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
If C contains only bad data (and its bad flag is set), |
|
816
|
|
|
|
|
|
|
C is set bad. Otherwise C will have its bad flag cleared, |
|
817
|
|
|
|
|
|
|
as it will not contain any bad values. |
|
818
|
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
=cut |
|
820
|
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
*zcover = \&PDL::zcover; |
|
825
|
|
|
|
|
|
|
|
|
826
|
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
|
|
828
|
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
=head2 numdiff |
|
832
|
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
=for sig |
|
834
|
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
Signature: (x(t); [o]dx(t)) |
|
836
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
837
|
|
|
|
|
|
|
float double ldouble cfloat cdouble cldouble) |
|
838
|
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
=for usage |
|
840
|
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
$dx = numdiff($x); |
|
842
|
|
|
|
|
|
|
numdiff($x, $dx); # all arguments given |
|
843
|
|
|
|
|
|
|
$dx = $x->numdiff; # method call |
|
844
|
|
|
|
|
|
|
$x->numdiff($dx); |
|
845
|
|
|
|
|
|
|
$x->inplace->numdiff; # can be used inplace |
|
846
|
|
|
|
|
|
|
numdiff($x->inplace); |
|
847
|
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
=for ref |
|
849
|
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
Numerical differencing. DX(t) = X(t) - X(t-1), DX(0) = X(0). |
|
851
|
|
|
|
|
|
|
Combined with C, can be used for backward differencing. |
|
852
|
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
Unlike L, output vector is same length. |
|
854
|
|
|
|
|
|
|
Originally by Maggie J. Xiong. |
|
855
|
|
|
|
|
|
|
|
|
856
|
|
|
|
|
|
|
Compare to L, which acts as the converse of this. |
|
857
|
|
|
|
|
|
|
See also L, L, L, L. |
|
858
|
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
=pod |
|
860
|
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
862
|
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
=for bad |
|
864
|
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
C does not process bad values. |
|
866
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
867
|
|
|
|
|
|
|
|
|
868
|
|
|
|
|
|
|
=cut |
|
869
|
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
*numdiff = \&PDL::numdiff; |
|
874
|
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
|
|
876
|
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
|
|
880
|
|
|
|
|
|
|
=head2 diffcentred |
|
881
|
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
=for sig |
|
883
|
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
Signature: (a(n); [o]o(n)) |
|
885
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
886
|
|
|
|
|
|
|
float double ldouble cfloat cdouble cldouble) |
|
887
|
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
=for usage |
|
889
|
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
$o = diffcentred($a); |
|
891
|
|
|
|
|
|
|
diffcentred($a, $o); # all arguments given |
|
892
|
|
|
|
|
|
|
$o = $a->diffcentred; # method call |
|
893
|
|
|
|
|
|
|
$a->diffcentred($o); |
|
894
|
|
|
|
|
|
|
|
|
895
|
|
|
|
|
|
|
=for ref |
|
896
|
|
|
|
|
|
|
|
|
897
|
|
|
|
|
|
|
Calculates centred differences along a vector's 0th dimension. |
|
898
|
|
|
|
|
|
|
Always periodic on boundaries; currently to change this, you must |
|
899
|
|
|
|
|
|
|
pad your data, and/or trim afterwards. This is so that when using |
|
900
|
|
|
|
|
|
|
with L, the size of data stays the same and therefore |
|
901
|
|
|
|
|
|
|
compatible if differentiated along different dimensions, e.g. |
|
902
|
|
|
|
|
|
|
calculating "curl". |
|
903
|
|
|
|
|
|
|
|
|
904
|
|
|
|
|
|
|
By using L etc. it is possible to use I dimension. |
|
905
|
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
See also L, L, L, L. |
|
907
|
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
=pod |
|
909
|
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
911
|
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
=for bad |
|
913
|
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
A bad value at C means the affected output values at C,C |
|
915
|
|
|
|
|
|
|
(if in boounds) are set bad. |
|
916
|
|
|
|
|
|
|
|
|
917
|
|
|
|
|
|
|
=cut |
|
918
|
|
|
|
|
|
|
|
|
919
|
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
|
|
921
|
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
*diffcentred = \&PDL::diffcentred; |
|
923
|
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
|
|
925
|
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
|
|
927
|
|
|
|
|
|
|
|
|
928
|
|
|
|
|
|
|
#line 249 "lib/PDL/Ufunc.pd" |
|
929
|
|
|
|
|
|
|
|
|
930
|
|
|
|
|
|
|
=head2 partial |
|
931
|
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
=for ref |
|
933
|
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
Take a numerical partial derivative along a given dimension, either |
|
935
|
|
|
|
|
|
|
forward, backward, or centred. |
|
936
|
|
|
|
|
|
|
|
|
937
|
|
|
|
|
|
|
See also L, L, |
|
938
|
|
|
|
|
|
|
L, L, |
|
939
|
|
|
|
|
|
|
and L, which are currently used to implement this. |
|
940
|
|
|
|
|
|
|
|
|
941
|
|
|
|
|
|
|
Can be used to implement divergence and curl calculations (adapted |
|
942
|
|
|
|
|
|
|
from Luis Mochán's work at |
|
943
|
|
|
|
|
|
|
https://sourceforge.net/p/pdl/mailman/message/58843767/): |
|
944
|
|
|
|
|
|
|
|
|
945
|
|
|
|
|
|
|
use v5.36; |
|
946
|
|
|
|
|
|
|
use PDL; |
|
947
|
|
|
|
|
|
|
sub curl ($f) { |
|
948
|
|
|
|
|
|
|
my ($f0, $f1, $f2) = $f->using(0..2); |
|
949
|
|
|
|
|
|
|
my $o = {dir=>'c'}; |
|
950
|
|
|
|
|
|
|
pdl( |
|
951
|
|
|
|
|
|
|
$f2->partial(1,$o) - $f1->partial(2,$o), |
|
952
|
|
|
|
|
|
|
$f0->partial(2,$o) - $f2->partial(0,$o), |
|
953
|
|
|
|
|
|
|
$f1->partial(0,$o) - $f0->partial(1,$o), |
|
954
|
|
|
|
|
|
|
)->mv(-1,0); |
|
955
|
|
|
|
|
|
|
} |
|
956
|
|
|
|
|
|
|
sub div ($f) { |
|
957
|
|
|
|
|
|
|
my ($f0, $f1, $f2) = $f->using(0..2); |
|
958
|
|
|
|
|
|
|
my $o = {dir=>'c'}; |
|
959
|
|
|
|
|
|
|
$f0->partial(0,$o) + $f1->partial(1,$o) + $f2->partial(2,$o); |
|
960
|
|
|
|
|
|
|
} |
|
961
|
|
|
|
|
|
|
sub trim3d ($f) { $f->slice(':,1:-2,1:-2,1:-2') } # adjust if change "dir" |
|
962
|
|
|
|
|
|
|
my $z=zeroes(5,5,5); |
|
963
|
|
|
|
|
|
|
my $v=pdl(-$z->yvals, $z->xvals, $z->zvals)->mv(-1,0); |
|
964
|
|
|
|
|
|
|
say trim3d(curl($v)); |
|
965
|
|
|
|
|
|
|
say div($v); |
|
966
|
|
|
|
|
|
|
|
|
967
|
|
|
|
|
|
|
=for usage |
|
968
|
|
|
|
|
|
|
|
|
969
|
|
|
|
|
|
|
$pdl->partial(2); # along dim 2, centred |
|
970
|
|
|
|
|
|
|
$pdl->partial(2, {d=>'c'}); # along dim 2, centred |
|
971
|
|
|
|
|
|
|
$pdl->partial(2, {d=>'f'}); # along dim 2, forward |
|
972
|
|
|
|
|
|
|
$pdl->partial(2, {d=>'b'}); # along dim 2, backward |
|
973
|
|
|
|
|
|
|
$pdl->partial(2, {d=>'p'}); # along dim 2, piecewise cubic Hermite |
|
974
|
|
|
|
|
|
|
$pdl->partial(2, {d=>'s'}); # along dim 2, cubic spline |
|
975
|
|
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
=cut |
|
977
|
|
|
|
|
|
|
|
|
978
|
|
|
|
|
|
|
my %dirtype2func = ( |
|
979
|
|
|
|
|
|
|
f => \&numdiff, |
|
980
|
|
|
|
|
|
|
b => sub { $_[0]->slice('-1:0')->numdiff }, |
|
981
|
|
|
|
|
|
|
c => \&diffcentred, |
|
982
|
|
|
|
|
|
|
p => sub {(PDL::Primitive::pchip_chim($_[0]->xvals, $_[0]))[0]}, |
|
983
|
|
|
|
|
|
|
s => sub {(PDL::Primitive::pchip_chsp([0,0], [0,0], $_[0]->xvals, $_[0]))[0]}, |
|
984
|
|
|
|
|
|
|
); |
|
985
|
|
|
|
|
|
|
*partial = \&PDL::partial; |
|
986
|
|
|
|
|
|
|
sub PDL::partial { |
|
987
|
|
|
|
|
|
|
my ($f, $dim, $opts) = @_; |
|
988
|
|
|
|
|
|
|
$opts ||= {}; |
|
989
|
|
|
|
|
|
|
my $difftype = $opts->{dir} || $opts->{d} || 'c'; |
|
990
|
|
|
|
|
|
|
my $func = $dirtype2func{$difftype} || barf "partial: unknown 'dir' option '$difftype', only know (@{[sort keys %dirtype2func]})"; |
|
991
|
|
|
|
|
|
|
$f = $f->mv($dim, 0) if $dim; |
|
992
|
|
|
|
|
|
|
my $ret = $f->$func; |
|
993
|
|
|
|
|
|
|
$dim ? $ret->mv(0, $dim) : $ret; |
|
994
|
|
|
|
|
|
|
} |
|
995
|
|
|
|
|
|
|
#line 996 "lib/PDL/Ufunc.pm" |
|
996
|
|
|
|
|
|
|
|
|
997
|
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
=head2 diff2 |
|
999
|
|
|
|
|
|
|
|
|
1000
|
|
|
|
|
|
|
=for sig |
|
1001
|
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
Signature: (a(n); [o]o(nminus1=CALC($SIZE(n) - 1))) |
|
1003
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1004
|
|
|
|
|
|
|
float double ldouble cfloat cdouble cldouble) |
|
1005
|
|
|
|
|
|
|
|
|
1006
|
|
|
|
|
|
|
=for usage |
|
1007
|
|
|
|
|
|
|
|
|
1008
|
|
|
|
|
|
|
$o = diff2($a); |
|
1009
|
|
|
|
|
|
|
diff2($a, $o); # all arguments given |
|
1010
|
|
|
|
|
|
|
$o = $a->diff2; # method call |
|
1011
|
|
|
|
|
|
|
$a->diff2($o); |
|
1012
|
|
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
=for ref |
|
1014
|
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
Numerically forward differentiates a vector along 0th dimension. |
|
1016
|
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
By using L etc. it is possible to use I dimension. |
|
1018
|
|
|
|
|
|
|
Unlike L, output vector is one shorter. |
|
1019
|
|
|
|
|
|
|
Combined with C, can be used for backward differencing. |
|
1020
|
|
|
|
|
|
|
|
|
1021
|
|
|
|
|
|
|
See also L, L, L, L. |
|
1022
|
|
|
|
|
|
|
|
|
1023
|
|
|
|
|
|
|
=for example |
|
1024
|
|
|
|
|
|
|
|
|
1025
|
|
|
|
|
|
|
print pdl(q[3 4 2 3 2 3 1])->diff2; |
|
1026
|
|
|
|
|
|
|
# [1 -2 1 -1 1 -2] |
|
1027
|
|
|
|
|
|
|
|
|
1028
|
|
|
|
|
|
|
=pod |
|
1029
|
|
|
|
|
|
|
|
|
1030
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1031
|
|
|
|
|
|
|
|
|
1032
|
|
|
|
|
|
|
=for bad |
|
1033
|
|
|
|
|
|
|
|
|
1034
|
|
|
|
|
|
|
On bad value, output value is set bad. On next good value, output value |
|
1035
|
|
|
|
|
|
|
is difference between that and last good value. |
|
1036
|
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
=cut |
|
1038
|
|
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
|
|
1040
|
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
|
|
1042
|
|
|
|
|
|
|
*diff2 = \&PDL::diff2; |
|
1043
|
|
|
|
|
|
|
|
|
1044
|
|
|
|
|
|
|
|
|
1045
|
|
|
|
|
|
|
|
|
1046
|
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
|
|
1048
|
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
=head2 intover |
|
1050
|
|
|
|
|
|
|
|
|
1051
|
|
|
|
|
|
|
=for sig |
|
1052
|
|
|
|
|
|
|
|
|
1053
|
|
|
|
|
|
|
Signature: (a(n); float+ [o]b()) |
|
1054
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1055
|
|
|
|
|
|
|
float double ldouble) |
|
1056
|
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
=for usage |
|
1058
|
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
$b = intover($a); |
|
1060
|
|
|
|
|
|
|
intover($a, $b); # all arguments given |
|
1061
|
|
|
|
|
|
|
$b = $a->intover; # method call |
|
1062
|
|
|
|
|
|
|
$a->intover($b); |
|
1063
|
|
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
=for ref |
|
1065
|
|
|
|
|
|
|
|
|
1066
|
|
|
|
|
|
|
Project via integral to N-1 dimensions |
|
1067
|
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
1069
|
|
|
|
|
|
|
by one by taking the integral along the 1st dimension. |
|
1070
|
|
|
|
|
|
|
|
|
1071
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
1072
|
|
|
|
|
|
|
I dimension. |
|
1073
|
|
|
|
|
|
|
|
|
1074
|
|
|
|
|
|
|
Notes: |
|
1075
|
|
|
|
|
|
|
|
|
1076
|
|
|
|
|
|
|
C uses a point spacing of one (i.e., delta-h==1). You will |
|
1077
|
|
|
|
|
|
|
need to scale the result to correct for the true point delta. |
|
1078
|
|
|
|
|
|
|
|
|
1079
|
|
|
|
|
|
|
For C 3>, these are all C (like Simpson's rule), but are |
|
1080
|
|
|
|
|
|
|
integrals between the end points assuming the pdl gives values just at |
|
1081
|
|
|
|
|
|
|
these centres: for such `functions', sumover is correct to C, but |
|
1082
|
|
|
|
|
|
|
is the natural (and correct) choice for binned data, of course. |
|
1083
|
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
=pod |
|
1085
|
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1087
|
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
=for bad |
|
1089
|
|
|
|
|
|
|
|
|
1090
|
|
|
|
|
|
|
C ignores the bad-value flag of the input ndarrays. |
|
1091
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1092
|
|
|
|
|
|
|
|
|
1093
|
|
|
|
|
|
|
=cut |
|
1094
|
|
|
|
|
|
|
|
|
1095
|
|
|
|
|
|
|
|
|
1096
|
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
|
|
1098
|
|
|
|
|
|
|
*intover = \&PDL::intover; |
|
1099
|
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
|
|
1101
|
|
|
|
|
|
|
|
|
1102
|
|
|
|
|
|
|
|
|
1103
|
|
|
|
|
|
|
|
|
1104
|
|
|
|
|
|
|
|
|
1105
|
|
|
|
|
|
|
=head2 average |
|
1106
|
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
=for sig |
|
1108
|
|
|
|
|
|
|
|
|
1109
|
|
|
|
|
|
|
Signature: (a(n); int+ [o]b()) |
|
1110
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1111
|
|
|
|
|
|
|
float double ldouble) |
|
1112
|
|
|
|
|
|
|
|
|
1113
|
|
|
|
|
|
|
=for usage |
|
1114
|
|
|
|
|
|
|
|
|
1115
|
|
|
|
|
|
|
$b = average($a); |
|
1116
|
|
|
|
|
|
|
average($a, $b); # all arguments given |
|
1117
|
|
|
|
|
|
|
$b = $a->average; # method call |
|
1118
|
|
|
|
|
|
|
$a->average($b); |
|
1119
|
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
=for ref |
|
1121
|
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
Project via average to N-1 dimensions |
|
1123
|
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
1125
|
|
|
|
|
|
|
by one by taking the average along the 1st dimension. |
|
1126
|
|
|
|
|
|
|
|
|
1127
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
1128
|
|
|
|
|
|
|
I dimension. |
|
1129
|
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
=pod |
|
1131
|
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1133
|
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
=for bad |
|
1135
|
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
C processes bad values. |
|
1137
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1138
|
|
|
|
|
|
|
|
|
1139
|
|
|
|
|
|
|
=cut |
|
1140
|
|
|
|
|
|
|
|
|
1141
|
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
|
|
1143
|
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
*average = \&PDL::average; |
|
1145
|
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
|
|
1147
|
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
|
|
1149
|
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
#line 416 "lib/PDL/Ufunc.pd" |
|
1151
|
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
=head2 avgover |
|
1153
|
|
|
|
|
|
|
|
|
1154
|
|
|
|
|
|
|
=for ref |
|
1155
|
|
|
|
|
|
|
|
|
1156
|
|
|
|
|
|
|
Synonym for L. |
|
1157
|
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
=cut |
|
1159
|
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
*PDL::avgover = *avgover = \&PDL::average; |
|
1161
|
|
|
|
|
|
|
#line 1162 "lib/PDL/Ufunc.pm" |
|
1162
|
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
|
|
1164
|
|
|
|
|
|
|
=head2 caverage |
|
1165
|
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
=for sig |
|
1167
|
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
Signature: (a(n); cdouble [o]b()) |
|
1169
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1170
|
|
|
|
|
|
|
float double ldouble) |
|
1171
|
|
|
|
|
|
|
|
|
1172
|
|
|
|
|
|
|
=for usage |
|
1173
|
|
|
|
|
|
|
|
|
1174
|
|
|
|
|
|
|
$b = caverage($a); |
|
1175
|
|
|
|
|
|
|
caverage($a, $b); # all arguments given |
|
1176
|
|
|
|
|
|
|
$b = $a->caverage; # method call |
|
1177
|
|
|
|
|
|
|
$a->caverage($b); |
|
1178
|
|
|
|
|
|
|
|
|
1179
|
|
|
|
|
|
|
=for ref |
|
1180
|
|
|
|
|
|
|
|
|
1181
|
|
|
|
|
|
|
Project via average to N-1 dimensions |
|
1182
|
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
1184
|
|
|
|
|
|
|
by one by taking the average along the 1st dimension. |
|
1185
|
|
|
|
|
|
|
|
|
1186
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
1187
|
|
|
|
|
|
|
I dimension. |
|
1188
|
|
|
|
|
|
|
|
|
1189
|
|
|
|
|
|
|
Unlike L, the calculation is performed in complex double |
|
1190
|
|
|
|
|
|
|
precision. |
|
1191
|
|
|
|
|
|
|
|
|
1192
|
|
|
|
|
|
|
=pod |
|
1193
|
|
|
|
|
|
|
|
|
1194
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1195
|
|
|
|
|
|
|
|
|
1196
|
|
|
|
|
|
|
=for bad |
|
1197
|
|
|
|
|
|
|
|
|
1198
|
|
|
|
|
|
|
C processes bad values. |
|
1199
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1200
|
|
|
|
|
|
|
|
|
1201
|
|
|
|
|
|
|
=cut |
|
1202
|
|
|
|
|
|
|
|
|
1203
|
|
|
|
|
|
|
|
|
1204
|
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
|
|
1206
|
|
|
|
|
|
|
*caverage = \&PDL::caverage; |
|
1207
|
|
|
|
|
|
|
|
|
1208
|
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
|
|
1210
|
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
|
|
1212
|
|
|
|
|
|
|
#line 416 "lib/PDL/Ufunc.pd" |
|
1213
|
|
|
|
|
|
|
|
|
1214
|
|
|
|
|
|
|
=head2 cavgover |
|
1215
|
|
|
|
|
|
|
|
|
1216
|
|
|
|
|
|
|
=for ref |
|
1217
|
|
|
|
|
|
|
|
|
1218
|
|
|
|
|
|
|
Synonym for L. |
|
1219
|
|
|
|
|
|
|
|
|
1220
|
|
|
|
|
|
|
=cut |
|
1221
|
|
|
|
|
|
|
|
|
1222
|
|
|
|
|
|
|
*PDL::cavgover = *cavgover = \&PDL::caverage; |
|
1223
|
|
|
|
|
|
|
#line 1224 "lib/PDL/Ufunc.pm" |
|
1224
|
|
|
|
|
|
|
|
|
1225
|
|
|
|
|
|
|
|
|
1226
|
|
|
|
|
|
|
=head2 daverage |
|
1227
|
|
|
|
|
|
|
|
|
1228
|
|
|
|
|
|
|
=for sig |
|
1229
|
|
|
|
|
|
|
|
|
1230
|
|
|
|
|
|
|
Signature: (a(n); double [o]b()) |
|
1231
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1232
|
|
|
|
|
|
|
float double ldouble) |
|
1233
|
|
|
|
|
|
|
|
|
1234
|
|
|
|
|
|
|
=for usage |
|
1235
|
|
|
|
|
|
|
|
|
1236
|
|
|
|
|
|
|
$b = daverage($a); |
|
1237
|
|
|
|
|
|
|
daverage($a, $b); # all arguments given |
|
1238
|
|
|
|
|
|
|
$b = $a->daverage; # method call |
|
1239
|
|
|
|
|
|
|
$a->daverage($b); |
|
1240
|
|
|
|
|
|
|
|
|
1241
|
|
|
|
|
|
|
=for ref |
|
1242
|
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
Project via average to N-1 dimensions |
|
1244
|
|
|
|
|
|
|
|
|
1245
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
1246
|
|
|
|
|
|
|
by one by taking the average along the 1st dimension. |
|
1247
|
|
|
|
|
|
|
|
|
1248
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
1249
|
|
|
|
|
|
|
I dimension. |
|
1250
|
|
|
|
|
|
|
|
|
1251
|
|
|
|
|
|
|
Unlike L, the calculation is performed in double |
|
1252
|
|
|
|
|
|
|
precision. |
|
1253
|
|
|
|
|
|
|
|
|
1254
|
|
|
|
|
|
|
=pod |
|
1255
|
|
|
|
|
|
|
|
|
1256
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1257
|
|
|
|
|
|
|
|
|
1258
|
|
|
|
|
|
|
=for bad |
|
1259
|
|
|
|
|
|
|
|
|
1260
|
|
|
|
|
|
|
C processes bad values. |
|
1261
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
1262
|
|
|
|
|
|
|
|
|
1263
|
|
|
|
|
|
|
=cut |
|
1264
|
|
|
|
|
|
|
|
|
1265
|
|
|
|
|
|
|
|
|
1266
|
|
|
|
|
|
|
|
|
1267
|
|
|
|
|
|
|
|
|
1268
|
|
|
|
|
|
|
*daverage = \&PDL::daverage; |
|
1269
|
|
|
|
|
|
|
|
|
1270
|
|
|
|
|
|
|
|
|
1271
|
|
|
|
|
|
|
|
|
1272
|
|
|
|
|
|
|
|
|
1273
|
|
|
|
|
|
|
|
|
1274
|
|
|
|
|
|
|
#line 416 "lib/PDL/Ufunc.pd" |
|
1275
|
|
|
|
|
|
|
|
|
1276
|
|
|
|
|
|
|
=head2 davgover |
|
1277
|
|
|
|
|
|
|
|
|
1278
|
|
|
|
|
|
|
=for ref |
|
1279
|
|
|
|
|
|
|
|
|
1280
|
|
|
|
|
|
|
Synonym for L. |
|
1281
|
|
|
|
|
|
|
|
|
1282
|
|
|
|
|
|
|
=cut |
|
1283
|
|
|
|
|
|
|
|
|
1284
|
|
|
|
|
|
|
*PDL::davgover = *davgover = \&PDL::daverage; |
|
1285
|
|
|
|
|
|
|
#line 1286 "lib/PDL/Ufunc.pm" |
|
1286
|
|
|
|
|
|
|
|
|
1287
|
|
|
|
|
|
|
|
|
1288
|
|
|
|
|
|
|
=head2 minimum |
|
1289
|
|
|
|
|
|
|
|
|
1290
|
|
|
|
|
|
|
=for sig |
|
1291
|
|
|
|
|
|
|
|
|
1292
|
|
|
|
|
|
|
Signature: (a(n); [o]c()) |
|
1293
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1294
|
|
|
|
|
|
|
float double ldouble) |
|
1295
|
|
|
|
|
|
|
|
|
1296
|
|
|
|
|
|
|
=for usage |
|
1297
|
|
|
|
|
|
|
|
|
1298
|
|
|
|
|
|
|
$c = minimum($a); |
|
1299
|
|
|
|
|
|
|
minimum($a, $c); # all arguments given |
|
1300
|
|
|
|
|
|
|
$c = $a->minimum; # method call |
|
1301
|
|
|
|
|
|
|
$a->minimum($c); |
|
1302
|
|
|
|
|
|
|
|
|
1303
|
|
|
|
|
|
|
=for ref |
|
1304
|
|
|
|
|
|
|
|
|
1305
|
|
|
|
|
|
|
Project via minimum to N-1 dimensions |
|
1306
|
|
|
|
|
|
|
|
|
1307
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
1308
|
|
|
|
|
|
|
by one by taking the minimum along the 1st dimension. |
|
1309
|
|
|
|
|
|
|
|
|
1310
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
1311
|
|
|
|
|
|
|
I dimension. |
|
1312
|
|
|
|
|
|
|
|
|
1313
|
|
|
|
|
|
|
=pod |
|
1314
|
|
|
|
|
|
|
|
|
1315
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1316
|
|
|
|
|
|
|
|
|
1317
|
|
|
|
|
|
|
=for bad |
|
1318
|
|
|
|
|
|
|
|
|
1319
|
|
|
|
|
|
|
Output is set bad if no elements of the input are non-bad, |
|
1320
|
|
|
|
|
|
|
otherwise the bad flag is cleared for the output ndarray. |
|
1321
|
|
|
|
|
|
|
|
|
1322
|
|
|
|
|
|
|
Note that C are considered to be valid values and will "win" over non-C; |
|
1323
|
|
|
|
|
|
|
see L and L |
|
1324
|
|
|
|
|
|
|
for ways of masking NaNs. |
|
1325
|
|
|
|
|
|
|
|
|
1326
|
|
|
|
|
|
|
=cut |
|
1327
|
|
|
|
|
|
|
|
|
1328
|
|
|
|
|
|
|
|
|
1329
|
|
|
|
|
|
|
|
|
1330
|
|
|
|
|
|
|
|
|
1331
|
|
|
|
|
|
|
*minimum = \&PDL::minimum; |
|
1332
|
|
|
|
|
|
|
|
|
1333
|
|
|
|
|
|
|
|
|
1334
|
|
|
|
|
|
|
|
|
1335
|
|
|
|
|
|
|
|
|
1336
|
|
|
|
|
|
|
|
|
1337
|
|
|
|
|
|
|
#line 416 "lib/PDL/Ufunc.pd" |
|
1338
|
|
|
|
|
|
|
|
|
1339
|
|
|
|
|
|
|
=head2 minover |
|
1340
|
|
|
|
|
|
|
|
|
1341
|
|
|
|
|
|
|
=for ref |
|
1342
|
|
|
|
|
|
|
|
|
1343
|
|
|
|
|
|
|
Synonym for L. |
|
1344
|
|
|
|
|
|
|
|
|
1345
|
|
|
|
|
|
|
=cut |
|
1346
|
|
|
|
|
|
|
|
|
1347
|
|
|
|
|
|
|
*PDL::minover = *minover = \&PDL::minimum; |
|
1348
|
|
|
|
|
|
|
#line 1349 "lib/PDL/Ufunc.pm" |
|
1349
|
|
|
|
|
|
|
|
|
1350
|
|
|
|
|
|
|
|
|
1351
|
|
|
|
|
|
|
=head2 minimum_ind |
|
1352
|
|
|
|
|
|
|
|
|
1353
|
|
|
|
|
|
|
=for sig |
|
1354
|
|
|
|
|
|
|
|
|
1355
|
|
|
|
|
|
|
Signature: (a(n); indx [o] c()) |
|
1356
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1357
|
|
|
|
|
|
|
float double ldouble) |
|
1358
|
|
|
|
|
|
|
|
|
1359
|
|
|
|
|
|
|
=for usage |
|
1360
|
|
|
|
|
|
|
|
|
1361
|
|
|
|
|
|
|
$c = minimum_ind($a); |
|
1362
|
|
|
|
|
|
|
minimum_ind($a, $c); # all arguments given |
|
1363
|
|
|
|
|
|
|
$c = $a->minimum_ind; # method call |
|
1364
|
|
|
|
|
|
|
$a->minimum_ind($c); |
|
1365
|
|
|
|
|
|
|
|
|
1366
|
|
|
|
|
|
|
=for ref |
|
1367
|
|
|
|
|
|
|
|
|
1368
|
|
|
|
|
|
|
Like minimum but returns the first matching index rather than the value |
|
1369
|
|
|
|
|
|
|
|
|
1370
|
|
|
|
|
|
|
=pod |
|
1371
|
|
|
|
|
|
|
|
|
1372
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1373
|
|
|
|
|
|
|
|
|
1374
|
|
|
|
|
|
|
=for bad |
|
1375
|
|
|
|
|
|
|
|
|
1376
|
|
|
|
|
|
|
Output is set bad if no elements of the input are non-bad, |
|
1377
|
|
|
|
|
|
|
otherwise the bad flag is cleared for the output ndarray. |
|
1378
|
|
|
|
|
|
|
|
|
1379
|
|
|
|
|
|
|
Note that C are considered to be valid values and will "win" over non-C; |
|
1380
|
|
|
|
|
|
|
see L and L |
|
1381
|
|
|
|
|
|
|
for ways of masking NaNs. |
|
1382
|
|
|
|
|
|
|
|
|
1383
|
|
|
|
|
|
|
=cut |
|
1384
|
|
|
|
|
|
|
|
|
1385
|
|
|
|
|
|
|
|
|
1386
|
|
|
|
|
|
|
|
|
1387
|
|
|
|
|
|
|
|
|
1388
|
|
|
|
|
|
|
*minimum_ind = \&PDL::minimum_ind; |
|
1389
|
|
|
|
|
|
|
|
|
1390
|
|
|
|
|
|
|
|
|
1391
|
|
|
|
|
|
|
|
|
1392
|
|
|
|
|
|
|
|
|
1393
|
|
|
|
|
|
|
|
|
1394
|
|
|
|
|
|
|
#line 416 "lib/PDL/Ufunc.pd" |
|
1395
|
|
|
|
|
|
|
|
|
1396
|
|
|
|
|
|
|
=head2 minover_ind |
|
1397
|
|
|
|
|
|
|
|
|
1398
|
|
|
|
|
|
|
=for ref |
|
1399
|
|
|
|
|
|
|
|
|
1400
|
|
|
|
|
|
|
Synonym for L. |
|
1401
|
|
|
|
|
|
|
|
|
1402
|
|
|
|
|
|
|
=cut |
|
1403
|
|
|
|
|
|
|
|
|
1404
|
|
|
|
|
|
|
*PDL::minover_ind = *minover_ind = \&PDL::minimum_ind; |
|
1405
|
|
|
|
|
|
|
#line 1406 "lib/PDL/Ufunc.pm" |
|
1406
|
|
|
|
|
|
|
|
|
1407
|
|
|
|
|
|
|
|
|
1408
|
|
|
|
|
|
|
=head2 minimum_n_ind |
|
1409
|
|
|
|
|
|
|
|
|
1410
|
|
|
|
|
|
|
=for sig |
|
1411
|
|
|
|
|
|
|
|
|
1412
|
|
|
|
|
|
|
Signature: (a(n); indx [o]c(m); PDL_Indx m_size => m) |
|
1413
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1414
|
|
|
|
|
|
|
float double ldouble) |
|
1415
|
|
|
|
|
|
|
|
|
1416
|
|
|
|
|
|
|
=for ref |
|
1417
|
|
|
|
|
|
|
|
|
1418
|
|
|
|
|
|
|
Returns the index of first C minimum elements. As of 2.077, you can |
|
1419
|
|
|
|
|
|
|
specify how many by either passing in an ndarray of the given size |
|
1420
|
|
|
|
|
|
|
(DEPRECATED - will be converted to indx if needed and the input arg will |
|
1421
|
|
|
|
|
|
|
be set to that), or just the size, or a null and the size. |
|
1422
|
|
|
|
|
|
|
|
|
1423
|
|
|
|
|
|
|
=for usage |
|
1424
|
|
|
|
|
|
|
|
|
1425
|
|
|
|
|
|
|
minimum_n_ind($pdl, $out = zeroes(5)); # DEPRECATED |
|
1426
|
|
|
|
|
|
|
$out = minimum_n_ind($pdl, 5); |
|
1427
|
|
|
|
|
|
|
minimum_n_ind($pdl, $out = null, 5); |
|
1428
|
|
|
|
|
|
|
|
|
1429
|
|
|
|
|
|
|
=pod |
|
1430
|
|
|
|
|
|
|
|
|
1431
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1432
|
|
|
|
|
|
|
|
|
1433
|
|
|
|
|
|
|
=for bad |
|
1434
|
|
|
|
|
|
|
|
|
1435
|
|
|
|
|
|
|
Output bad flag is cleared for the output ndarray if sufficient non-bad elements found, |
|
1436
|
|
|
|
|
|
|
else remaining slots in C<$c()> are set bad. |
|
1437
|
|
|
|
|
|
|
|
|
1438
|
|
|
|
|
|
|
Note that C are considered to be valid values and will "win" over non-C; |
|
1439
|
|
|
|
|
|
|
see L and L |
|
1440
|
|
|
|
|
|
|
for ways of masking NaNs. |
|
1441
|
|
|
|
|
|
|
|
|
1442
|
|
|
|
|
|
|
=cut |
|
1443
|
|
|
|
|
|
|
|
|
1444
|
|
|
|
|
|
|
|
|
1445
|
|
|
|
|
|
|
|
|
1446
|
|
|
|
|
|
|
|
|
1447
|
|
|
|
|
|
|
|
|
1448
|
|
|
|
|
|
|
#line 516 "lib/PDL/Ufunc.pd" |
|
1449
|
|
|
|
|
|
|
sub PDL::minimum_n_ind { |
|
1450
|
|
|
|
|
|
|
my ($a, $c, $m_size) = @_; |
|
1451
|
|
|
|
|
|
|
$m_size //= ref($c) ? $c->dim(0) : $c; # back-compat with pre-2.077 |
|
1452
|
|
|
|
|
|
|
my $set_out = 1; |
|
1453
|
|
|
|
|
|
|
$set_out = 0, $c = null if !ref $c; |
|
1454
|
|
|
|
|
|
|
$c = $c->indx if !$c->isnull; |
|
1455
|
|
|
|
|
|
|
PDL::_minimum_n_ind_int($a, $c, $m_size); |
|
1456
|
|
|
|
|
|
|
$set_out ? $_[1] = $c : $c; |
|
1457
|
|
|
|
|
|
|
} |
|
1458
|
|
|
|
|
|
|
#line 1459 "lib/PDL/Ufunc.pm" |
|
1459
|
|
|
|
|
|
|
|
|
1460
|
|
|
|
|
|
|
*minimum_n_ind = \&PDL::minimum_n_ind; |
|
1461
|
|
|
|
|
|
|
|
|
1462
|
|
|
|
|
|
|
|
|
1463
|
|
|
|
|
|
|
|
|
1464
|
|
|
|
|
|
|
|
|
1465
|
|
|
|
|
|
|
|
|
1466
|
|
|
|
|
|
|
#line 416 "lib/PDL/Ufunc.pd" |
|
1467
|
|
|
|
|
|
|
|
|
1468
|
|
|
|
|
|
|
=head2 minover_n_ind |
|
1469
|
|
|
|
|
|
|
|
|
1470
|
|
|
|
|
|
|
=for ref |
|
1471
|
|
|
|
|
|
|
|
|
1472
|
|
|
|
|
|
|
Synonym for L. |
|
1473
|
|
|
|
|
|
|
|
|
1474
|
|
|
|
|
|
|
=cut |
|
1475
|
|
|
|
|
|
|
|
|
1476
|
|
|
|
|
|
|
*PDL::minover_n_ind = *minover_n_ind = \&PDL::minimum_n_ind; |
|
1477
|
|
|
|
|
|
|
#line 1478 "lib/PDL/Ufunc.pm" |
|
1478
|
|
|
|
|
|
|
|
|
1479
|
|
|
|
|
|
|
|
|
1480
|
|
|
|
|
|
|
=head2 maximum |
|
1481
|
|
|
|
|
|
|
|
|
1482
|
|
|
|
|
|
|
=for sig |
|
1483
|
|
|
|
|
|
|
|
|
1484
|
|
|
|
|
|
|
Signature: (a(n); [o]c()) |
|
1485
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1486
|
|
|
|
|
|
|
float double ldouble) |
|
1487
|
|
|
|
|
|
|
|
|
1488
|
|
|
|
|
|
|
=for usage |
|
1489
|
|
|
|
|
|
|
|
|
1490
|
|
|
|
|
|
|
$c = maximum($a); |
|
1491
|
|
|
|
|
|
|
maximum($a, $c); # all arguments given |
|
1492
|
|
|
|
|
|
|
$c = $a->maximum; # method call |
|
1493
|
|
|
|
|
|
|
$a->maximum($c); |
|
1494
|
|
|
|
|
|
|
|
|
1495
|
|
|
|
|
|
|
=for ref |
|
1496
|
|
|
|
|
|
|
|
|
1497
|
|
|
|
|
|
|
Project via maximum to N-1 dimensions |
|
1498
|
|
|
|
|
|
|
|
|
1499
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
1500
|
|
|
|
|
|
|
by one by taking the maximum along the 1st dimension. |
|
1501
|
|
|
|
|
|
|
|
|
1502
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
1503
|
|
|
|
|
|
|
I dimension. |
|
1504
|
|
|
|
|
|
|
|
|
1505
|
|
|
|
|
|
|
=pod |
|
1506
|
|
|
|
|
|
|
|
|
1507
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1508
|
|
|
|
|
|
|
|
|
1509
|
|
|
|
|
|
|
=for bad |
|
1510
|
|
|
|
|
|
|
|
|
1511
|
|
|
|
|
|
|
Output is set bad if no elements of the input are non-bad, |
|
1512
|
|
|
|
|
|
|
otherwise the bad flag is cleared for the output ndarray. |
|
1513
|
|
|
|
|
|
|
|
|
1514
|
|
|
|
|
|
|
Note that C are considered to be valid values and will "win" over non-C; |
|
1515
|
|
|
|
|
|
|
see L and L |
|
1516
|
|
|
|
|
|
|
for ways of masking NaNs. |
|
1517
|
|
|
|
|
|
|
|
|
1518
|
|
|
|
|
|
|
=cut |
|
1519
|
|
|
|
|
|
|
|
|
1520
|
|
|
|
|
|
|
|
|
1521
|
|
|
|
|
|
|
|
|
1522
|
|
|
|
|
|
|
|
|
1523
|
|
|
|
|
|
|
*maximum = \&PDL::maximum; |
|
1524
|
|
|
|
|
|
|
|
|
1525
|
|
|
|
|
|
|
|
|
1526
|
|
|
|
|
|
|
|
|
1527
|
|
|
|
|
|
|
|
|
1528
|
|
|
|
|
|
|
|
|
1529
|
|
|
|
|
|
|
#line 416 "lib/PDL/Ufunc.pd" |
|
1530
|
|
|
|
|
|
|
|
|
1531
|
|
|
|
|
|
|
=head2 maxover |
|
1532
|
|
|
|
|
|
|
|
|
1533
|
|
|
|
|
|
|
=for ref |
|
1534
|
|
|
|
|
|
|
|
|
1535
|
|
|
|
|
|
|
Synonym for L. |
|
1536
|
|
|
|
|
|
|
|
|
1537
|
|
|
|
|
|
|
=cut |
|
1538
|
|
|
|
|
|
|
|
|
1539
|
|
|
|
|
|
|
*PDL::maxover = *maxover = \&PDL::maximum; |
|
1540
|
|
|
|
|
|
|
#line 1541 "lib/PDL/Ufunc.pm" |
|
1541
|
|
|
|
|
|
|
|
|
1542
|
|
|
|
|
|
|
|
|
1543
|
|
|
|
|
|
|
=head2 maximum_ind |
|
1544
|
|
|
|
|
|
|
|
|
1545
|
|
|
|
|
|
|
=for sig |
|
1546
|
|
|
|
|
|
|
|
|
1547
|
|
|
|
|
|
|
Signature: (a(n); indx [o] c()) |
|
1548
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1549
|
|
|
|
|
|
|
float double ldouble) |
|
1550
|
|
|
|
|
|
|
|
|
1551
|
|
|
|
|
|
|
=for usage |
|
1552
|
|
|
|
|
|
|
|
|
1553
|
|
|
|
|
|
|
$c = maximum_ind($a); |
|
1554
|
|
|
|
|
|
|
maximum_ind($a, $c); # all arguments given |
|
1555
|
|
|
|
|
|
|
$c = $a->maximum_ind; # method call |
|
1556
|
|
|
|
|
|
|
$a->maximum_ind($c); |
|
1557
|
|
|
|
|
|
|
|
|
1558
|
|
|
|
|
|
|
=for ref |
|
1559
|
|
|
|
|
|
|
|
|
1560
|
|
|
|
|
|
|
Like maximum but returns the first matching index rather than the value |
|
1561
|
|
|
|
|
|
|
|
|
1562
|
|
|
|
|
|
|
=pod |
|
1563
|
|
|
|
|
|
|
|
|
1564
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1565
|
|
|
|
|
|
|
|
|
1566
|
|
|
|
|
|
|
=for bad |
|
1567
|
|
|
|
|
|
|
|
|
1568
|
|
|
|
|
|
|
Output is set bad if no elements of the input are non-bad, |
|
1569
|
|
|
|
|
|
|
otherwise the bad flag is cleared for the output ndarray. |
|
1570
|
|
|
|
|
|
|
|
|
1571
|
|
|
|
|
|
|
Note that C are considered to be valid values and will "win" over non-C; |
|
1572
|
|
|
|
|
|
|
see L and L |
|
1573
|
|
|
|
|
|
|
for ways of masking NaNs. |
|
1574
|
|
|
|
|
|
|
|
|
1575
|
|
|
|
|
|
|
=cut |
|
1576
|
|
|
|
|
|
|
|
|
1577
|
|
|
|
|
|
|
|
|
1578
|
|
|
|
|
|
|
|
|
1579
|
|
|
|
|
|
|
|
|
1580
|
|
|
|
|
|
|
*maximum_ind = \&PDL::maximum_ind; |
|
1581
|
|
|
|
|
|
|
|
|
1582
|
|
|
|
|
|
|
|
|
1583
|
|
|
|
|
|
|
|
|
1584
|
|
|
|
|
|
|
|
|
1585
|
|
|
|
|
|
|
|
|
1586
|
|
|
|
|
|
|
#line 416 "lib/PDL/Ufunc.pd" |
|
1587
|
|
|
|
|
|
|
|
|
1588
|
|
|
|
|
|
|
=head2 maxover_ind |
|
1589
|
|
|
|
|
|
|
|
|
1590
|
|
|
|
|
|
|
=for ref |
|
1591
|
|
|
|
|
|
|
|
|
1592
|
|
|
|
|
|
|
Synonym for L. |
|
1593
|
|
|
|
|
|
|
|
|
1594
|
|
|
|
|
|
|
=cut |
|
1595
|
|
|
|
|
|
|
|
|
1596
|
|
|
|
|
|
|
*PDL::maxover_ind = *maxover_ind = \&PDL::maximum_ind; |
|
1597
|
|
|
|
|
|
|
#line 1598 "lib/PDL/Ufunc.pm" |
|
1598
|
|
|
|
|
|
|
|
|
1599
|
|
|
|
|
|
|
|
|
1600
|
|
|
|
|
|
|
=head2 maximum_n_ind |
|
1601
|
|
|
|
|
|
|
|
|
1602
|
|
|
|
|
|
|
=for sig |
|
1603
|
|
|
|
|
|
|
|
|
1604
|
|
|
|
|
|
|
Signature: (a(n); indx [o]c(m); PDL_Indx m_size => m) |
|
1605
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1606
|
|
|
|
|
|
|
float double ldouble) |
|
1607
|
|
|
|
|
|
|
|
|
1608
|
|
|
|
|
|
|
=for ref |
|
1609
|
|
|
|
|
|
|
|
|
1610
|
|
|
|
|
|
|
Returns the index of first C maximum elements. As of 2.077, you can |
|
1611
|
|
|
|
|
|
|
specify how many by either passing in an ndarray of the given size |
|
1612
|
|
|
|
|
|
|
(DEPRECATED - will be converted to indx if needed and the input arg will |
|
1613
|
|
|
|
|
|
|
be set to that), or just the size, or a null and the size. |
|
1614
|
|
|
|
|
|
|
|
|
1615
|
|
|
|
|
|
|
=for usage |
|
1616
|
|
|
|
|
|
|
|
|
1617
|
|
|
|
|
|
|
maximum_n_ind($pdl, $out = zeroes(5)); # DEPRECATED |
|
1618
|
|
|
|
|
|
|
$out = maximum_n_ind($pdl, 5); |
|
1619
|
|
|
|
|
|
|
maximum_n_ind($pdl, $out = null, 5); |
|
1620
|
|
|
|
|
|
|
|
|
1621
|
|
|
|
|
|
|
=pod |
|
1622
|
|
|
|
|
|
|
|
|
1623
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1624
|
|
|
|
|
|
|
|
|
1625
|
|
|
|
|
|
|
=for bad |
|
1626
|
|
|
|
|
|
|
|
|
1627
|
|
|
|
|
|
|
Output bad flag is cleared for the output ndarray if sufficient non-bad elements found, |
|
1628
|
|
|
|
|
|
|
else remaining slots in C<$c()> are set bad. |
|
1629
|
|
|
|
|
|
|
|
|
1630
|
|
|
|
|
|
|
Note that C are considered to be valid values and will "win" over non-C; |
|
1631
|
|
|
|
|
|
|
see L and L |
|
1632
|
|
|
|
|
|
|
for ways of masking NaNs. |
|
1633
|
|
|
|
|
|
|
|
|
1634
|
|
|
|
|
|
|
=cut |
|
1635
|
|
|
|
|
|
|
|
|
1636
|
|
|
|
|
|
|
|
|
1637
|
|
|
|
|
|
|
|
|
1638
|
|
|
|
|
|
|
|
|
1639
|
|
|
|
|
|
|
|
|
1640
|
|
|
|
|
|
|
#line 516 "lib/PDL/Ufunc.pd" |
|
1641
|
|
|
|
|
|
|
sub PDL::maximum_n_ind { |
|
1642
|
|
|
|
|
|
|
my ($a, $c, $m_size) = @_; |
|
1643
|
|
|
|
|
|
|
$m_size //= ref($c) ? $c->dim(0) : $c; # back-compat with pre-2.077 |
|
1644
|
|
|
|
|
|
|
my $set_out = 1; |
|
1645
|
|
|
|
|
|
|
$set_out = 0, $c = null if !ref $c; |
|
1646
|
|
|
|
|
|
|
$c = $c->indx if !$c->isnull; |
|
1647
|
|
|
|
|
|
|
PDL::_maximum_n_ind_int($a, $c, $m_size); |
|
1648
|
|
|
|
|
|
|
$set_out ? $_[1] = $c : $c; |
|
1649
|
|
|
|
|
|
|
} |
|
1650
|
|
|
|
|
|
|
#line 1651 "lib/PDL/Ufunc.pm" |
|
1651
|
|
|
|
|
|
|
|
|
1652
|
|
|
|
|
|
|
*maximum_n_ind = \&PDL::maximum_n_ind; |
|
1653
|
|
|
|
|
|
|
|
|
1654
|
|
|
|
|
|
|
|
|
1655
|
|
|
|
|
|
|
|
|
1656
|
|
|
|
|
|
|
|
|
1657
|
|
|
|
|
|
|
|
|
1658
|
|
|
|
|
|
|
#line 416 "lib/PDL/Ufunc.pd" |
|
1659
|
|
|
|
|
|
|
|
|
1660
|
|
|
|
|
|
|
=head2 maxover_n_ind |
|
1661
|
|
|
|
|
|
|
|
|
1662
|
|
|
|
|
|
|
=for ref |
|
1663
|
|
|
|
|
|
|
|
|
1664
|
|
|
|
|
|
|
Synonym for L. |
|
1665
|
|
|
|
|
|
|
|
|
1666
|
|
|
|
|
|
|
=cut |
|
1667
|
|
|
|
|
|
|
|
|
1668
|
|
|
|
|
|
|
*PDL::maxover_n_ind = *maxover_n_ind = \&PDL::maximum_n_ind; |
|
1669
|
|
|
|
|
|
|
#line 1670 "lib/PDL/Ufunc.pm" |
|
1670
|
|
|
|
|
|
|
|
|
1671
|
|
|
|
|
|
|
|
|
1672
|
|
|
|
|
|
|
=head2 minmaximum |
|
1673
|
|
|
|
|
|
|
|
|
1674
|
|
|
|
|
|
|
=for sig |
|
1675
|
|
|
|
|
|
|
|
|
1676
|
|
|
|
|
|
|
Signature: (a(n); [o]cmin(); [o] cmax(); indx [o]cmin_ind(); indx [o]cmax_ind()) |
|
1677
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
1678
|
|
|
|
|
|
|
float double ldouble) |
|
1679
|
|
|
|
|
|
|
|
|
1680
|
|
|
|
|
|
|
=for usage |
|
1681
|
|
|
|
|
|
|
|
|
1682
|
|
|
|
|
|
|
($cmin, $cmax, $cmin_ind, $cmax_ind) = minmaximum($a); |
|
1683
|
|
|
|
|
|
|
minmaximum($a, $cmin, $cmax, $cmin_ind, $cmax_ind); # all arguments given |
|
1684
|
|
|
|
|
|
|
($cmin, $cmax, $cmin_ind, $cmax_ind) = $a->minmaximum; # method call |
|
1685
|
|
|
|
|
|
|
$a->minmaximum($cmin, $cmax, $cmin_ind, $cmax_ind); |
|
1686
|
|
|
|
|
|
|
|
|
1687
|
|
|
|
|
|
|
=for ref |
|
1688
|
|
|
|
|
|
|
|
|
1689
|
|
|
|
|
|
|
Find minimum and maximum and their indices for a given ndarray; |
|
1690
|
|
|
|
|
|
|
|
|
1691
|
|
|
|
|
|
|
=for example |
|
1692
|
|
|
|
|
|
|
|
|
1693
|
|
|
|
|
|
|
pdl> $x=pdl [[-2,3,4],[1,0,3]] |
|
1694
|
|
|
|
|
|
|
pdl> ($min, $max, $min_ind, $max_ind)=minmaximum($x) |
|
1695
|
|
|
|
|
|
|
pdl> p $min, $max, $min_ind, $max_ind |
|
1696
|
|
|
|
|
|
|
[-2 0] [4 3] [0 1] [2 2] |
|
1697
|
|
|
|
|
|
|
|
|
1698
|
|
|
|
|
|
|
See also L, which clumps the ndarray together. |
|
1699
|
|
|
|
|
|
|
|
|
1700
|
|
|
|
|
|
|
=pod |
|
1701
|
|
|
|
|
|
|
|
|
1702
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
1703
|
|
|
|
|
|
|
|
|
1704
|
|
|
|
|
|
|
=for bad |
|
1705
|
|
|
|
|
|
|
|
|
1706
|
|
|
|
|
|
|
If C contains only bad data, then the output ndarrays will |
|
1707
|
|
|
|
|
|
|
be set bad, along with their bad flag. |
|
1708
|
|
|
|
|
|
|
Otherwise they will have their bad flags cleared, |
|
1709
|
|
|
|
|
|
|
since they will not contain any bad values. |
|
1710
|
|
|
|
|
|
|
|
|
1711
|
|
|
|
|
|
|
=cut |
|
1712
|
|
|
|
|
|
|
|
|
1713
|
|
|
|
|
|
|
|
|
1714
|
|
|
|
|
|
|
|
|
1715
|
|
|
|
|
|
|
|
|
1716
|
|
|
|
|
|
|
*minmaximum = \&PDL::minmaximum; |
|
1717
|
|
|
|
|
|
|
|
|
1718
|
|
|
|
|
|
|
|
|
1719
|
|
|
|
|
|
|
|
|
1720
|
|
|
|
|
|
|
|
|
1721
|
|
|
|
|
|
|
|
|
1722
|
|
|
|
|
|
|
#line 416 "lib/PDL/Ufunc.pd" |
|
1723
|
|
|
|
|
|
|
|
|
1724
|
|
|
|
|
|
|
=head2 minmaxover |
|
1725
|
|
|
|
|
|
|
|
|
1726
|
|
|
|
|
|
|
=for ref |
|
1727
|
|
|
|
|
|
|
|
|
1728
|
|
|
|
|
|
|
Synonym for L. |
|
1729
|
|
|
|
|
|
|
|
|
1730
|
|
|
|
|
|
|
=cut |
|
1731
|
|
|
|
|
|
|
|
|
1732
|
|
|
|
|
|
|
*PDL::minmaxover = *minmaxover = \&PDL::minmaximum; |
|
1733
|
|
|
|
|
|
|
|
|
1734
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
1735
|
|
|
|
|
|
|
|
|
1736
|
|
|
|
|
|
|
=head2 avg |
|
1737
|
|
|
|
|
|
|
|
|
1738
|
|
|
|
|
|
|
=for ref |
|
1739
|
|
|
|
|
|
|
|
|
1740
|
|
|
|
|
|
|
Return the average of all elements in an ndarray. |
|
1741
|
|
|
|
|
|
|
|
|
1742
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
1743
|
|
|
|
|
|
|
|
|
1744
|
|
|
|
|
|
|
=for usage |
|
1745
|
|
|
|
|
|
|
|
|
1746
|
|
|
|
|
|
|
$x = avg($data); |
|
1747
|
|
|
|
|
|
|
|
|
1748
|
|
|
|
|
|
|
=for bad |
|
1749
|
|
|
|
|
|
|
|
|
1750
|
|
|
|
|
|
|
This routine handles bad values. |
|
1751
|
|
|
|
|
|
|
|
|
1752
|
|
|
|
|
|
|
=cut |
|
1753
|
|
|
|
|
|
|
|
|
1754
|
|
|
|
|
|
|
*avg = \&PDL::avg; |
|
1755
|
|
|
|
|
|
|
sub PDL::avg { $_[0]->flat->average } |
|
1756
|
|
|
|
|
|
|
|
|
1757
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
1758
|
|
|
|
|
|
|
|
|
1759
|
|
|
|
|
|
|
=head2 sum |
|
1760
|
|
|
|
|
|
|
|
|
1761
|
|
|
|
|
|
|
=for ref |
|
1762
|
|
|
|
|
|
|
|
|
1763
|
|
|
|
|
|
|
Return the sum of all elements in an ndarray. |
|
1764
|
|
|
|
|
|
|
|
|
1765
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
1766
|
|
|
|
|
|
|
|
|
1767
|
|
|
|
|
|
|
=for usage |
|
1768
|
|
|
|
|
|
|
|
|
1769
|
|
|
|
|
|
|
$x = sum($data); |
|
1770
|
|
|
|
|
|
|
|
|
1771
|
|
|
|
|
|
|
=for bad |
|
1772
|
|
|
|
|
|
|
|
|
1773
|
|
|
|
|
|
|
This routine handles bad values. |
|
1774
|
|
|
|
|
|
|
|
|
1775
|
|
|
|
|
|
|
=cut |
|
1776
|
|
|
|
|
|
|
|
|
1777
|
|
|
|
|
|
|
*sum = \&PDL::sum; |
|
1778
|
|
|
|
|
|
|
sub PDL::sum { $_[0]->flat->sumover } |
|
1779
|
|
|
|
|
|
|
|
|
1780
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
1781
|
|
|
|
|
|
|
|
|
1782
|
|
|
|
|
|
|
=head2 prod |
|
1783
|
|
|
|
|
|
|
|
|
1784
|
|
|
|
|
|
|
=for ref |
|
1785
|
|
|
|
|
|
|
|
|
1786
|
|
|
|
|
|
|
Return the product of all elements in an ndarray. |
|
1787
|
|
|
|
|
|
|
|
|
1788
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
1789
|
|
|
|
|
|
|
|
|
1790
|
|
|
|
|
|
|
=for usage |
|
1791
|
|
|
|
|
|
|
|
|
1792
|
|
|
|
|
|
|
$x = prod($data); |
|
1793
|
|
|
|
|
|
|
|
|
1794
|
|
|
|
|
|
|
=for bad |
|
1795
|
|
|
|
|
|
|
|
|
1796
|
|
|
|
|
|
|
This routine handles bad values. |
|
1797
|
|
|
|
|
|
|
|
|
1798
|
|
|
|
|
|
|
=cut |
|
1799
|
|
|
|
|
|
|
|
|
1800
|
|
|
|
|
|
|
*prod = \&PDL::prod; |
|
1801
|
|
|
|
|
|
|
sub PDL::prod { $_[0]->flat->prodover } |
|
1802
|
|
|
|
|
|
|
|
|
1803
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
1804
|
|
|
|
|
|
|
|
|
1805
|
|
|
|
|
|
|
=head2 davg |
|
1806
|
|
|
|
|
|
|
|
|
1807
|
|
|
|
|
|
|
=for ref |
|
1808
|
|
|
|
|
|
|
|
|
1809
|
|
|
|
|
|
|
Return the average (in double precision) of all elements in an ndarray. |
|
1810
|
|
|
|
|
|
|
|
|
1811
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
1812
|
|
|
|
|
|
|
|
|
1813
|
|
|
|
|
|
|
=for usage |
|
1814
|
|
|
|
|
|
|
|
|
1815
|
|
|
|
|
|
|
$x = davg($data); |
|
1816
|
|
|
|
|
|
|
|
|
1817
|
|
|
|
|
|
|
=for bad |
|
1818
|
|
|
|
|
|
|
|
|
1819
|
|
|
|
|
|
|
This routine handles bad values. |
|
1820
|
|
|
|
|
|
|
|
|
1821
|
|
|
|
|
|
|
=cut |
|
1822
|
|
|
|
|
|
|
|
|
1823
|
|
|
|
|
|
|
*davg = \&PDL::davg; |
|
1824
|
|
|
|
|
|
|
sub PDL::davg { $_[0]->flat->daverage } |
|
1825
|
|
|
|
|
|
|
|
|
1826
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
1827
|
|
|
|
|
|
|
|
|
1828
|
|
|
|
|
|
|
=head2 dsum |
|
1829
|
|
|
|
|
|
|
|
|
1830
|
|
|
|
|
|
|
=for ref |
|
1831
|
|
|
|
|
|
|
|
|
1832
|
|
|
|
|
|
|
Return the sum (in double precision) of all elements in an ndarray. |
|
1833
|
|
|
|
|
|
|
|
|
1834
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
1835
|
|
|
|
|
|
|
|
|
1836
|
|
|
|
|
|
|
=for usage |
|
1837
|
|
|
|
|
|
|
|
|
1838
|
|
|
|
|
|
|
$x = dsum($data); |
|
1839
|
|
|
|
|
|
|
|
|
1840
|
|
|
|
|
|
|
=for bad |
|
1841
|
|
|
|
|
|
|
|
|
1842
|
|
|
|
|
|
|
This routine handles bad values. |
|
1843
|
|
|
|
|
|
|
|
|
1844
|
|
|
|
|
|
|
=cut |
|
1845
|
|
|
|
|
|
|
|
|
1846
|
|
|
|
|
|
|
*dsum = \&PDL::dsum; |
|
1847
|
|
|
|
|
|
|
sub PDL::dsum { $_[0]->flat->dsumover } |
|
1848
|
|
|
|
|
|
|
|
|
1849
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
1850
|
|
|
|
|
|
|
|
|
1851
|
|
|
|
|
|
|
=head2 dprod |
|
1852
|
|
|
|
|
|
|
|
|
1853
|
|
|
|
|
|
|
=for ref |
|
1854
|
|
|
|
|
|
|
|
|
1855
|
|
|
|
|
|
|
Return the product (in double precision) of all elements in an ndarray. |
|
1856
|
|
|
|
|
|
|
|
|
1857
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
1858
|
|
|
|
|
|
|
|
|
1859
|
|
|
|
|
|
|
=for usage |
|
1860
|
|
|
|
|
|
|
|
|
1861
|
|
|
|
|
|
|
$x = dprod($data); |
|
1862
|
|
|
|
|
|
|
|
|
1863
|
|
|
|
|
|
|
=for bad |
|
1864
|
|
|
|
|
|
|
|
|
1865
|
|
|
|
|
|
|
This routine handles bad values. |
|
1866
|
|
|
|
|
|
|
|
|
1867
|
|
|
|
|
|
|
=cut |
|
1868
|
|
|
|
|
|
|
|
|
1869
|
|
|
|
|
|
|
*dprod = \&PDL::dprod; |
|
1870
|
|
|
|
|
|
|
sub PDL::dprod { $_[0]->flat->dprodover } |
|
1871
|
|
|
|
|
|
|
|
|
1872
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
1873
|
|
|
|
|
|
|
|
|
1874
|
|
|
|
|
|
|
=head2 zcheck |
|
1875
|
|
|
|
|
|
|
|
|
1876
|
|
|
|
|
|
|
=for ref |
|
1877
|
|
|
|
|
|
|
|
|
1878
|
|
|
|
|
|
|
Return the check for zero of all elements in an ndarray. |
|
1879
|
|
|
|
|
|
|
|
|
1880
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
1881
|
|
|
|
|
|
|
|
|
1882
|
|
|
|
|
|
|
=for usage |
|
1883
|
|
|
|
|
|
|
|
|
1884
|
|
|
|
|
|
|
$x = zcheck($data); |
|
1885
|
|
|
|
|
|
|
|
|
1886
|
|
|
|
|
|
|
=for bad |
|
1887
|
|
|
|
|
|
|
|
|
1888
|
|
|
|
|
|
|
This routine handles bad values. |
|
1889
|
|
|
|
|
|
|
|
|
1890
|
|
|
|
|
|
|
=cut |
|
1891
|
|
|
|
|
|
|
|
|
1892
|
|
|
|
|
|
|
*zcheck = \&PDL::zcheck; |
|
1893
|
|
|
|
|
|
|
sub PDL::zcheck { $_[0]->flat->zcover } |
|
1894
|
|
|
|
|
|
|
|
|
1895
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
1896
|
|
|
|
|
|
|
|
|
1897
|
|
|
|
|
|
|
=head2 and |
|
1898
|
|
|
|
|
|
|
|
|
1899
|
|
|
|
|
|
|
=for ref |
|
1900
|
|
|
|
|
|
|
|
|
1901
|
|
|
|
|
|
|
Return the logical and of all elements in an ndarray. |
|
1902
|
|
|
|
|
|
|
|
|
1903
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
1904
|
|
|
|
|
|
|
|
|
1905
|
|
|
|
|
|
|
=for usage |
|
1906
|
|
|
|
|
|
|
|
|
1907
|
|
|
|
|
|
|
$x = and($data); |
|
1908
|
|
|
|
|
|
|
|
|
1909
|
|
|
|
|
|
|
=for bad |
|
1910
|
|
|
|
|
|
|
|
|
1911
|
|
|
|
|
|
|
This routine handles bad values. |
|
1912
|
|
|
|
|
|
|
|
|
1913
|
|
|
|
|
|
|
=cut |
|
1914
|
|
|
|
|
|
|
|
|
1915
|
|
|
|
|
|
|
*and = \&PDL::and; |
|
1916
|
|
|
|
|
|
|
sub PDL::and { $_[0]->flat->andover } |
|
1917
|
|
|
|
|
|
|
|
|
1918
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
1919
|
|
|
|
|
|
|
|
|
1920
|
|
|
|
|
|
|
=head2 band |
|
1921
|
|
|
|
|
|
|
|
|
1922
|
|
|
|
|
|
|
=for ref |
|
1923
|
|
|
|
|
|
|
|
|
1924
|
|
|
|
|
|
|
Return the bitwise and of all elements in an ndarray. |
|
1925
|
|
|
|
|
|
|
|
|
1926
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
1927
|
|
|
|
|
|
|
|
|
1928
|
|
|
|
|
|
|
=for usage |
|
1929
|
|
|
|
|
|
|
|
|
1930
|
|
|
|
|
|
|
$x = band($data); |
|
1931
|
|
|
|
|
|
|
|
|
1932
|
|
|
|
|
|
|
=for bad |
|
1933
|
|
|
|
|
|
|
|
|
1934
|
|
|
|
|
|
|
This routine handles bad values. |
|
1935
|
|
|
|
|
|
|
|
|
1936
|
|
|
|
|
|
|
=cut |
|
1937
|
|
|
|
|
|
|
|
|
1938
|
|
|
|
|
|
|
*band = \&PDL::band; |
|
1939
|
|
|
|
|
|
|
sub PDL::band { $_[0]->flat->bandover } |
|
1940
|
|
|
|
|
|
|
|
|
1941
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
1942
|
|
|
|
|
|
|
|
|
1943
|
|
|
|
|
|
|
=head2 or |
|
1944
|
|
|
|
|
|
|
|
|
1945
|
|
|
|
|
|
|
=for ref |
|
1946
|
|
|
|
|
|
|
|
|
1947
|
|
|
|
|
|
|
Return the logical or of all elements in an ndarray. |
|
1948
|
|
|
|
|
|
|
|
|
1949
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
1950
|
|
|
|
|
|
|
|
|
1951
|
|
|
|
|
|
|
=for usage |
|
1952
|
|
|
|
|
|
|
|
|
1953
|
|
|
|
|
|
|
$x = or($data); |
|
1954
|
|
|
|
|
|
|
|
|
1955
|
|
|
|
|
|
|
=for bad |
|
1956
|
|
|
|
|
|
|
|
|
1957
|
|
|
|
|
|
|
This routine handles bad values. |
|
1958
|
|
|
|
|
|
|
|
|
1959
|
|
|
|
|
|
|
=cut |
|
1960
|
|
|
|
|
|
|
|
|
1961
|
|
|
|
|
|
|
*or = \&PDL::or; |
|
1962
|
|
|
|
|
|
|
sub PDL::or { $_[0]->flat->orover } |
|
1963
|
|
|
|
|
|
|
|
|
1964
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
1965
|
|
|
|
|
|
|
|
|
1966
|
|
|
|
|
|
|
=head2 bor |
|
1967
|
|
|
|
|
|
|
|
|
1968
|
|
|
|
|
|
|
=for ref |
|
1969
|
|
|
|
|
|
|
|
|
1970
|
|
|
|
|
|
|
Return the bitwise or of all elements in an ndarray. |
|
1971
|
|
|
|
|
|
|
|
|
1972
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
1973
|
|
|
|
|
|
|
|
|
1974
|
|
|
|
|
|
|
=for usage |
|
1975
|
|
|
|
|
|
|
|
|
1976
|
|
|
|
|
|
|
$x = bor($data); |
|
1977
|
|
|
|
|
|
|
|
|
1978
|
|
|
|
|
|
|
=for bad |
|
1979
|
|
|
|
|
|
|
|
|
1980
|
|
|
|
|
|
|
This routine handles bad values. |
|
1981
|
|
|
|
|
|
|
|
|
1982
|
|
|
|
|
|
|
=cut |
|
1983
|
|
|
|
|
|
|
|
|
1984
|
|
|
|
|
|
|
*bor = \&PDL::bor; |
|
1985
|
|
|
|
|
|
|
sub PDL::bor { $_[0]->flat->borover } |
|
1986
|
|
|
|
|
|
|
|
|
1987
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
1988
|
|
|
|
|
|
|
|
|
1989
|
|
|
|
|
|
|
=head2 xorall |
|
1990
|
|
|
|
|
|
|
|
|
1991
|
|
|
|
|
|
|
=for ref |
|
1992
|
|
|
|
|
|
|
|
|
1993
|
|
|
|
|
|
|
Return the logical xor of all elements in an ndarray. |
|
1994
|
|
|
|
|
|
|
|
|
1995
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
1996
|
|
|
|
|
|
|
|
|
1997
|
|
|
|
|
|
|
=for usage |
|
1998
|
|
|
|
|
|
|
|
|
1999
|
|
|
|
|
|
|
$x = xorall($data); |
|
2000
|
|
|
|
|
|
|
|
|
2001
|
|
|
|
|
|
|
=for bad |
|
2002
|
|
|
|
|
|
|
|
|
2003
|
|
|
|
|
|
|
This routine handles bad values. |
|
2004
|
|
|
|
|
|
|
|
|
2005
|
|
|
|
|
|
|
=cut |
|
2006
|
|
|
|
|
|
|
|
|
2007
|
|
|
|
|
|
|
*xorall = \&PDL::xorall; |
|
2008
|
|
|
|
|
|
|
sub PDL::xorall { $_[0]->flat->xorover } |
|
2009
|
|
|
|
|
|
|
|
|
2010
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
2011
|
|
|
|
|
|
|
|
|
2012
|
|
|
|
|
|
|
=head2 bxor |
|
2013
|
|
|
|
|
|
|
|
|
2014
|
|
|
|
|
|
|
=for ref |
|
2015
|
|
|
|
|
|
|
|
|
2016
|
|
|
|
|
|
|
Return the bitwise xor of all elements in an ndarray. |
|
2017
|
|
|
|
|
|
|
|
|
2018
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
2019
|
|
|
|
|
|
|
|
|
2020
|
|
|
|
|
|
|
=for usage |
|
2021
|
|
|
|
|
|
|
|
|
2022
|
|
|
|
|
|
|
$x = bxor($data); |
|
2023
|
|
|
|
|
|
|
|
|
2024
|
|
|
|
|
|
|
=for bad |
|
2025
|
|
|
|
|
|
|
|
|
2026
|
|
|
|
|
|
|
This routine handles bad values. |
|
2027
|
|
|
|
|
|
|
|
|
2028
|
|
|
|
|
|
|
=cut |
|
2029
|
|
|
|
|
|
|
|
|
2030
|
|
|
|
|
|
|
*bxor = \&PDL::bxor; |
|
2031
|
|
|
|
|
|
|
sub PDL::bxor { $_[0]->flat->bxorover } |
|
2032
|
|
|
|
|
|
|
|
|
2033
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
2034
|
|
|
|
|
|
|
|
|
2035
|
|
|
|
|
|
|
=head2 min |
|
2036
|
|
|
|
|
|
|
|
|
2037
|
|
|
|
|
|
|
=for ref |
|
2038
|
|
|
|
|
|
|
|
|
2039
|
|
|
|
|
|
|
Return the minimum of all elements in an ndarray. |
|
2040
|
|
|
|
|
|
|
|
|
2041
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
2042
|
|
|
|
|
|
|
|
|
2043
|
|
|
|
|
|
|
=for usage |
|
2044
|
|
|
|
|
|
|
|
|
2045
|
|
|
|
|
|
|
$x = min($data); |
|
2046
|
|
|
|
|
|
|
|
|
2047
|
|
|
|
|
|
|
=for bad |
|
2048
|
|
|
|
|
|
|
|
|
2049
|
|
|
|
|
|
|
This routine handles bad values. |
|
2050
|
|
|
|
|
|
|
|
|
2051
|
|
|
|
|
|
|
=cut |
|
2052
|
|
|
|
|
|
|
|
|
2053
|
|
|
|
|
|
|
*min = \&PDL::min; |
|
2054
|
|
|
|
|
|
|
sub PDL::min { $_[0]->flat->minimum } |
|
2055
|
|
|
|
|
|
|
|
|
2056
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
2057
|
|
|
|
|
|
|
|
|
2058
|
|
|
|
|
|
|
=head2 max |
|
2059
|
|
|
|
|
|
|
|
|
2060
|
|
|
|
|
|
|
=for ref |
|
2061
|
|
|
|
|
|
|
|
|
2062
|
|
|
|
|
|
|
Return the maximum of all elements in an ndarray. |
|
2063
|
|
|
|
|
|
|
|
|
2064
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
2065
|
|
|
|
|
|
|
|
|
2066
|
|
|
|
|
|
|
=for usage |
|
2067
|
|
|
|
|
|
|
|
|
2068
|
|
|
|
|
|
|
$x = max($data); |
|
2069
|
|
|
|
|
|
|
|
|
2070
|
|
|
|
|
|
|
=for bad |
|
2071
|
|
|
|
|
|
|
|
|
2072
|
|
|
|
|
|
|
This routine handles bad values. |
|
2073
|
|
|
|
|
|
|
|
|
2074
|
|
|
|
|
|
|
=cut |
|
2075
|
|
|
|
|
|
|
|
|
2076
|
|
|
|
|
|
|
*max = \&PDL::max; |
|
2077
|
|
|
|
|
|
|
sub PDL::max { $_[0]->flat->maximum } |
|
2078
|
|
|
|
|
|
|
|
|
2079
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
2080
|
|
|
|
|
|
|
|
|
2081
|
|
|
|
|
|
|
=head2 median |
|
2082
|
|
|
|
|
|
|
|
|
2083
|
|
|
|
|
|
|
=for ref |
|
2084
|
|
|
|
|
|
|
|
|
2085
|
|
|
|
|
|
|
Return the median of all elements in an ndarray. |
|
2086
|
|
|
|
|
|
|
|
|
2087
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
2088
|
|
|
|
|
|
|
|
|
2089
|
|
|
|
|
|
|
=for usage |
|
2090
|
|
|
|
|
|
|
|
|
2091
|
|
|
|
|
|
|
$x = median($data); |
|
2092
|
|
|
|
|
|
|
|
|
2093
|
|
|
|
|
|
|
=for bad |
|
2094
|
|
|
|
|
|
|
|
|
2095
|
|
|
|
|
|
|
This routine handles bad values. |
|
2096
|
|
|
|
|
|
|
|
|
2097
|
|
|
|
|
|
|
=cut |
|
2098
|
|
|
|
|
|
|
|
|
2099
|
|
|
|
|
|
|
*median = \&PDL::median; |
|
2100
|
|
|
|
|
|
|
sub PDL::median { $_[0]->flat->medover } |
|
2101
|
|
|
|
|
|
|
|
|
2102
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
2103
|
|
|
|
|
|
|
|
|
2104
|
|
|
|
|
|
|
=head2 mode |
|
2105
|
|
|
|
|
|
|
|
|
2106
|
|
|
|
|
|
|
=for ref |
|
2107
|
|
|
|
|
|
|
|
|
2108
|
|
|
|
|
|
|
Return the mode of all elements in an ndarray. |
|
2109
|
|
|
|
|
|
|
|
|
2110
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
2111
|
|
|
|
|
|
|
|
|
2112
|
|
|
|
|
|
|
=for usage |
|
2113
|
|
|
|
|
|
|
|
|
2114
|
|
|
|
|
|
|
$x = mode($data); |
|
2115
|
|
|
|
|
|
|
|
|
2116
|
|
|
|
|
|
|
=for bad |
|
2117
|
|
|
|
|
|
|
|
|
2118
|
|
|
|
|
|
|
This routine handles bad values. |
|
2119
|
|
|
|
|
|
|
|
|
2120
|
|
|
|
|
|
|
=cut |
|
2121
|
|
|
|
|
|
|
|
|
2122
|
|
|
|
|
|
|
*mode = \&PDL::mode; |
|
2123
|
|
|
|
|
|
|
sub PDL::mode { $_[0]->flat->modeover } |
|
2124
|
|
|
|
|
|
|
|
|
2125
|
|
|
|
|
|
|
#line 649 "lib/PDL/Ufunc.pd" |
|
2126
|
|
|
|
|
|
|
|
|
2127
|
|
|
|
|
|
|
=head2 oddmedian |
|
2128
|
|
|
|
|
|
|
|
|
2129
|
|
|
|
|
|
|
=for ref |
|
2130
|
|
|
|
|
|
|
|
|
2131
|
|
|
|
|
|
|
Return the oddmedian of all elements in an ndarray. |
|
2132
|
|
|
|
|
|
|
|
|
2133
|
|
|
|
|
|
|
See the documentation for L for more information. |
|
2134
|
|
|
|
|
|
|
|
|
2135
|
|
|
|
|
|
|
=for usage |
|
2136
|
|
|
|
|
|
|
|
|
2137
|
|
|
|
|
|
|
$x = oddmedian($data); |
|
2138
|
|
|
|
|
|
|
|
|
2139
|
|
|
|
|
|
|
=for bad |
|
2140
|
|
|
|
|
|
|
|
|
2141
|
|
|
|
|
|
|
This routine handles bad values. |
|
2142
|
|
|
|
|
|
|
|
|
2143
|
|
|
|
|
|
|
=cut |
|
2144
|
|
|
|
|
|
|
|
|
2145
|
|
|
|
|
|
|
*oddmedian = \&PDL::oddmedian; |
|
2146
|
|
|
|
|
|
|
sub PDL::oddmedian { $_[0]->flat->oddmedover } |
|
2147
|
|
|
|
|
|
|
|
|
2148
|
|
|
|
|
|
|
#line 675 "lib/PDL/Ufunc.pd" |
|
2149
|
|
|
|
|
|
|
|
|
2150
|
|
|
|
|
|
|
=head2 any |
|
2151
|
|
|
|
|
|
|
|
|
2152
|
|
|
|
|
|
|
=for ref |
|
2153
|
|
|
|
|
|
|
|
|
2154
|
|
|
|
|
|
|
Return true if any element in ndarray set |
|
2155
|
|
|
|
|
|
|
|
|
2156
|
|
|
|
|
|
|
Useful in conditional expressions: |
|
2157
|
|
|
|
|
|
|
|
|
2158
|
|
|
|
|
|
|
=for example |
|
2159
|
|
|
|
|
|
|
|
|
2160
|
|
|
|
|
|
|
if (any $x>15) { print "some values are greater than 15\n" } |
|
2161
|
|
|
|
|
|
|
|
|
2162
|
|
|
|
|
|
|
=for bad |
|
2163
|
|
|
|
|
|
|
|
|
2164
|
|
|
|
|
|
|
See L for comments on what happens when all elements |
|
2165
|
|
|
|
|
|
|
in the check are bad. |
|
2166
|
|
|
|
|
|
|
|
|
2167
|
|
|
|
|
|
|
=cut |
|
2168
|
|
|
|
|
|
|
|
|
2169
|
|
|
|
|
|
|
*any = \∨ |
|
2170
|
|
|
|
|
|
|
*PDL::any = \&PDL::or; |
|
2171
|
|
|
|
|
|
|
|
|
2172
|
|
|
|
|
|
|
=head2 all |
|
2173
|
|
|
|
|
|
|
|
|
2174
|
|
|
|
|
|
|
=for ref |
|
2175
|
|
|
|
|
|
|
|
|
2176
|
|
|
|
|
|
|
Return true if all elements in ndarray set |
|
2177
|
|
|
|
|
|
|
|
|
2178
|
|
|
|
|
|
|
Useful in conditional expressions: |
|
2179
|
|
|
|
|
|
|
|
|
2180
|
|
|
|
|
|
|
=for example |
|
2181
|
|
|
|
|
|
|
|
|
2182
|
|
|
|
|
|
|
if (all $x>15) { print "all values are greater than 15\n" } |
|
2183
|
|
|
|
|
|
|
|
|
2184
|
|
|
|
|
|
|
=for bad |
|
2185
|
|
|
|
|
|
|
|
|
2186
|
|
|
|
|
|
|
See L for comments on what happens when all elements |
|
2187
|
|
|
|
|
|
|
in the check are bad. |
|
2188
|
|
|
|
|
|
|
|
|
2189
|
|
|
|
|
|
|
=cut |
|
2190
|
|
|
|
|
|
|
|
|
2191
|
|
|
|
|
|
|
*all = \∧ |
|
2192
|
|
|
|
|
|
|
*PDL::all = \&PDL::and; |
|
2193
|
|
|
|
|
|
|
|
|
2194
|
|
|
|
|
|
|
=head2 minmax |
|
2195
|
|
|
|
|
|
|
|
|
2196
|
|
|
|
|
|
|
=for ref |
|
2197
|
|
|
|
|
|
|
|
|
2198
|
|
|
|
|
|
|
Returns a list with minimum and maximum values of an ndarray. |
|
2199
|
|
|
|
|
|
|
|
|
2200
|
|
|
|
|
|
|
=for usage |
|
2201
|
|
|
|
|
|
|
|
|
2202
|
|
|
|
|
|
|
($mn, $mx) = minmax($pdl); |
|
2203
|
|
|
|
|
|
|
|
|
2204
|
|
|
|
|
|
|
This routine does I broadcast over the dimensions of C<$pdl>; |
|
2205
|
|
|
|
|
|
|
it returns the minimum and maximum values of the whole ndarray. |
|
2206
|
|
|
|
|
|
|
See L if this is not what is required. |
|
2207
|
|
|
|
|
|
|
The two values are returned as Perl scalars, |
|
2208
|
|
|
|
|
|
|
and therefore ignore whether the values are bad. |
|
2209
|
|
|
|
|
|
|
|
|
2210
|
|
|
|
|
|
|
=for example |
|
2211
|
|
|
|
|
|
|
|
|
2212
|
|
|
|
|
|
|
pdl> $x = pdl [1,-2,3,5,0] |
|
2213
|
|
|
|
|
|
|
pdl> ($min, $max) = minmax($x); |
|
2214
|
|
|
|
|
|
|
pdl> p "$min $max\n"; |
|
2215
|
|
|
|
|
|
|
-2 5 |
|
2216
|
|
|
|
|
|
|
|
|
2217
|
|
|
|
|
|
|
=cut |
|
2218
|
|
|
|
|
|
|
|
|
2219
|
|
|
|
|
|
|
*minmax = \&PDL::minmax; |
|
2220
|
|
|
|
|
|
|
sub PDL::minmax { map $_->sclr, ($_[0]->flat->minmaximum)[0,1] } |
|
2221
|
|
|
|
|
|
|
#line 2222 "lib/PDL/Ufunc.pm" |
|
2222
|
|
|
|
|
|
|
|
|
2223
|
|
|
|
|
|
|
|
|
2224
|
|
|
|
|
|
|
=head2 medover |
|
2225
|
|
|
|
|
|
|
|
|
2226
|
|
|
|
|
|
|
=for sig |
|
2227
|
|
|
|
|
|
|
|
|
2228
|
|
|
|
|
|
|
Signature: (a(n); [o]b(); [t]tmp(n)) |
|
2229
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
2230
|
|
|
|
|
|
|
float double ldouble) |
|
2231
|
|
|
|
|
|
|
|
|
2232
|
|
|
|
|
|
|
=for usage |
|
2233
|
|
|
|
|
|
|
|
|
2234
|
|
|
|
|
|
|
$b = medover($a); |
|
2235
|
|
|
|
|
|
|
medover($a, $b); # all arguments given |
|
2236
|
|
|
|
|
|
|
$b = $a->medover; # method call |
|
2237
|
|
|
|
|
|
|
$a->medover($b); |
|
2238
|
|
|
|
|
|
|
|
|
2239
|
|
|
|
|
|
|
=for ref |
|
2240
|
|
|
|
|
|
|
|
|
2241
|
|
|
|
|
|
|
Project via median to N-1 dimensions |
|
2242
|
|
|
|
|
|
|
|
|
2243
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
2244
|
|
|
|
|
|
|
by one by taking the median along the 1st dimension. |
|
2245
|
|
|
|
|
|
|
|
|
2246
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
2247
|
|
|
|
|
|
|
I dimension. |
|
2248
|
|
|
|
|
|
|
|
|
2249
|
|
|
|
|
|
|
=pod |
|
2250
|
|
|
|
|
|
|
|
|
2251
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
2252
|
|
|
|
|
|
|
|
|
2253
|
|
|
|
|
|
|
=for bad |
|
2254
|
|
|
|
|
|
|
|
|
2255
|
|
|
|
|
|
|
C processes bad values. |
|
2256
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
2257
|
|
|
|
|
|
|
|
|
2258
|
|
|
|
|
|
|
=cut |
|
2259
|
|
|
|
|
|
|
|
|
2260
|
|
|
|
|
|
|
|
|
2261
|
|
|
|
|
|
|
|
|
2262
|
|
|
|
|
|
|
|
|
2263
|
|
|
|
|
|
|
*medover = \&PDL::medover; |
|
2264
|
|
|
|
|
|
|
|
|
2265
|
|
|
|
|
|
|
|
|
2266
|
|
|
|
|
|
|
|
|
2267
|
|
|
|
|
|
|
|
|
2268
|
|
|
|
|
|
|
|
|
2269
|
|
|
|
|
|
|
|
|
2270
|
|
|
|
|
|
|
=head2 oddmedover |
|
2271
|
|
|
|
|
|
|
|
|
2272
|
|
|
|
|
|
|
=for sig |
|
2273
|
|
|
|
|
|
|
|
|
2274
|
|
|
|
|
|
|
Signature: (a(n); [o]b(); [t]tmp(n)) |
|
2275
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
2276
|
|
|
|
|
|
|
float double ldouble) |
|
2277
|
|
|
|
|
|
|
|
|
2278
|
|
|
|
|
|
|
=for usage |
|
2279
|
|
|
|
|
|
|
|
|
2280
|
|
|
|
|
|
|
$b = oddmedover($a); |
|
2281
|
|
|
|
|
|
|
oddmedover($a, $b); # all arguments given |
|
2282
|
|
|
|
|
|
|
$b = $a->oddmedover; # method call |
|
2283
|
|
|
|
|
|
|
$a->oddmedover($b); |
|
2284
|
|
|
|
|
|
|
|
|
2285
|
|
|
|
|
|
|
=for ref |
|
2286
|
|
|
|
|
|
|
|
|
2287
|
|
|
|
|
|
|
Project via oddmedian to N-1 dimensions |
|
2288
|
|
|
|
|
|
|
|
|
2289
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
2290
|
|
|
|
|
|
|
by one by taking the oddmedian along the 1st dimension. |
|
2291
|
|
|
|
|
|
|
|
|
2292
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
2293
|
|
|
|
|
|
|
I dimension. |
|
2294
|
|
|
|
|
|
|
|
|
2295
|
|
|
|
|
|
|
The median is sometimes not a good choice as if the array has |
|
2296
|
|
|
|
|
|
|
an even number of elements it lies half-way between the two |
|
2297
|
|
|
|
|
|
|
middle values - thus it does not always correspond to a data |
|
2298
|
|
|
|
|
|
|
value. The lower-odd median is just the lower of these two values |
|
2299
|
|
|
|
|
|
|
and so it ALWAYS sits on an actual data value which is useful in |
|
2300
|
|
|
|
|
|
|
some circumstances. |
|
2301
|
|
|
|
|
|
|
|
|
2302
|
|
|
|
|
|
|
|
|
2303
|
|
|
|
|
|
|
=pod |
|
2304
|
|
|
|
|
|
|
|
|
2305
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
2306
|
|
|
|
|
|
|
|
|
2307
|
|
|
|
|
|
|
=for bad |
|
2308
|
|
|
|
|
|
|
|
|
2309
|
|
|
|
|
|
|
C processes bad values. |
|
2310
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
2311
|
|
|
|
|
|
|
|
|
2312
|
|
|
|
|
|
|
=cut |
|
2313
|
|
|
|
|
|
|
|
|
2314
|
|
|
|
|
|
|
|
|
2315
|
|
|
|
|
|
|
|
|
2316
|
|
|
|
|
|
|
|
|
2317
|
|
|
|
|
|
|
*oddmedover = \&PDL::oddmedover; |
|
2318
|
|
|
|
|
|
|
|
|
2319
|
|
|
|
|
|
|
|
|
2320
|
|
|
|
|
|
|
|
|
2321
|
|
|
|
|
|
|
|
|
2322
|
|
|
|
|
|
|
|
|
2323
|
|
|
|
|
|
|
|
|
2324
|
|
|
|
|
|
|
=head2 modeover |
|
2325
|
|
|
|
|
|
|
|
|
2326
|
|
|
|
|
|
|
=for sig |
|
2327
|
|
|
|
|
|
|
|
|
2328
|
|
|
|
|
|
|
Signature: (data(n); [o]out(); [t]sorted(n)) |
|
2329
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong) |
|
2330
|
|
|
|
|
|
|
|
|
2331
|
|
|
|
|
|
|
=for usage |
|
2332
|
|
|
|
|
|
|
|
|
2333
|
|
|
|
|
|
|
$out = modeover($data); |
|
2334
|
|
|
|
|
|
|
modeover($data, $out); # all arguments given |
|
2335
|
|
|
|
|
|
|
$out = $data->modeover; # method call |
|
2336
|
|
|
|
|
|
|
$data->modeover($out); |
|
2337
|
|
|
|
|
|
|
|
|
2338
|
|
|
|
|
|
|
=for ref |
|
2339
|
|
|
|
|
|
|
|
|
2340
|
|
|
|
|
|
|
Project via mode to N-1 dimensions |
|
2341
|
|
|
|
|
|
|
|
|
2342
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
2343
|
|
|
|
|
|
|
by one by taking the mode along the 1st dimension. |
|
2344
|
|
|
|
|
|
|
|
|
2345
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
2346
|
|
|
|
|
|
|
I dimension. |
|
2347
|
|
|
|
|
|
|
|
|
2348
|
|
|
|
|
|
|
The mode is the single element most frequently found in a |
|
2349
|
|
|
|
|
|
|
discrete data set. |
|
2350
|
|
|
|
|
|
|
|
|
2351
|
|
|
|
|
|
|
It I makes sense for integer data types, since |
|
2352
|
|
|
|
|
|
|
floating-point types are demoted to integer before the |
|
2353
|
|
|
|
|
|
|
mode is calculated. |
|
2354
|
|
|
|
|
|
|
|
|
2355
|
|
|
|
|
|
|
C treats BAD the same as any other value: if |
|
2356
|
|
|
|
|
|
|
BAD is the most common element, the returned value is also BAD. |
|
2357
|
|
|
|
|
|
|
|
|
2358
|
|
|
|
|
|
|
=pod |
|
2359
|
|
|
|
|
|
|
|
|
2360
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
2361
|
|
|
|
|
|
|
|
|
2362
|
|
|
|
|
|
|
=for bad |
|
2363
|
|
|
|
|
|
|
|
|
2364
|
|
|
|
|
|
|
C does not process bad values. |
|
2365
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
2366
|
|
|
|
|
|
|
|
|
2367
|
|
|
|
|
|
|
=cut |
|
2368
|
|
|
|
|
|
|
|
|
2369
|
|
|
|
|
|
|
|
|
2370
|
|
|
|
|
|
|
|
|
2371
|
|
|
|
|
|
|
|
|
2372
|
|
|
|
|
|
|
*modeover = \&PDL::modeover; |
|
2373
|
|
|
|
|
|
|
|
|
2374
|
|
|
|
|
|
|
|
|
2375
|
|
|
|
|
|
|
|
|
2376
|
|
|
|
|
|
|
|
|
2377
|
|
|
|
|
|
|
|
|
2378
|
|
|
|
|
|
|
|
|
2379
|
|
|
|
|
|
|
=head2 pctover |
|
2380
|
|
|
|
|
|
|
|
|
2381
|
|
|
|
|
|
|
=for sig |
|
2382
|
|
|
|
|
|
|
|
|
2383
|
|
|
|
|
|
|
Signature: (a(n); p(); [o]b(); [t]tmp(n)) |
|
2384
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
2385
|
|
|
|
|
|
|
float double ldouble) |
|
2386
|
|
|
|
|
|
|
|
|
2387
|
|
|
|
|
|
|
=for usage |
|
2388
|
|
|
|
|
|
|
|
|
2389
|
|
|
|
|
|
|
$b = pctover($a, $p); |
|
2390
|
|
|
|
|
|
|
pctover($a, $p, $b); # all arguments given |
|
2391
|
|
|
|
|
|
|
$b = $a->pctover($p); # method call |
|
2392
|
|
|
|
|
|
|
$a->pctover($p, $b); |
|
2393
|
|
|
|
|
|
|
|
|
2394
|
|
|
|
|
|
|
=for ref |
|
2395
|
|
|
|
|
|
|
|
|
2396
|
|
|
|
|
|
|
Project via specified percentile to N-1 dimensions |
|
2397
|
|
|
|
|
|
|
|
|
2398
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
2399
|
|
|
|
|
|
|
by one by taking the specified percentile along the 1st dimension. |
|
2400
|
|
|
|
|
|
|
|
|
2401
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
2402
|
|
|
|
|
|
|
I dimension. |
|
2403
|
|
|
|
|
|
|
|
|
2404
|
|
|
|
|
|
|
The specified |
|
2405
|
|
|
|
|
|
|
percentile must be between 0.0 and 1.0. When the specified percentile |
|
2406
|
|
|
|
|
|
|
falls between data points, the result is interpolated. Values outside |
|
2407
|
|
|
|
|
|
|
the allowed range are clipped to 0.0 or 1.0 respectively. The algorithm |
|
2408
|
|
|
|
|
|
|
implemented here is based on the interpolation variant described at |
|
2409
|
|
|
|
|
|
|
L as used by Microsoft Excel |
|
2410
|
|
|
|
|
|
|
and recommended by NIST. |
|
2411
|
|
|
|
|
|
|
|
|
2412
|
|
|
|
|
|
|
=pod |
|
2413
|
|
|
|
|
|
|
|
|
2414
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
2415
|
|
|
|
|
|
|
|
|
2416
|
|
|
|
|
|
|
=for bad |
|
2417
|
|
|
|
|
|
|
|
|
2418
|
|
|
|
|
|
|
C processes bad values. |
|
2419
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
2420
|
|
|
|
|
|
|
|
|
2421
|
|
|
|
|
|
|
=cut |
|
2422
|
|
|
|
|
|
|
|
|
2423
|
|
|
|
|
|
|
|
|
2424
|
|
|
|
|
|
|
|
|
2425
|
|
|
|
|
|
|
|
|
2426
|
|
|
|
|
|
|
*pctover = \&PDL::pctover; |
|
2427
|
|
|
|
|
|
|
|
|
2428
|
|
|
|
|
|
|
|
|
2429
|
|
|
|
|
|
|
|
|
2430
|
|
|
|
|
|
|
|
|
2431
|
|
|
|
|
|
|
|
|
2432
|
|
|
|
|
|
|
|
|
2433
|
|
|
|
|
|
|
=head2 oddpctover |
|
2434
|
|
|
|
|
|
|
|
|
2435
|
|
|
|
|
|
|
=for sig |
|
2436
|
|
|
|
|
|
|
|
|
2437
|
|
|
|
|
|
|
Signature: (a(n); p(); [o]b(); [t]tmp(n)) |
|
2438
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
2439
|
|
|
|
|
|
|
float double ldouble) |
|
2440
|
|
|
|
|
|
|
|
|
2441
|
|
|
|
|
|
|
=for usage |
|
2442
|
|
|
|
|
|
|
|
|
2443
|
|
|
|
|
|
|
$b = oddpctover($a, $p); |
|
2444
|
|
|
|
|
|
|
oddpctover($a, $p, $b); # all arguments given |
|
2445
|
|
|
|
|
|
|
$b = $a->oddpctover($p); # method call |
|
2446
|
|
|
|
|
|
|
$a->oddpctover($p, $b); |
|
2447
|
|
|
|
|
|
|
|
|
2448
|
|
|
|
|
|
|
=for ref |
|
2449
|
|
|
|
|
|
|
|
|
2450
|
|
|
|
|
|
|
Project via specified percentile to N-1 dimensions |
|
2451
|
|
|
|
|
|
|
|
|
2452
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
2453
|
|
|
|
|
|
|
by one by taking the specified percentile along the 1st dimension. |
|
2454
|
|
|
|
|
|
|
|
|
2455
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
2456
|
|
|
|
|
|
|
I dimension. |
|
2457
|
|
|
|
|
|
|
|
|
2458
|
|
|
|
|
|
|
The specified |
|
2459
|
|
|
|
|
|
|
percentile must be between 0.0 and 1.0. When the specified percentile |
|
2460
|
|
|
|
|
|
|
falls between two values, the nearest data value is the result. |
|
2461
|
|
|
|
|
|
|
The algorithm implemented is from the textbook version described |
|
2462
|
|
|
|
|
|
|
first at L. |
|
2463
|
|
|
|
|
|
|
|
|
2464
|
|
|
|
|
|
|
=pod |
|
2465
|
|
|
|
|
|
|
|
|
2466
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
2467
|
|
|
|
|
|
|
|
|
2468
|
|
|
|
|
|
|
=for bad |
|
2469
|
|
|
|
|
|
|
|
|
2470
|
|
|
|
|
|
|
C processes bad values. |
|
2471
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
2472
|
|
|
|
|
|
|
|
|
2473
|
|
|
|
|
|
|
=cut |
|
2474
|
|
|
|
|
|
|
|
|
2475
|
|
|
|
|
|
|
|
|
2476
|
|
|
|
|
|
|
|
|
2477
|
|
|
|
|
|
|
|
|
2478
|
|
|
|
|
|
|
*oddpctover = \&PDL::oddpctover; |
|
2479
|
|
|
|
|
|
|
|
|
2480
|
|
|
|
|
|
|
|
|
2481
|
|
|
|
|
|
|
|
|
2482
|
|
|
|
|
|
|
|
|
2483
|
|
|
|
|
|
|
|
|
2484
|
|
|
|
|
|
|
#line 1023 "lib/PDL/Ufunc.pd" |
|
2485
|
|
|
|
|
|
|
|
|
2486
|
|
|
|
|
|
|
=head2 pct |
|
2487
|
|
|
|
|
|
|
|
|
2488
|
|
|
|
|
|
|
=for ref |
|
2489
|
|
|
|
|
|
|
|
|
2490
|
|
|
|
|
|
|
Return the specified percentile of all elements in an ndarray. The |
|
2491
|
|
|
|
|
|
|
specified percentile (p) must be between 0.0 and 1.0. When the |
|
2492
|
|
|
|
|
|
|
specified percentile falls between data points, the result is interpolated. |
|
2493
|
|
|
|
|
|
|
|
|
2494
|
|
|
|
|
|
|
=for usage |
|
2495
|
|
|
|
|
|
|
|
|
2496
|
|
|
|
|
|
|
$x = pct($data, $pct); |
|
2497
|
|
|
|
|
|
|
|
|
2498
|
|
|
|
|
|
|
=cut |
|
2499
|
|
|
|
|
|
|
|
|
2500
|
|
|
|
|
|
|
*pct = \&PDL::pct; |
|
2501
|
|
|
|
|
|
|
sub PDL::pct { |
|
2502
|
|
|
|
|
|
|
my($x, $p) = @_; |
|
2503
|
|
|
|
|
|
|
$x->flat->pctover($p, my $tmp=PDL->nullcreate($x)); |
|
2504
|
|
|
|
|
|
|
$tmp; |
|
2505
|
|
|
|
|
|
|
} |
|
2506
|
|
|
|
|
|
|
|
|
2507
|
|
|
|
|
|
|
#line 1023 "lib/PDL/Ufunc.pd" |
|
2508
|
|
|
|
|
|
|
|
|
2509
|
|
|
|
|
|
|
=head2 oddpct |
|
2510
|
|
|
|
|
|
|
|
|
2511
|
|
|
|
|
|
|
=for ref |
|
2512
|
|
|
|
|
|
|
|
|
2513
|
|
|
|
|
|
|
Return the specified percentile of all elements in an ndarray. The |
|
2514
|
|
|
|
|
|
|
specified percentile (p) must be between 0.0 and 1.0. When the |
|
2515
|
|
|
|
|
|
|
specified percentile falls between data points, the nearest data value is the result. |
|
2516
|
|
|
|
|
|
|
|
|
2517
|
|
|
|
|
|
|
=for usage |
|
2518
|
|
|
|
|
|
|
|
|
2519
|
|
|
|
|
|
|
$x = oddpct($data, $pct); |
|
2520
|
|
|
|
|
|
|
|
|
2521
|
|
|
|
|
|
|
=cut |
|
2522
|
|
|
|
|
|
|
|
|
2523
|
|
|
|
|
|
|
*oddpct = \&PDL::oddpct; |
|
2524
|
|
|
|
|
|
|
sub PDL::oddpct { |
|
2525
|
|
|
|
|
|
|
my($x, $p) = @_; |
|
2526
|
|
|
|
|
|
|
$x->flat->oddpctover($p, my $tmp=PDL->nullcreate($x)); |
|
2527
|
|
|
|
|
|
|
$tmp; |
|
2528
|
|
|
|
|
|
|
} |
|
2529
|
|
|
|
|
|
|
#line 2530 "lib/PDL/Ufunc.pm" |
|
2530
|
|
|
|
|
|
|
|
|
2531
|
|
|
|
|
|
|
|
|
2532
|
|
|
|
|
|
|
=head2 qsort |
|
2533
|
|
|
|
|
|
|
|
|
2534
|
|
|
|
|
|
|
=for sig |
|
2535
|
|
|
|
|
|
|
|
|
2536
|
|
|
|
|
|
|
Signature: (!complex a(n); !complex [o]b(n)) |
|
2537
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
2538
|
|
|
|
|
|
|
float double ldouble) |
|
2539
|
|
|
|
|
|
|
|
|
2540
|
|
|
|
|
|
|
=for usage |
|
2541
|
|
|
|
|
|
|
|
|
2542
|
|
|
|
|
|
|
$b = qsort($a); |
|
2543
|
|
|
|
|
|
|
qsort($a, $b); # all arguments given |
|
2544
|
|
|
|
|
|
|
$b = $a->qsort; # method call |
|
2545
|
|
|
|
|
|
|
$a->qsort($b); |
|
2546
|
|
|
|
|
|
|
$a->inplace->qsort; # can be used inplace |
|
2547
|
|
|
|
|
|
|
qsort($a->inplace); |
|
2548
|
|
|
|
|
|
|
|
|
2549
|
|
|
|
|
|
|
=for ref |
|
2550
|
|
|
|
|
|
|
|
|
2551
|
|
|
|
|
|
|
Quicksort a vector into ascending order. |
|
2552
|
|
|
|
|
|
|
|
|
2553
|
|
|
|
|
|
|
=pod |
|
2554
|
|
|
|
|
|
|
|
|
2555
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
2556
|
|
|
|
|
|
|
|
|
2557
|
|
|
|
|
|
|
=for bad |
|
2558
|
|
|
|
|
|
|
|
|
2559
|
|
|
|
|
|
|
Bad values are moved to the end of the array: |
|
2560
|
|
|
|
|
|
|
|
|
2561
|
|
|
|
|
|
|
pdl> p $y |
|
2562
|
|
|
|
|
|
|
[42 47 98 BAD 22 96 74 41 79 76 96 BAD 32 76 25 59 BAD 96 32 BAD] |
|
2563
|
|
|
|
|
|
|
pdl> p qsort($y) |
|
2564
|
|
|
|
|
|
|
[22 25 32 32 41 42 47 59 74 76 76 79 96 96 96 98 BAD BAD BAD BAD] |
|
2565
|
|
|
|
|
|
|
|
|
2566
|
|
|
|
|
|
|
=cut |
|
2567
|
|
|
|
|
|
|
|
|
2568
|
|
|
|
|
|
|
|
|
2569
|
|
|
|
|
|
|
|
|
2570
|
|
|
|
|
|
|
|
|
2571
|
|
|
|
|
|
|
*qsort = \&PDL::qsort; |
|
2572
|
|
|
|
|
|
|
|
|
2573
|
|
|
|
|
|
|
|
|
2574
|
|
|
|
|
|
|
|
|
2575
|
|
|
|
|
|
|
|
|
2576
|
|
|
|
|
|
|
|
|
2577
|
|
|
|
|
|
|
|
|
2578
|
|
|
|
|
|
|
=head2 qsorti |
|
2579
|
|
|
|
|
|
|
|
|
2580
|
|
|
|
|
|
|
=for sig |
|
2581
|
|
|
|
|
|
|
|
|
2582
|
|
|
|
|
|
|
Signature: (!complex a(n); indx [o]indx(n)) |
|
2583
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
2584
|
|
|
|
|
|
|
float double ldouble) |
|
2585
|
|
|
|
|
|
|
|
|
2586
|
|
|
|
|
|
|
=for usage |
|
2587
|
|
|
|
|
|
|
|
|
2588
|
|
|
|
|
|
|
$indx = qsorti($a); |
|
2589
|
|
|
|
|
|
|
qsorti($a, $indx); # all arguments given |
|
2590
|
|
|
|
|
|
|
$indx = $a->qsorti; # method call |
|
2591
|
|
|
|
|
|
|
$a->qsorti($indx); |
|
2592
|
|
|
|
|
|
|
|
|
2593
|
|
|
|
|
|
|
=for ref |
|
2594
|
|
|
|
|
|
|
|
|
2595
|
|
|
|
|
|
|
Quicksort a vector and return index of elements in ascending order. |
|
2596
|
|
|
|
|
|
|
|
|
2597
|
|
|
|
|
|
|
=for example |
|
2598
|
|
|
|
|
|
|
|
|
2599
|
|
|
|
|
|
|
$ix = qsorti $x; |
|
2600
|
|
|
|
|
|
|
print $x->index($ix); # Sorted list |
|
2601
|
|
|
|
|
|
|
|
|
2602
|
|
|
|
|
|
|
=pod |
|
2603
|
|
|
|
|
|
|
|
|
2604
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
2605
|
|
|
|
|
|
|
|
|
2606
|
|
|
|
|
|
|
=for bad |
|
2607
|
|
|
|
|
|
|
|
|
2608
|
|
|
|
|
|
|
Bad elements are moved to the end of the array: |
|
2609
|
|
|
|
|
|
|
|
|
2610
|
|
|
|
|
|
|
pdl> p $y |
|
2611
|
|
|
|
|
|
|
[42 47 98 BAD 22 96 74 41 79 76 96 BAD 32 76 25 59 BAD 96 32 BAD] |
|
2612
|
|
|
|
|
|
|
pdl> p $y->index( qsorti($y) ) |
|
2613
|
|
|
|
|
|
|
[22 25 32 32 41 42 47 59 74 76 76 79 96 96 96 98 BAD BAD BAD BAD] |
|
2614
|
|
|
|
|
|
|
|
|
2615
|
|
|
|
|
|
|
=cut |
|
2616
|
|
|
|
|
|
|
|
|
2617
|
|
|
|
|
|
|
|
|
2618
|
|
|
|
|
|
|
|
|
2619
|
|
|
|
|
|
|
|
|
2620
|
|
|
|
|
|
|
*qsorti = \&PDL::qsorti; |
|
2621
|
|
|
|
|
|
|
|
|
2622
|
|
|
|
|
|
|
|
|
2623
|
|
|
|
|
|
|
|
|
2624
|
|
|
|
|
|
|
|
|
2625
|
|
|
|
|
|
|
|
|
2626
|
|
|
|
|
|
|
|
|
2627
|
|
|
|
|
|
|
=head2 qsortvec |
|
2628
|
|
|
|
|
|
|
|
|
2629
|
|
|
|
|
|
|
=for sig |
|
2630
|
|
|
|
|
|
|
|
|
2631
|
|
|
|
|
|
|
Signature: (!complex a(n,m); !complex [o]b(n,m)) |
|
2632
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
2633
|
|
|
|
|
|
|
float double ldouble) |
|
2634
|
|
|
|
|
|
|
|
|
2635
|
|
|
|
|
|
|
=for usage |
|
2636
|
|
|
|
|
|
|
|
|
2637
|
|
|
|
|
|
|
$b = qsortvec($a); |
|
2638
|
|
|
|
|
|
|
qsortvec($a, $b); # all arguments given |
|
2639
|
|
|
|
|
|
|
$b = $a->qsortvec; # method call |
|
2640
|
|
|
|
|
|
|
$a->qsortvec($b); |
|
2641
|
|
|
|
|
|
|
$a->inplace->qsortvec; # can be used inplace |
|
2642
|
|
|
|
|
|
|
qsortvec($a->inplace); |
|
2643
|
|
|
|
|
|
|
|
|
2644
|
|
|
|
|
|
|
=for ref |
|
2645
|
|
|
|
|
|
|
|
|
2646
|
|
|
|
|
|
|
Sort a list of vectors lexicographically. |
|
2647
|
|
|
|
|
|
|
|
|
2648
|
|
|
|
|
|
|
The 0th dimension of the source ndarray is dimension in the vector; |
|
2649
|
|
|
|
|
|
|
the 1st dimension is list order. Higher dimensions are broadcasted over. |
|
2650
|
|
|
|
|
|
|
|
|
2651
|
|
|
|
|
|
|
=for example |
|
2652
|
|
|
|
|
|
|
|
|
2653
|
|
|
|
|
|
|
print qsortvec pdl([[1,2],[0,500],[2,3],[4,2],[3,4],[3,5]]); |
|
2654
|
|
|
|
|
|
|
[ |
|
2655
|
|
|
|
|
|
|
[ 0 500] |
|
2656
|
|
|
|
|
|
|
[ 1 2] |
|
2657
|
|
|
|
|
|
|
[ 2 3] |
|
2658
|
|
|
|
|
|
|
[ 3 4] |
|
2659
|
|
|
|
|
|
|
[ 3 5] |
|
2660
|
|
|
|
|
|
|
[ 4 2] |
|
2661
|
|
|
|
|
|
|
] |
|
2662
|
|
|
|
|
|
|
|
|
2663
|
|
|
|
|
|
|
=pod |
|
2664
|
|
|
|
|
|
|
|
|
2665
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
2666
|
|
|
|
|
|
|
|
|
2667
|
|
|
|
|
|
|
=for bad |
|
2668
|
|
|
|
|
|
|
|
|
2669
|
|
|
|
|
|
|
Vectors with bad components are moved to the end of the array: |
|
2670
|
|
|
|
|
|
|
|
|
2671
|
|
|
|
|
|
|
pdl> p $p = pdl("[0 0] [-100 0] [BAD 0] [100 0]")->qsortvec |
|
2672
|
|
|
|
|
|
|
|
|
2673
|
|
|
|
|
|
|
[ |
|
2674
|
|
|
|
|
|
|
[-100 0] |
|
2675
|
|
|
|
|
|
|
[ 0 0] |
|
2676
|
|
|
|
|
|
|
[ 100 0] |
|
2677
|
|
|
|
|
|
|
[ BAD 0] |
|
2678
|
|
|
|
|
|
|
] |
|
2679
|
|
|
|
|
|
|
|
|
2680
|
|
|
|
|
|
|
=cut |
|
2681
|
|
|
|
|
|
|
|
|
2682
|
|
|
|
|
|
|
|
|
2683
|
|
|
|
|
|
|
|
|
2684
|
|
|
|
|
|
|
|
|
2685
|
|
|
|
|
|
|
*qsortvec = \&PDL::qsortvec; |
|
2686
|
|
|
|
|
|
|
|
|
2687
|
|
|
|
|
|
|
|
|
2688
|
|
|
|
|
|
|
|
|
2689
|
|
|
|
|
|
|
|
|
2690
|
|
|
|
|
|
|
|
|
2691
|
|
|
|
|
|
|
|
|
2692
|
|
|
|
|
|
|
=head2 qsortveci |
|
2693
|
|
|
|
|
|
|
|
|
2694
|
|
|
|
|
|
|
=for sig |
|
2695
|
|
|
|
|
|
|
|
|
2696
|
|
|
|
|
|
|
Signature: (!complex a(n,m); indx [o]indx(m)) |
|
2697
|
|
|
|
|
|
|
Types: (sbyte byte short ushort long ulong indx ulonglong longlong |
|
2698
|
|
|
|
|
|
|
float double ldouble) |
|
2699
|
|
|
|
|
|
|
|
|
2700
|
|
|
|
|
|
|
=for usage |
|
2701
|
|
|
|
|
|
|
|
|
2702
|
|
|
|
|
|
|
$indx = qsortveci($a); |
|
2703
|
|
|
|
|
|
|
qsortveci($a, $indx); # all arguments given |
|
2704
|
|
|
|
|
|
|
$indx = $a->qsortveci; # method call |
|
2705
|
|
|
|
|
|
|
$a->qsortveci($indx); |
|
2706
|
|
|
|
|
|
|
|
|
2707
|
|
|
|
|
|
|
=for ref |
|
2708
|
|
|
|
|
|
|
|
|
2709
|
|
|
|
|
|
|
Sort a list of vectors lexicographically, returning the indices of the |
|
2710
|
|
|
|
|
|
|
sorted vectors rather than the sorted list itself. |
|
2711
|
|
|
|
|
|
|
|
|
2712
|
|
|
|
|
|
|
As with C, the input PDL should be an NxM array containing M |
|
2713
|
|
|
|
|
|
|
separate N-dimensional vectors. The return value is an integer M-PDL |
|
2714
|
|
|
|
|
|
|
containing the M-indices of original array rows, in sorted order. |
|
2715
|
|
|
|
|
|
|
|
|
2716
|
|
|
|
|
|
|
As with C, the zeroth element of the vectors runs slowest in the |
|
2717
|
|
|
|
|
|
|
sorted list. |
|
2718
|
|
|
|
|
|
|
|
|
2719
|
|
|
|
|
|
|
Additional dimensions are broadcasted over: each plane is sorted separately, |
|
2720
|
|
|
|
|
|
|
so qsortveci may be thought of as a collapse operator of sorts (groan). |
|
2721
|
|
|
|
|
|
|
|
|
2722
|
|
|
|
|
|
|
=pod |
|
2723
|
|
|
|
|
|
|
|
|
2724
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
2725
|
|
|
|
|
|
|
|
|
2726
|
|
|
|
|
|
|
=for bad |
|
2727
|
|
|
|
|
|
|
|
|
2728
|
|
|
|
|
|
|
Vectors with bad components are moved to the end of the array as |
|
2729
|
|
|
|
|
|
|
for L. |
|
2730
|
|
|
|
|
|
|
|
|
2731
|
|
|
|
|
|
|
=cut |
|
2732
|
|
|
|
|
|
|
|
|
2733
|
|
|
|
|
|
|
|
|
2734
|
|
|
|
|
|
|
|
|
2735
|
|
|
|
|
|
|
|
|
2736
|
|
|
|
|
|
|
*qsortveci = \&PDL::qsortveci; |
|
2737
|
|
|
|
|
|
|
|
|
2738
|
|
|
|
|
|
|
|
|
2739
|
|
|
|
|
|
|
|
|
2740
|
|
|
|
|
|
|
|
|
2741
|
|
|
|
|
|
|
|
|
2742
|
|
|
|
|
|
|
|
|
2743
|
|
|
|
|
|
|
=head2 magnover |
|
2744
|
|
|
|
|
|
|
|
|
2745
|
|
|
|
|
|
|
=for sig |
|
2746
|
|
|
|
|
|
|
|
|
2747
|
|
|
|
|
|
|
Signature: (a(n); real [o]b()) |
|
2748
|
|
|
|
|
|
|
Types: (double ldouble cfloat cdouble cldouble float) |
|
2749
|
|
|
|
|
|
|
|
|
2750
|
|
|
|
|
|
|
=for usage |
|
2751
|
|
|
|
|
|
|
|
|
2752
|
|
|
|
|
|
|
$b = magnover($a); |
|
2753
|
|
|
|
|
|
|
magnover($a, $b); # all arguments given |
|
2754
|
|
|
|
|
|
|
$b = $a->magnover; # method call |
|
2755
|
|
|
|
|
|
|
$a->magnover($b); |
|
2756
|
|
|
|
|
|
|
|
|
2757
|
|
|
|
|
|
|
=for ref |
|
2758
|
|
|
|
|
|
|
|
|
2759
|
|
|
|
|
|
|
Project via Euclidean (aka Pythagorean) distance to N-1 dimensions |
|
2760
|
|
|
|
|
|
|
|
|
2761
|
|
|
|
|
|
|
This function reduces the dimensionality of an ndarray |
|
2762
|
|
|
|
|
|
|
by one by taking the Euclidean (aka Pythagorean) distance along the 1st dimension. |
|
2763
|
|
|
|
|
|
|
|
|
2764
|
|
|
|
|
|
|
By using L etc. it is possible to use |
|
2765
|
|
|
|
|
|
|
I dimension. |
|
2766
|
|
|
|
|
|
|
|
|
2767
|
|
|
|
|
|
|
Minimum C precision output. |
|
2768
|
|
|
|
|
|
|
See also L, L. |
|
2769
|
|
|
|
|
|
|
|
|
2770
|
|
|
|
|
|
|
=pod |
|
2771
|
|
|
|
|
|
|
|
|
2772
|
|
|
|
|
|
|
Broadcasts over its inputs. |
|
2773
|
|
|
|
|
|
|
|
|
2774
|
|
|
|
|
|
|
=for bad |
|
2775
|
|
|
|
|
|
|
|
|
2776
|
|
|
|
|
|
|
C processes bad values. |
|
2777
|
|
|
|
|
|
|
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. |
|
2778
|
|
|
|
|
|
|
|
|
2779
|
|
|
|
|
|
|
=cut |
|
2780
|
|
|
|
|
|
|
|
|
2781
|
|
|
|
|
|
|
|
|
2782
|
|
|
|
|
|
|
|
|
2783
|
|
|
|
|
|
|
|
|
2784
|
|
|
|
|
|
|
*magnover = \&PDL::magnover; |
|
2785
|
|
|
|
|
|
|
|
|
2786
|
|
|
|
|
|
|
|
|
2787
|
|
|
|
|
|
|
|
|
2788
|
|
|
|
|
|
|
|
|
2789
|
|
|
|
|
|
|
|
|
2790
|
|
|
|
|
|
|
|
|
2791
|
|
|
|
|
|
|
|
|
2792
|
|
|
|
|
|
|
#line 1267 "lib/PDL/Ufunc.pd" |
|
2793
|
|
|
|
|
|
|
|
|
2794
|
|
|
|
|
|
|
=head1 AUTHOR |
|
2795
|
|
|
|
|
|
|
|
|
2796
|
|
|
|
|
|
|
Copyright (C) Tuomas J. Lukka 1997 (lukka@husc.harvard.edu). |
|
2797
|
|
|
|
|
|
|
Contributions by Christian Soeller (c.soeller@auckland.ac.nz) |
|
2798
|
|
|
|
|
|
|
and Karl Glazebrook (kgb@aaoepp.aao.gov.au). All rights |
|
2799
|
|
|
|
|
|
|
reserved. There is no warranty. You are allowed to redistribute this |
|
2800
|
|
|
|
|
|
|
software / documentation under certain conditions. For details, see |
|
2801
|
|
|
|
|
|
|
the file COPYING in the PDL distribution. If this file is separated |
|
2802
|
|
|
|
|
|
|
from the PDL distribution, the copyright notice should be included in |
|
2803
|
|
|
|
|
|
|
the file. |
|
2804
|
|
|
|
|
|
|
|
|
2805
|
|
|
|
|
|
|
=cut |
|
2806
|
|
|
|
|
|
|
#line 2807 "lib/PDL/Ufunc.pm" |
|
2807
|
|
|
|
|
|
|
|
|
2808
|
|
|
|
|
|
|
# Exit with OK status |
|
2809
|
|
|
|
|
|
|
|
|
2810
|
|
|
|
|
|
|
1; |