|
0 |
|
0 | 1 |
#
|
1 | 2 |
# GENERATED WITH PDL::PP! Don't modify!
|
2 | 3 |
#
|
3 | 4 |
package PDL::VectorValued::Utils;
|
4 | 5 |
|
5 | |
our @EXPORT_OK = qw(rlevec rldvec enumvec enumvecg rleseq rldseq vsearchvec cmpvec vv_qsortvec vv_qsortveci vv_union vv_intersect vv_setdiff v_union v_intersect v_setdiff vv_vcos );
|
6 | |
our %EXPORT_TAGS = (Func=>\@EXPORT_OK);
|
|
6 |
@EXPORT_OK = qw( PDL::PP rlevec PDL::PP rldvec PDL::PP enumvec PDL::PP enumvecg PDL::PP rleseq PDL::PP rldseq PDL::PP vsearchvec PDL::PP cmpvec vv_qsortvec vv_qsortveci PDL::PP vv_union PDL::PP vv_intersect PDL::PP vv_setdiff PDL::PP v_union PDL::PP v_intersect PDL::PP v_setdiff PDL::PP vv_vcos );
|
|
7 |
%EXPORT_TAGS = (Func=>[@EXPORT_OK]);
|
7 | 8 |
|
8 | 9 |
use PDL::Core;
|
9 | 10 |
use PDL::Exporter;
|
10 | 11 |
use DynaLoader;
|
11 | 12 |
|
12 | 13 |
|
13 | |
our $VERSION = '1.0.15';
|
14 | |
our @ISA = ( 'PDL::Exporter','DynaLoader' );
|
|
14 |
|
|
15 |
$PDL::VectorValued::Utils::VERSION = 1.0.16;
|
|
16 |
@ISA = ( 'PDL::Exporter','DynaLoader' );
|
15 | 17 |
push @PDL::Core::PP, __PACKAGE__;
|
16 | 18 |
bootstrap PDL::VectorValued::Utils $VERSION;
|
17 | 19 |
|
|
19 | 21 |
|
20 | 22 |
|
21 | 23 |
|
22 | |
|
23 | |
#line 21 "utils.pd"
|
24 | |
|
25 | |
|
26 | 24 |
use strict;
|
27 | 25 |
|
28 | 26 |
=pod
|
|
40 | 38 |
## ... stuff happens
|
41 | 39 |
|
42 | 40 |
=cut
|
43 | |
#line 45 "Utils.pm"
|
|
41 |
|
44 | 42 |
|
45 | 43 |
|
46 | 44 |
|
|
49 | 47 |
|
50 | 48 |
=head1 FUNCTIONS
|
51 | 49 |
|
52 | |
=cut
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
#line 67 "utils.pd"
|
|
50 |
|
|
51 |
|
|
52 |
=cut
|
|
53 |
|
|
54 |
|
|
55 |
|
58 | 56 |
|
59 | 57 |
|
60 | 58 |
=pod
|
|
62 | 60 |
=head1 Vector-Based Run-Length Encoding and Decoding
|
63 | 61 |
|
64 | 62 |
=cut
|
65 | |
#line 67 "Utils.pm"
|
66 | |
|
67 | |
|
68 | |
|
69 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
63 |
|
|
64 |
|
70 | 65 |
|
71 | 66 |
|
72 | 67 |
|
|
96 | 91 |
=for bad
|
97 | 92 |
|
98 | 93 |
rlevec does not process bad values.
|
99 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
100 | |
|
101 | |
|
102 | |
=cut
|
103 | |
#line 105 "Utils.pm"
|
104 | |
|
105 | |
|
106 | |
|
107 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
94 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
95 |
|
|
96 |
|
|
97 |
=cut
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
108 | 103 |
|
109 | 104 |
*rlevec = \&PDL::rlevec;
|
110 | |
#line 112 "Utils.pm"
|
111 | |
|
112 | |
|
113 | |
|
114 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
105 |
|
|
106 |
|
115 | 107 |
|
116 | 108 |
|
117 | 109 |
|
|
135 | 127 |
=for bad
|
136 | 128 |
|
137 | 129 |
rldvec does not process bad values.
|
138 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
139 | |
|
140 | |
|
141 | |
=cut
|
142 | |
#line 144 "Utils.pm"
|
143 | |
|
144 | |
|
145 | |
|
146 | |
#line 1059 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
130 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
131 |
|
|
132 |
|
|
133 |
=cut
|
|
134 |
|
|
135 |
|
|
136 |
|
147 | 137 |
|
148 | 138 |
sub PDL::rldvec {
|
149 | 139 |
my ($a,$b,$c) = @_;
|
|
158 | 148 |
&PDL::_rldvec_int($a,$b,$c);
|
159 | 149 |
return $c;
|
160 | 150 |
}
|
161 | |
#line 163 "Utils.pm"
|
162 | |
|
163 | |
|
164 | |
|
165 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
151 |
|
166 | 152 |
|
167 | 153 |
*rldvec = \&PDL::rldvec;
|
168 | |
#line 170 "Utils.pm"
|
169 | |
|
170 | |
|
171 | |
|
172 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
154 |
|
|
155 |
|
173 | 156 |
|
174 | 157 |
|
175 | 158 |
|
|
193 | 176 |
=for bad
|
194 | 177 |
|
195 | 178 |
enumvec does not process bad values.
|
196 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
197 | |
|
198 | |
|
199 | |
=cut
|
200 | |
#line 202 "Utils.pm"
|
201 | |
|
202 | |
|
203 | |
|
204 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
179 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
180 |
|
|
181 |
|
|
182 |
=cut
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
205 | 188 |
|
206 | 189 |
*enumvec = \&PDL::enumvec;
|
207 | |
#line 209 "Utils.pm"
|
208 | |
|
209 | |
|
210 | |
|
211 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
190 |
|
|
191 |
|
212 | 192 |
|
213 | 193 |
|
214 | 194 |
|
|
233 | 213 |
=for bad
|
234 | 214 |
|
235 | 215 |
enumvecg does not process bad values.
|
236 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
237 | |
|
238 | |
|
239 | |
=cut
|
240 | |
#line 242 "Utils.pm"
|
241 | |
|
242 | |
|
243 | |
|
244 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
216 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
217 |
|
|
218 |
|
|
219 |
=cut
|
|
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
245 | 225 |
|
246 | 226 |
*enumvecg = \&PDL::enumvecg;
|
247 | |
#line 249 "Utils.pm"
|
248 | |
|
249 | |
|
250 | |
|
251 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
227 |
|
|
228 |
|
252 | 229 |
|
253 | 230 |
|
254 | 231 |
|
|
272 | 249 |
=for bad
|
273 | 250 |
|
274 | 251 |
rleseq does not process bad values.
|
275 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
276 | |
|
277 | |
|
278 | |
=cut
|
279 | |
#line 281 "Utils.pm"
|
280 | |
|
281 | |
|
282 | |
|
283 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
252 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
253 |
|
|
254 |
|
|
255 |
=cut
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
284 | 261 |
|
285 | 262 |
*rleseq = \&PDL::rleseq;
|
286 | |
#line 288 "Utils.pm"
|
287 | |
|
288 | |
|
289 | |
|
290 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
263 |
|
|
264 |
|
291 | 265 |
|
292 | 266 |
|
293 | 267 |
|
|
314 | 288 |
=for bad
|
315 | 289 |
|
316 | 290 |
rldseq does not process bad values.
|
317 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
318 | |
|
319 | |
|
320 | |
=cut
|
321 | |
#line 323 "Utils.pm"
|
322 | |
|
323 | |
|
324 | |
|
325 | |
#line 1059 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
291 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
292 |
|
|
293 |
|
|
294 |
=cut
|
|
295 |
|
|
296 |
|
|
297 |
|
326 | 298 |
|
327 | 299 |
sub PDL::rldseq {
|
328 | 300 |
my ($a,$b,$c) = @_;
|
|
335 | 307 |
&PDL::_rldseq_int($a,$b,$c);
|
336 | 308 |
return $c;
|
337 | 309 |
}
|
338 | |
#line 340 "Utils.pm"
|
339 | |
|
340 | |
|
341 | |
|
342 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
310 |
|
343 | 311 |
|
344 | 312 |
*rldseq = \&PDL::rldseq;
|
345 | |
#line 347 "Utils.pm"
|
346 | |
|
347 | |
|
348 | |
|
349 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
313 |
|
|
314 |
|
350 | 315 |
|
351 | 316 |
|
352 | 317 |
|
|
380 | 345 |
=for bad
|
381 | 346 |
|
382 | 347 |
vsearchvec does not process bad values.
|
383 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
384 | |
|
385 | |
|
386 | |
=cut
|
387 | |
#line 389 "Utils.pm"
|
388 | |
|
389 | |
|
390 | |
|
391 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
348 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
349 |
|
|
350 |
|
|
351 |
=cut
|
|
352 |
|
|
353 |
|
|
354 |
|
|
355 |
|
|
356 |
|
392 | 357 |
|
393 | 358 |
*vsearchvec = \&PDL::vsearchvec;
|
394 | |
#line 396 "Utils.pm"
|
395 | |
|
396 | |
|
397 | |
|
398 | |
#line 392 "utils.pd"
|
|
359 |
|
|
360 |
|
399 | 361 |
|
400 | 362 |
|
401 | 363 |
=pod
|
|
409 | 371 |
for a bug in PDL-2.4.3, which has long since been fixed.
|
410 | 372 |
|
411 | 373 |
=cut
|
412 | |
#line 414 "Utils.pm"
|
413 | |
|
414 | |
|
415 | |
|
416 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
374 |
|
|
375 |
|
417 | 376 |
|
418 | 377 |
|
419 | 378 |
|
|
423 | 382 |
|
424 | 383 |
Signature: (a(N); b(N); int [o]cmp())
|
425 | 384 |
|
|
385 |
=for ref
|
|
386 |
|
426 | 387 |
Lexicographically compare a pair of vectors.
|
427 | 388 |
|
428 | 389 |
|
|
430 | 391 |
=for bad
|
431 | 392 |
|
432 | 393 |
cmpvec does not process bad values.
|
433 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
434 | |
|
435 | |
|
436 | |
=cut
|
437 | |
#line 439 "Utils.pm"
|
438 | |
|
439 | |
|
440 | |
|
441 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
394 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
395 |
|
|
396 |
|
|
397 |
=cut
|
|
398 |
|
|
399 |
|
|
400 |
|
|
401 |
|
|
402 |
|
442 | 403 |
|
443 | 404 |
*cmpvec = \&PDL::cmpvec;
|
444 | |
#line 446 "Utils.pm"
|
445 | |
|
446 | |
|
447 | |
|
448 | |
#line 422 "utils.pd"
|
|
405 |
|
|
406 |
|
449 | 407 |
|
450 | 408 |
|
451 | 409 |
=head2 vv_qsortvec
|
|
478 | 436 |
*vv_qsortvec = *PDL::vv_qsortvec = *PDL::qsortvec;
|
479 | 437 |
*vv_qsortveci = *PDL::vv_qsortveci = *PDL::qsortveci;
|
480 | 438 |
}
|
481 | |
#line 483 "Utils.pm"
|
482 | |
|
483 | |
|
484 | |
|
485 | |
#line 463 "utils.pd"
|
|
439 |
|
|
440 |
|
486 | 441 |
|
487 | 442 |
|
488 | 443 |
=pod
|
|
493 | 448 |
sorted vector-valued PDLs.
|
494 | 449 |
|
495 | 450 |
=cut
|
496 | |
#line 498 "Utils.pm"
|
497 | |
|
498 | |
|
499 | |
|
500 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
451 |
|
|
452 |
|
501 | 453 |
|
502 | 454 |
|
503 | 455 |
|
|
521 | 473 |
=for bad
|
522 | 474 |
|
523 | 475 |
vv_union does not process bad values.
|
524 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
525 | |
|
526 | |
|
527 | |
=cut
|
528 | |
#line 530 "Utils.pm"
|
529 | |
|
530 | |
|
531 | |
|
532 | |
#line 1059 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
476 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
477 |
|
|
478 |
|
|
479 |
=cut
|
|
480 |
|
|
481 |
|
|
482 |
|
533 | 483 |
|
534 | 484 |
|
535 | 485 |
sub PDL::vv_union {
|
536 | 486 |
my ($a,$b,$c,$nc) = @_;
|
537 | |
barf("PDL::VectorValued::vv_union(): dimension mismatch") if ($a->dim(-2) != $b->dim(-2));
|
538 | |
my @adims = $a->dims;
|
|
487 |
my ($MA,$NA,@adims) = $a->dims;
|
|
488 |
my ($MB,$NB,@bdims) = $b->dims;
|
|
489 |
barf("PDL::VectorValued::vv_union(): dimension mismatch") if ($MA != $MB);
|
539 | 490 |
if (!defined($c)) {
|
540 | 491 |
my $ctype = $a->type > $b->type ? $a->type : $b->type;
|
541 | |
$c = PDL->zeroes($ctype, @adims[0..($#adims-1)], $adims[$#adims] + $b->dim(-1));
|
|
492 |
$c = PDL->zeroes($ctype, $MA, ($NA+$NB), @adims);
|
542 | 493 |
}
|
543 | |
$nc = PDL->zeroes(PDL::long(), (@adims > 2 ? @adims[0..($#adims-2)] : 1)) if (!defined($nc));
|
|
494 |
$nc = PDL->zeroes(PDL::long(), @adims ? @adims : 1) if (!defined($nc));
|
544 | 495 |
&PDL::_vv_union_int($a,$b,$c,$nc);
|
545 | 496 |
return ($c,$nc) if (wantarray);
|
546 | |
return $c->mv(-1,0)->slice("0:".($nc->sclr-1))->mv(0,-1);
|
|
497 |
return $c->mv(1,0)->slice("0:".($nc->max-1))->mv(0,1);
|
547 | 498 |
}
|
548 | |
#line 550 "Utils.pm"
|
549 | |
|
550 | |
|
551 | |
|
552 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
499 |
|
553 | 500 |
|
554 | 501 |
*vv_union = \&PDL::vv_union;
|
555 | |
#line 557 "Utils.pm"
|
556 | |
|
557 | |
|
558 | |
|
559 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
502 |
|
|
503 |
|
560 | 504 |
|
561 | 505 |
|
562 | 506 |
|
|
579 | 523 |
=for bad
|
580 | 524 |
|
581 | 525 |
vv_intersect does not process bad values.
|
582 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
583 | |
|
584 | |
|
585 | |
=cut
|
586 | |
#line 588 "Utils.pm"
|
587 | |
|
588 | |
|
589 | |
|
590 | |
#line 1059 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
526 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
527 |
|
|
528 |
|
|
529 |
=cut
|
|
530 |
|
|
531 |
|
|
532 |
|
591 | 533 |
|
592 | 534 |
|
593 | 535 |
sub PDL::vv_intersect {
|
594 | 536 |
my ($a,$b,$c,$nc) = @_;
|
595 | |
barf("PDL::VectorValued::vv_intersect(): dimension mismatch") if ($a->dim(-2) != $b->dim(-2));
|
596 | |
my @adims = $a->dims;
|
597 | |
my $NA = $adims[$#adims];
|
598 | |
my $NB = $b->dim(-1);
|
|
537 |
my ($MA,$NA,@adims) = $a->dims;
|
|
538 |
my ($MB,$NB,@bdims) = $b->dims;
|
|
539 |
barf("PDL::VectorValued::vv_intersect(): dimension mismatch") if ($MA != $MB);
|
599 | 540 |
if (!defined($c)) {
|
600 | 541 |
my $ctype = $a->type > $b->type ? $a->type : $b->type;
|
601 | |
$c = PDL->zeroes($ctype, @adims[0..($#adims-1)], $NA < $NB ? $NA : $NB);
|
|
542 |
$c = PDL->zeroes($ctype, $MA, ($NA < $NB ? $NA : $NB), @adims);
|
602 | 543 |
}
|
603 | |
$nc = PDL->zeroes(PDL::long(), (@adims > 2 ? @adims[0..($#adims-2)] : 1)) if (!defined($nc));
|
|
544 |
$nc = PDL->zeroes(PDL::long(), @adims ? @adims : 1) if (!defined($nc));
|
604 | 545 |
&PDL::_vv_intersect_int($a,$b,$c,$nc);
|
605 | 546 |
return ($c,$nc) if (wantarray);
|
606 | |
return $c->mv(-1,0)->slice("0:".($nc->sclr-1))->mv(0,-1);
|
|
547 |
my $nc_max = $nc->max;
|
|
548 |
return ($nc_max > 0
|
|
549 |
? $c->mv(1,0)->slice("0:".($nc_max-1))->mv(0,1)
|
|
550 |
: $c->reshape($c->dim(0), 0, ($c->dims)[2..($c->ndims-1)]));
|
607 | 551 |
}
|
608 | |
#line 610 "Utils.pm"
|
609 | |
|
610 | |
|
611 | |
|
612 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
552 |
|
613 | 553 |
|
614 | 554 |
*vv_intersect = \&PDL::vv_intersect;
|
615 | |
#line 617 "Utils.pm"
|
616 | |
|
617 | |
|
618 | |
|
619 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
555 |
|
|
556 |
|
620 | 557 |
|
621 | 558 |
|
622 | 559 |
|
|
639 | 576 |
=for bad
|
640 | 577 |
|
641 | 578 |
vv_setdiff does not process bad values.
|
642 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
643 | |
|
644 | |
|
645 | |
=cut
|
646 | |
#line 648 "Utils.pm"
|
647 | |
|
648 | |
|
649 | |
|
650 | |
#line 1059 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
579 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
580 |
|
|
581 |
|
|
582 |
=cut
|
|
583 |
|
|
584 |
|
|
585 |
|
651 | 586 |
|
652 | 587 |
|
653 | 588 |
sub PDL::vv_setdiff {
|
654 | |
my ($a,$b,$c,$nc) = @_;
|
655 | |
barf("PDL::VectorValued::vv_setdiff(): dimension mismatch") if ($a->dim(-2) != $b->dim(-2));
|
656 | |
my @adims = $a->dims;
|
657 | |
my $NA = $adims[$#adims];
|
658 | |
my $NB = $b->dim(-1);
|
659 | |
if (!defined($c)) {
|
660 | |
my $ctype = $a->type > $b->type ? $a->type : $b->type;
|
661 | |
$c = PDL->zeroes($ctype, @adims[0..($#adims-1)], $NA);
|
662 | |
}
|
663 | |
$nc = PDL->zeroes(PDL::long(), (@adims > 2 ? @adims[0..($#adims-2)] : 1)) if (!defined($nc));
|
664 | |
&PDL::_vv_setdiff_int($a,$b,$c,$nc);
|
665 | |
return ($c,$nc) if (wantarray);
|
666 | |
return $c->mv(-1,0)->slice("0:".($nc->sclr-1))->mv(0,-1);
|
|
589 |
my ($a,$b,$c,$nc) = @_;
|
|
590 |
my ($MA,$NA,@adims) = $a->dims;
|
|
591 |
my ($MB,$NB,@bdims) = $b->dims;
|
|
592 |
barf("PDL::VectorValued::vv_setdiff(): dimension mismatch") if ($MA != $MB);
|
|
593 |
if (!defined($c)) {
|
|
594 |
my $ctype = $a->type > $b->type ? $a->type : $b->type;
|
|
595 |
$c = PDL->zeroes($ctype, $MA, $NA, @adims);
|
|
596 |
}
|
|
597 |
$nc = PDL->zeroes(PDL::long(), @adims ? @adims : 1) if (!defined($nc));
|
|
598 |
&PDL::_vv_setdiff_int($a,$b,$c,$nc);
|
|
599 |
return ($c,$nc) if (wantarray);
|
|
600 |
my $nc_max = $nc->max;
|
|
601 |
return ($nc_max > 0
|
|
602 |
? $c->mv(1,0)->slice("0:".($nc_max-1))->mv(0,1)
|
|
603 |
: $c->reshape($c->dim(0), 0, ($c->dims)[2..($c->ndims-1)]));
|
667 | 604 |
}
|
668 | |
#line 670 "Utils.pm"
|
669 | |
|
670 | |
|
671 | |
|
672 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
605 |
|
673 | 606 |
|
674 | 607 |
*vv_setdiff = \&PDL::vv_setdiff;
|
675 | |
#line 677 "Utils.pm"
|
676 | |
|
677 | |
|
678 | |
|
679 | |
#line 674 "utils.pd"
|
|
608 |
|
|
609 |
|
680 | 610 |
|
681 | 611 |
|
682 | 612 |
=pod
|
|
688 | 618 |
than the corresponding implementations via PDL::Primitive::setops().
|
689 | 619 |
|
690 | 620 |
=cut
|
691 | |
#line 693 "Utils.pm"
|
692 | |
|
693 | |
|
694 | |
|
695 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
621 |
|
|
622 |
|
696 | 623 |
|
697 | 624 |
|
698 | 625 |
|
|
714 | 641 |
=for bad
|
715 | 642 |
|
716 | 643 |
v_union does not process bad values.
|
717 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
718 | |
|
719 | |
|
720 | |
=cut
|
721 | |
#line 723 "Utils.pm"
|
722 | |
|
723 | |
|
724 | |
|
725 | |
#line 1059 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
644 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
645 |
|
|
646 |
|
|
647 |
=cut
|
|
648 |
|
|
649 |
|
|
650 |
|
726 | 651 |
|
727 | 652 |
|
728 | 653 |
sub PDL::v_union {
|
729 | 654 |
my ($a,$b,$c,$nc) = @_;
|
730 | |
barf("PDL::VectorValued::v_union(): only 1d vectors are supported") if ($a->ndims > 1 || $b->ndims > 1);
|
731 | |
$nc = PDL->pdl(PDL::long(), $a->dim(0) + $b->dim(0)) if (!defined($nc));
|
|
655 |
my ($NA,@adims) = $a->dims;
|
|
656 |
my ($NB,@bdims) = $b->dims;
|
732 | 657 |
if (!defined($c)) {
|
733 | 658 |
my $ctype = $a->type > $b->type ? $a->type : $b->type;
|
734 | |
$c = PDL->zeroes($ctype, ref($nc) ? $nc->sclr : $nc);
|
|
659 |
$c = PDL->zeroes($ctype, ($NA+$NB), @adims);
|
735 | 660 |
}
|
|
661 |
$nc = PDL->pdl(PDL::long(), @adims ? @adims : 1) if (!defined($nc));
|
736 | 662 |
&PDL::_v_union_int($a,$b,$c,$nc);
|
737 | 663 |
return ($c,$nc) if (wantarray);
|
738 | |
return $c->reshape($nc->sclr);
|
|
664 |
return $c->slice("0:".($nc->max-1));
|
739 | 665 |
}
|
740 | |
#line 742 "Utils.pm"
|
741 | |
|
742 | |
|
743 | |
|
744 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
666 |
|
745 | 667 |
|
746 | 668 |
*v_union = \&PDL::v_union;
|
747 | |
#line 749 "Utils.pm"
|
748 | |
|
749 | |
|
750 | |
|
751 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
669 |
|
|
670 |
|
752 | 671 |
|
753 | 672 |
|
754 | 673 |
|
|
770 | 689 |
=for bad
|
771 | 690 |
|
772 | 691 |
v_intersect does not process bad values.
|
773 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
774 | |
|
775 | |
|
776 | |
=cut
|
777 | |
#line 779 "Utils.pm"
|
778 | |
|
779 | |
|
780 | |
|
781 | |
#line 1059 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
692 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
693 |
|
|
694 |
|
|
695 |
=cut
|
|
696 |
|
|
697 |
|
|
698 |
|
782 | 699 |
|
783 | 700 |
|
784 | 701 |
sub PDL::v_intersect {
|
785 | 702 |
my ($a,$b,$c,$nc) = @_;
|
786 | |
barf("PDL::VectorValued::v_intersect(): only 1d vectors are supported") if ($a->ndims > 1 || $b->ndims > 1);
|
787 | |
my $NA = $a->dim(0);
|
788 | |
my $NB = $b->dim(0);
|
789 | |
$nc = PDL->pdl(PDL::long(), $NA < $NB ? $NA : $NB) if (!defined($nc));
|
|
703 |
my ($NA,@adims) = $a->dims;
|
|
704 |
my ($NB,@bdims) = $b->dims;
|
790 | 705 |
if (!defined($c)) {
|
791 | 706 |
my $ctype = $a->type > $b->type ? $a->type : $b->type;
|
792 | |
$c = PDL->zeroes($ctype, ref($nc) ? $nc->sclr : $nc);
|
|
707 |
$c = PDL->zeroes($ctype, ($NA < $NB ? $NA : $NB), @adims);
|
793 | 708 |
}
|
|
709 |
$nc = PDL->pdl(PDL::long(), @adims ? @adims : 1) if (!defined($nc));
|
794 | 710 |
&PDL::_v_intersect_int($a,$b,$c,$nc);
|
795 | 711 |
return ($c,$nc) if (wantarray);
|
796 | |
return $c->reshape($nc->sclr);
|
|
712 |
my $nc_max = $nc->max;
|
|
713 |
return ($nc_max > 0
|
|
714 |
? $c->slice("0:".($nc_max-1))
|
|
715 |
: $c->reshape(0, ($c->dims)[1..($c->ndims-1)]));
|
797 | 716 |
}
|
798 | |
#line 800 "Utils.pm"
|
799 | |
|
800 | |
|
801 | |
|
802 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
717 |
|
803 | 718 |
|
804 | 719 |
*v_intersect = \&PDL::v_intersect;
|
805 | |
#line 807 "Utils.pm"
|
806 | |
|
807 | |
|
808 | |
|
809 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
720 |
|
|
721 |
|
810 | 722 |
|
811 | 723 |
|
812 | 724 |
|
|
828 | 740 |
=for bad
|
829 | 741 |
|
830 | 742 |
v_setdiff does not process bad values.
|
831 | |
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
|
832 | |
|
833 | |
|
834 | |
=cut
|
835 | |
#line 837 "Utils.pm"
|
836 | |
|
837 | |
|
838 | |
|
839 | |
#line 1059 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
743 |
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
|
|
744 |
|
|
745 |
|
|
746 |
=cut
|
|
747 |
|
|
748 |
|
|
749 |
|
840 | 750 |
|
841 | 751 |
|
842 | 752 |
sub PDL::v_setdiff {
|
843 | 753 |
my ($a,$b,$c,$nc) = @_;
|
844 | |
barf("PDL::VectorValued::v_setdiff(): only 1d vectors are supported") if ($a->ndims > 1 || $b->ndims > 1);
|
845 | |
my $NA = $a->dim(0);
|
846 | |
my $NB = $b->dim(0);
|
847 | |
$nc = PDL->pdl(PDL::long(), $NA) if (!defined($nc));
|
|
754 |
my ($NA,@adims) = $a->dims;
|
|
755 |
my ($NB,@bdims) = $b->dims;
|
848 | 756 |
if (!defined($c)) {
|
849 | 757 |
my $ctype = $a->type > $b->type ? $a->type : $b->type;
|
850 | |
$c = PDL->zeroes($ctype, $NA);
|
|
758 |
$c = PDL->zeroes($ctype, $NA, @adims);
|
851 | 759 |
}
|
|
760 |
$nc = PDL->pdl(PDL::long(), @adims ? @adims : 1) if (!defined($nc));
|
852 | 761 |
&PDL::_v_setdiff_int($a,$b,$c,$nc);
|
853 | 762 |
return ($c,$nc) if (wantarray);
|
854 | |
return $c->reshape($nc->sclr);
|
|
763 |
my $nc_max = $nc->max;
|
|
764 |
return ($nc_max > 0
|
|
765 |
? $c->slice("0:".($nc_max-1))
|
|
766 |
: $c->reshape(0, ($c->dims)[1..($c->ndims-1)]));
|
855 | 767 |
}
|
856 | |
#line 858 "Utils.pm"
|
857 | |
|
858 | |
|
859 | |
|
860 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
768 |
|
861 | 769 |
|
862 | 770 |
*v_setdiff = \&PDL::v_setdiff;
|
863 | |
#line 865 "Utils.pm"
|
864 | |
|
865 | |
|
866 | |
|
867 | |
#line 875 "utils.pd"
|
|
771 |
|
|
772 |
|
868 | 773 |
|
869 | 774 |
|
870 | 775 |
=pod
|
|
872 | 777 |
=head1 Miscellaneous Vector-Valued Operations
|
873 | 778 |
|
874 | 779 |
=cut
|
875 | |
#line 877 "Utils.pm"
|
876 | |
|
877 | |
|
878 | |
|
879 | |
#line 1058 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
780 |
|
|
781 |
|
880 | 782 |
|
881 | 783 |
|
882 | 784 |
|
|
910 | 812 |
|
911 | 813 |
|
912 | 814 |
=cut
|
913 | |
#line 915 "Utils.pm"
|
914 | |
|
915 | |
|
916 | |
|
917 | |
#line 1060 "/local/home/moocow/local/lib/perl5/x86_64-linux-gnu-thread-multi/PDL/PP.pm"
|
|
815 |
|
|
816 |
|
|
817 |
|
|
818 |
|
|
819 |
|
918 | 820 |
|
919 | 821 |
*vv_vcos = \&PDL::vv_vcos;
|
920 | |
#line 922 "Utils.pm"
|
921 | |
|
922 | |
|
923 | |
|
924 | |
#line 985 "utils.pd"
|
|
822 |
|
|
823 |
|
925 | 824 |
|
926 | 825 |
|
927 | 826 |
##---------------------------------------------------------------------
|
|
998 | 897 |
perl(1), PDL(3perl)
|
999 | 898 |
|
1000 | 899 |
=cut
|
1001 | |
#line 1003 "Utils.pm"
|
1002 | |
|
1003 | |
|
1004 | |
|
|
900 |
|
|
901 |
|
|
902 |
|
|
903 |
;
|
1005 | 904 |
|
1006 | 905 |
|
1007 | 906 |
|
1008 | 907 |
# Exit with OK status
|
1009 | 908 |
|
1010 | 909 |
1;
|
|
910 |
|
|
911 |
⏎
|