File Coverage

blib/lib/PDL/Bad.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             #
2             # GENERATED WITH PDL::PP from lib/PDL/Bad.pd! Don't modify!
3             #
4             package PDL::Bad;
5              
6             our @EXPORT_OK = qw(badflag check_badflag badvalue orig_badvalue nbad nbadover ngood ngoodover setbadat isbad isgood nbadover ngoodover setbadif setvaltobad setnantobad setinftobad setnonfinitetobad setbadtonan setbadtoval badmask copybad locf );
7             our %EXPORT_TAGS = (Func=>\@EXPORT_OK);
8              
9 70     70   471 use PDL::Core;
  70         144  
  70         660  
10 70     70   604 use PDL::Exporter;
  70         156  
  70         338  
11 70     70   416 use DynaLoader;
  70         156  
  70         32063  
12              
13              
14            
15             our @ISA = ( 'PDL::Exporter','DynaLoader' );
16             push @PDL::Core::PP, __PACKAGE__;
17             bootstrap PDL::Bad ;
18              
19              
20              
21              
22              
23              
24              
25              
26             #line 20 "lib/PDL/Bad.pd"
27              
28             =head1 NAME
29              
30             PDL::Bad - PDL always processes bad values
31              
32             =head1 DESCRIPTION
33              
34             This module is loaded when you do C,
35             C or C.
36              
37             Implementation details are given in
38             L.
39              
40             =head1 SYNOPSIS
41              
42             use PDL::Bad;
43             print "\nBad value per PDL support in PDL is turned " .
44             $PDL::Bad::PerPdl ? "on" : "off" . ".\n";
45              
46             =head1 VARIABLES
47              
48             =over 4
49              
50             =item $PDL::Bad::UseNaN
51              
52             Set to 0 as of PDL 2.040, as no longer available, though NaN can be used
53             as a badvalue for a given PDL object.
54              
55             =item $PDL::Bad::PerPdl
56              
57             Set to 1 as of PDL 2.040 as always available.
58              
59             =item $PDL::Bad::Status
60              
61             Set to 1 as of PDL 2.035 as always available.
62              
63             =back
64              
65             =cut
66             #line 67 "lib/PDL/Bad.pm"
67              
68              
69             =head1 FUNCTIONS
70              
71             =cut
72              
73              
74              
75              
76              
77             #line 63 "lib/PDL/Bad.pd"
78              
79             $PDL::Bad::Status = 1;
80             $PDL::Bad::UseNaN = 0;
81             $PDL::Bad::PerPdl = 1;
82              
83             use strict;
84              
85             use PDL::Types;
86             use PDL::Primitive;
87              
88             ############################################################
89             ############################################################
90              
91             #line 79 "lib/PDL/Bad.pd"
92             ############################################################
93             ############################################################
94              
95             *badflag = \&PDL::badflag;
96             *badvalue = \&PDL::badvalue;
97             *orig_badvalue = \&PDL::orig_badvalue;
98              
99             ############################################################
100             ############################################################
101              
102             =head2 badflag
103              
104             =for ref
105              
106             getter/setter for the bad data flag
107              
108             =for example
109              
110             if ( $x->badflag() ) {
111             print "Data may contain bad values.\n";
112             }
113             $x->badflag(1); # set bad data flag
114             $x->badflag(0); # unset bad data flag
115              
116             When called as a setter, this modifies the ndarray on which
117             it is called. This always returns a Perl scalar with the
118             final value of the bad flag.
119              
120             A return value of 1 does not guarantee the presence of
121             bad data in an ndarray; all it does is say that we need to
122             I for the presence of such beasties. To actually
123             find out if there are any bad values present in an ndarray,
124             use the L method.
125              
126             =for bad
127              
128             This function works with ndarrays that have bad values. It
129             always returns a Perl scalar, so it never returns bad values.
130              
131             =head2 badvalue
132              
133             =for ref
134              
135             returns (or sets) the value used to indicate a missing (or bad) element
136             for the given ndarray type. You can give it an ndarray,
137             a PDL::Type object, or one of C<$PDL_B>, C<$PDL_S>, etc.
138              
139             =for example
140              
141             $badval = badvalue( float );
142             $x = ones(ushort,10);
143             print "The bad data value for ushort is: ",
144             $x->badvalue(), "\n";
145              
146             This can act as a setter (e.g. C<< $x->badvalue(23) >>),
147             including with the value C for floating-point types.
148             Note that this B for
149             floating-point-typed ndarrays.
150             That is, if C<$x> already has bad values, they will not
151             be changed to use the given number and if any elements of
152             C<$x> have that value, they will unceremoniously be marked
153             as bad data. See L, L, and
154             L for ways to actually modify the data in ndarrays
155              
156             It I change data for integer-typed arrays, changing values that
157             had the old bad value to have the new one.
158              
159             It is possible to change the bad value on a per-ndarray basis, so
160              
161             $x = sequence (10);
162             $x->badvalue (3); $x->badflag (1);
163             $y = sequence (10);
164             $y->badvalue (4); $y->badflag (1);
165              
166             will set $x to be C<[0 1 2 BAD 4 5 6 7 8 9]> and $y to be
167             C<[0 1 2 3 BAD 5 6 7 8 9]>.
168              
169             =for bad
170              
171             This method does not care if you call it on an input ndarray
172             that has bad values. It always returns an ndarray
173             with the current or new bad value.
174              
175             =cut
176              
177             sub PDL::badvalue {
178             my ( $self, $val ) = @_;
179             my $num;
180             if ( UNIVERSAL::isa($self,"PDL") ) {
181             $num = $self->get_datatype;
182             if ( $num < $PDL_F && defined($val) && $self->badflag ) {
183             $self->inplace->setbadtoval( $val );
184             $self->badflag(1);
185             }
186             return PDL::Bad::_badvalue_per_pdl_int($self, $val, $num);
187             } elsif ( UNIVERSAL::isa($self,"PDL::Type") ) {
188             $num = $self->enum;
189             } else {
190             # assume it's a number
191             $num = $self;
192             }
193             PDL::Bad::_badvalue_int( $val, $num );
194             }
195              
196             =head2 orig_badvalue
197              
198             =for ref
199              
200             returns the original value used to represent bad values for
201             a given type.
202              
203             This routine operates the same as L,
204             except you can not change the values.
205              
206             It also has an I name.
207              
208             =for example
209              
210             $orig_badval = orig_badvalue( float );
211             $x = ones(ushort,10);
212             print "The original bad data value for ushort is: ",
213             $x->orig_badvalue(), "\n";
214              
215             =for bad
216              
217             This method does not care if you call it on an input ndarray
218             that has bad values. It always returns an ndarray
219             with the original bad value for the associated type.
220              
221             =cut
222              
223             sub PDL::orig_badvalue {
224             no strict 'refs';
225             my $self = shift;
226             my $num;
227             if ( UNIVERSAL::isa($self,"PDL") ) {
228             $num = $self->get_datatype;
229             } elsif ( UNIVERSAL::isa($self,"PDL::Type") ) {
230             $num = $self->enum;
231             } else {
232             # assume it's a number
233             $num = $self;
234             }
235             PDL::Bad::_default_badvalue_int($num);
236             }
237              
238             =head2 check_badflag
239              
240             =for ref
241              
242             Clear the badflag of an ndarray if it does not
243             contain any bad values
244              
245             Given an ndarray whose bad flag is set, check whether it
246             actually contains any bad values and, if not, clear the flag.
247             It returns the final state of the badflag.
248              
249             =for example
250              
251             print "State of bad flag == ", $pdl->check_badflag;
252              
253             =for bad
254              
255             This method accepts ndarrays with or without bad values. It
256             returns an ndarray with the final badflag.
257              
258             =cut
259              
260             *check_badflag = \&PDL::check_badflag;
261              
262             sub PDL::check_badflag {
263             my $pdl = shift;
264             $pdl->badflag(0) if $pdl->badflag and $pdl->nbad == 0;
265             return $pdl->badflag;
266             } # sub: check_badflag()
267             #line 268 "lib/PDL/Bad.pm"
268              
269              
270             =head2 isbad
271              
272             =for sig
273              
274             Signature: (a(); int [o]b())
275             Types: (sbyte byte short ushort long ulong indx ulonglong longlong
276             float double ldouble cfloat cdouble cldouble)
277              
278             =for usage
279              
280             $b = isbad($a);
281             isbad($a, $b); # all arguments given
282             $b = $a->isbad; # method call
283             $a->isbad($b);
284              
285             =for ref
286              
287             Returns a binary mask indicating which values of
288             the input are bad values
289              
290             Returns a 1 if the value is bad, 0 otherwise.
291             Similar to L.
292              
293             =for example
294              
295             $x = pdl(1,2,3);
296             $x->badflag(1);
297             set($x,1,$x->badvalue);
298             $y = isbad($x);
299             print $y, "\n";
300             [0 1 0]
301              
302             =pod
303              
304             Broadcasts over its inputs.
305              
306             =for bad
307              
308             This method works with input ndarrays that are bad. The output ndarray
309             will never contain bad values, but its bad value flag will be the
310             same as the input ndarray's flag.
311              
312             =cut
313              
314              
315              
316              
317             *isbad = \&PDL::isbad;
318              
319              
320              
321              
322              
323              
324             =head2 isgood
325              
326             =for sig
327              
328             Signature: (a(); int [o]b())
329             Types: (sbyte byte short ushort long ulong indx ulonglong longlong
330             float double ldouble cfloat cdouble cldouble)
331              
332             =for usage
333              
334             $b = isgood($a);
335             isgood($a, $b); # all arguments given
336             $b = $a->isgood; # method call
337             $a->isgood($b);
338              
339             =for ref
340              
341             Is a value good?
342              
343             Returns a 1 if the value is good, 0 otherwise.
344             Also see L.
345              
346             =for example
347              
348             $x = pdl(1,2,3);
349             $x->badflag(1);
350             set($x,1,$x->badvalue);
351             $y = isgood($x);
352             print $y, "\n";
353             [1 0 1]
354              
355             =pod
356              
357             Broadcasts over its inputs.
358              
359             =for bad
360              
361             This method works with input ndarrays that are bad. The output ndarray
362             will never contain bad values, but its bad value flag will be the
363             same as the input ndarray's flag.
364              
365             =cut
366              
367              
368              
369              
370             *isgood = \&PDL::isgood;
371              
372              
373              
374              
375              
376              
377             =head2 nbadover
378              
379             =for sig
380              
381             Signature: (a(n); indx [o] b())
382             Types: (sbyte byte short ushort long ulong indx ulonglong longlong
383             float double ldouble cfloat cdouble cldouble)
384              
385             =for usage
386              
387             $b = nbadover($a);
388             nbadover($a, $b); # all arguments given
389             $b = $a->nbadover; # method call
390             $a->nbadover($b);
391              
392             =for ref
393              
394             Find the number of bad elements along the 1st dimension.
395              
396             This function reduces the dimensionality of an ndarray by one by finding the
397             number of bad elements along the 1st dimension. In this sense it shares
398             much in common with the functions defined in L. In particular,
399             by using L and similar dimension rearranging methods,
400             it is possible to perform this calculation over I dimension.
401              
402             =pod
403              
404             Broadcasts over its inputs.
405              
406             =for bad
407              
408             nbadover processes input values that are bad. The output ndarray will not have
409             any bad values, but the bad flag will be set if the input ndarray had its bad
410             flag set.
411              
412             =cut
413              
414              
415              
416              
417             *nbadover = \&PDL::nbadover;
418              
419              
420              
421              
422              
423              
424             =head2 ngoodover
425              
426             =for sig
427              
428             Signature: (a(n); indx [o] b())
429             Types: (sbyte byte short ushort long ulong indx ulonglong longlong
430             float double ldouble cfloat cdouble cldouble)
431              
432             =for usage
433              
434             $b = ngoodover($a);
435             ngoodover($a, $b); # all arguments given
436             $b = $a->ngoodover; # method call
437             $a->ngoodover($b);
438              
439             =for ref
440              
441             Find the number of good elements along the 1st dimension.
442              
443             This function reduces the dimensionality of an ndarray
444             by one by finding the number of good elements
445             along the 1st dimension.
446              
447             By using L etc. it is possible to use
448             I dimension.
449              
450             =pod
451              
452             Broadcasts over its inputs.
453              
454             =for bad
455              
456             ngoodover processes input values that are bad. The output ndarray will not have
457             any bad values, but the bad flag will be set if the input ndarray had its bad
458             flag set.
459              
460             =cut
461              
462              
463              
464              
465             *ngoodover = \&PDL::ngoodover;
466              
467              
468              
469              
470              
471             #line 463 "lib/PDL/Bad.pd"
472              
473             *nbad = \&PDL::nbad;
474             sub PDL::nbad {
475             my($x) = @_; my $tmp;
476             $x->flat->nbadover($tmp=PDL->nullcreate($x) );
477             return $tmp;
478             }
479              
480             #line 463 "lib/PDL/Bad.pd"
481             *ngood = \&PDL::ngood;
482             sub PDL::ngood {
483             my($x) = @_; my $tmp;
484             $x->flat->ngoodover($tmp=PDL->nullcreate($x) );
485             return $tmp;
486             }
487              
488             #line 475 "lib/PDL/Bad.pd"
489              
490             =head2 nbad
491              
492             =for ref
493              
494             Returns the number of bad values in an ndarray
495              
496             =for bad
497              
498             Accepts good and bad input ndarrays; output is an ndarray
499             and is always good.
500              
501             =head2 ngood
502              
503             =for ref
504              
505             Returns the number of good values in an ndarray
506              
507             =for usage
508              
509             $x = ngood($data);
510              
511             =for bad
512              
513             Accepts good and bad input ndarrays; output is an ndarray
514             and is always good.
515              
516             =head2 setbadat
517              
518             =for ref
519              
520             Set the value to bad at a given position.
521              
522             =for usage
523              
524             setbadat $ndarray, @position
525              
526             C<@position> is a coordinate list, of size equal to the
527             number of dimensions in the ndarray.
528             This is a wrapper around L and is
529             probably mainly useful in test scripts!
530              
531             =for example
532              
533             pdl> $x = sequence 3,4
534             pdl> $x->setbadat 2,1
535             pdl> p $x
536             [
537             [ 0 1 2]
538             [ 3 4 BAD]
539             [ 6 7 8]
540             [ 9 10 11]
541             ]
542              
543             =for bad
544              
545             This method can be called on ndarrays that have bad values.
546             The remainder of the arguments should be Perl scalars indicating
547             the position to set as bad. The output ndarray will have bad values
548             and will have its badflag turned on.
549              
550             =cut
551              
552             *setbadat = \&PDL::setbadat;
553             sub PDL::setbadat {
554             barf 'Usage: setbadat($pdl, $x, $y, ...)' if $#_<1;
555             my $self = shift;
556             PDL::Core::set_c ($self, [@_], $self->badvalue);
557             $self->badflag(1);
558             return $self;
559             }
560             #line 561 "lib/PDL/Bad.pm"
561              
562              
563             =head2 setbadif
564              
565             =for sig
566              
567             Signature: (a(); int mask(); [o]b())
568             Types: (sbyte byte short ushort long ulong indx ulonglong longlong
569             float double ldouble cfloat cdouble cldouble)
570              
571             =for usage
572              
573             $b = setbadif($a, $mask);
574             setbadif($a, $mask, $b); # all arguments given
575             $b = $a->setbadif($mask); # method call
576             $a->setbadif($mask, $b);
577              
578             =for ref
579              
580             Set elements bad based on the supplied mask, otherwise
581             copy across the data.
582              
583             =for example
584              
585             pdl> $x = sequence(5,5)
586             pdl> $x = $x->setbadif( $x % 2 )
587             pdl> p "a badflag: ", $x->badflag, "\n"
588             a badflag: 1
589             pdl> p "a is\n$x"
590             [
591             [ 0 BAD 2 BAD 4]
592             [BAD 6 BAD 8 BAD]
593             [ 10 BAD 12 BAD 14]
594             [BAD 16 BAD 18 BAD]
595             [ 20 BAD 22 BAD 24]
596             ]
597              
598             Unfortunately, this routine can I be run inplace, since the
599             current implementation can not handle the same ndarray used as
600             C and C (eg C<< $x->inplace->setbadif($x%2) >> fails).
601             Even more unfortunate: we can't catch this error and tell you.
602              
603             =pod
604              
605             Broadcasts over its inputs.
606              
607             =for bad
608              
609             The output always has its bad flag set, even if it does not contain
610             any bad values (use L to check
611             whether there are any bad values in the output).
612             The input ndarray can have bad values: any bad values in the input ndarrays
613             are copied across to the output ndarray.
614              
615             Also see L and L.
616              
617             =cut
618              
619              
620              
621              
622             *setbadif = \&PDL::setbadif;
623              
624              
625              
626              
627              
628              
629             =head2 setvaltobad
630              
631             =for sig
632              
633             Signature: (a(); [o]b(); double value)
634             Types: (sbyte byte short ushort long ulong indx ulonglong longlong
635             float double ldouble cfloat cdouble cldouble)
636              
637             =for usage
638              
639             $b = setvaltobad($a, $value);
640             setvaltobad($a, $b, $value); # all arguments given
641             $b = $a->setvaltobad($value); # method call
642             $a->setvaltobad($b, $value);
643             $a->inplace->setvaltobad($value); # can be used inplace
644             setvaltobad($a->inplace, $value);
645              
646             =for ref
647              
648             Set bad all those elements which equal the supplied value.
649              
650             =for example
651              
652             $x = sequence(10) % 3;
653             $x->inplace->setvaltobad( 0 );
654             print "$x\n";
655             [BAD 1 2 BAD 1 2 BAD 1 2 BAD]
656              
657             This is a simpler version of L, but this
658             function can be done inplace. See L
659             if you want to convert NaN to the bad value.
660              
661             =pod
662              
663             Broadcasts over its inputs.
664              
665             =for bad
666              
667             The output always has its bad flag set, even if it does not contain
668             any bad values (use L to check
669             whether there are any bad values in the output).
670             Any bad values in the input ndarrays are copied across to the output ndarray.
671              
672             =cut
673              
674              
675              
676              
677             *setvaltobad = \&PDL::setvaltobad;
678              
679              
680              
681              
682              
683              
684             =head2 setnantobad
685              
686             =for sig
687              
688             Signature: (a(); [o]b())
689             Types: (float ldouble cfloat cdouble cldouble double)
690              
691             =for usage
692              
693             $b = setnantobad($a);
694             setnantobad($a, $b); # all arguments given
695             $b = $a->setnantobad; # method call
696             $a->setnantobad($b);
697             $a->inplace->setnantobad; # can be used inplace
698             setnantobad($a->inplace);
699              
700             =for ref
701              
702             Sets NaN values (for complex, where either is NaN) in the input ndarray bad
703             (only relevant for floating-point ndarrays).
704              
705             =pod
706              
707             Broadcasts over its inputs.
708              
709             =for bad
710              
711             This method can process ndarrays with bad values: those bad values
712             are propagated into the output ndarray. Any value that is not a number
713             (before version 2.040 the test was for "not finite")
714             is also set to bad in the output ndarray. If all values from the input
715             ndarray are good, the output ndarray will B have its
716             bad flag set.
717              
718             =cut
719              
720              
721              
722              
723             *setnantobad = \&PDL::setnantobad;
724              
725              
726              
727              
728              
729              
730             =head2 setinftobad
731              
732             =for sig
733              
734             Signature: (a(); [o]b())
735             Types: (float ldouble cfloat cdouble cldouble double)
736              
737             =for usage
738              
739             $b = setinftobad($a);
740             setinftobad($a, $b); # all arguments given
741             $b = $a->setinftobad; # method call
742             $a->setinftobad($b);
743             $a->inplace->setinftobad; # can be used inplace
744             setinftobad($a->inplace);
745              
746             =for ref
747              
748             Sets non-finite values (for complex, where either is non-finite) in
749             the input ndarray bad (only relevant for floating-point ndarrays).
750              
751             =pod
752              
753             Broadcasts over its inputs.
754              
755             =for bad
756              
757             This method can process ndarrays with bad values: those bad values
758             are propagated into the output ndarray. Any value that is not finite
759             is also set to bad in the output ndarray. If all values from the input
760             ndarray are finite, the output ndarray will B have its
761             bad flag set.
762              
763             =cut
764              
765              
766              
767              
768             *setinftobad = \&PDL::setinftobad;
769              
770              
771              
772              
773              
774              
775             =head2 setnonfinitetobad
776              
777             =for sig
778              
779             Signature: (a(); [o]b())
780             Types: (float ldouble cfloat cdouble cldouble double)
781              
782             =for usage
783              
784             $b = setnonfinitetobad($a);
785             setnonfinitetobad($a, $b); # all arguments given
786             $b = $a->setnonfinitetobad; # method call
787             $a->setnonfinitetobad($b);
788             $a->inplace->setnonfinitetobad; # can be used inplace
789             setnonfinitetobad($a->inplace);
790              
791             =for ref
792              
793             Sets non-finite values (for complex, where either is non-finite) in
794             the input ndarray bad (only relevant for floating-point ndarrays).
795              
796             =pod
797              
798             Broadcasts over its inputs.
799              
800             =for bad
801              
802             This method can process ndarrays with bad values: those bad values
803             are propagated into the output ndarray. Any value that is not finite
804             is also set to bad in the output ndarray. If all values from the input
805             ndarray are finite, the output ndarray will B have its
806             bad flag set.
807              
808             =cut
809              
810              
811              
812              
813             *setnonfinitetobad = \&PDL::setnonfinitetobad;
814              
815              
816              
817              
818              
819              
820             =head2 setbadtonan
821              
822             =for sig
823              
824             Signature: (a(); [o] b())
825             Types: (float ldouble cfloat cdouble cldouble double)
826              
827             =for usage
828              
829             $b = setbadtonan($a);
830             setbadtonan($a, $b); # all arguments given
831             $b = $a->setbadtonan; # method call
832             $a->setbadtonan($b);
833             $a->inplace->setbadtonan; # can be used inplace
834             setbadtonan($a->inplace);
835              
836             =for ref
837              
838             Sets Bad values to NaN
839              
840             This is only relevant for floating-point ndarrays. The input ndarray can be
841             of any type, but if done inplace, the input must be floating point.
842              
843             =pod
844              
845             Broadcasts over its inputs.
846              
847             =for bad
848              
849             This method processes input ndarrays with bad values. The output ndarrays will
850             not contain bad values (insofar as NaN is not Bad as far as PDL is concerned)
851             and the output ndarray does not have its bad flag set. As an inplace
852             operation, it clears the bad flag.
853              
854             =cut
855              
856              
857              
858              
859             *setbadtonan = \&PDL::setbadtonan;
860              
861              
862              
863              
864              
865              
866             =head2 setbadtoval
867              
868             =for sig
869              
870             Signature: (a(); [o]b(); double newval)
871             Types: (sbyte byte short ushort long ulong indx ulonglong longlong
872             float double ldouble cfloat cdouble cldouble)
873              
874             =for usage
875              
876             $b = setbadtoval($a, $newval);
877             setbadtoval($a, $b, $newval); # all arguments given
878             $b = $a->setbadtoval($newval); # method call
879             $a->setbadtoval($b, $newval);
880             $a->inplace->setbadtoval($newval); # can be used inplace
881             setbadtoval($a->inplace, $newval);
882              
883             =for ref
884              
885             Replace any bad values by a (non-bad) value.
886              
887             Also see L.
888              
889             =for example
890              
891             $x->inplace->setbadtoval(23);
892             print "a badflag: ", $x->badflag, "\n";
893             a badflag: 0
894              
895             =pod
896              
897             Broadcasts over its inputs.
898              
899             =for bad
900              
901             The output always has its bad flag cleared.
902             If the input ndarray does not have its bad flag set, then
903             values are copied with no replacement.
904              
905             =cut
906              
907              
908              
909              
910             *setbadtoval = \&PDL::setbadtoval;
911              
912              
913              
914              
915              
916              
917             =head2 badmask
918              
919             =for sig
920              
921             Signature: (a(); b(); [o]c())
922             Types: (sbyte byte short ushort long ulong indx ulonglong longlong
923             float double ldouble)
924              
925             =for usage
926              
927             $c = badmask($a, $b);
928             badmask($a, $b, $c); # all arguments given
929             $c = $a->badmask($b); # method call
930             $a->badmask($b, $c);
931             $a->inplace->badmask($b); # can be used inplace
932             badmask($a->inplace, $b);
933              
934             =for ref
935              
936             Clears all C and C in C<$a> to the corresponding value in C<$b>.
937              
938             =pod
939              
940             Broadcasts over its inputs.
941              
942             =for bad
943              
944             If bad values are present, these are also cleared.
945              
946             =cut
947              
948              
949              
950              
951             *badmask = \&PDL::badmask;
952              
953              
954              
955              
956              
957              
958             =head2 copybad
959              
960             =for sig
961              
962             Signature: (a(); mask(); [o]b())
963             Types: (sbyte byte short ushort long ulong indx ulonglong longlong
964             float double ldouble cfloat cdouble cldouble)
965              
966             =for usage
967              
968             $b = copybad($a, $mask);
969             copybad($a, $mask, $b); # all arguments given
970             $b = $a->copybad($mask); # method call
971             $a->copybad($mask, $b);
972             $a->inplace->copybad($mask); # can be used inplace
973             copybad($a->inplace, $mask);
974              
975             =for ref
976              
977             Copies values from one ndarray to another, setting them
978             bad if they are bad in the supplied mask.
979              
980             =for example
981              
982             $x = byte( [0,1,3] );
983             $mask = byte( [0,0,0] );
984             $mask->badflag(1);
985             set($mask,1,$mask->badvalue);
986             $x->inplace->copybad( $mask );
987             p $x;
988             [0 BAD 3]
989              
990             It is equivalent to:
991              
992             $c = $x + $mask * 0
993              
994             =pod
995              
996             Broadcasts over its inputs.
997              
998             =for bad
999              
1000             This handles input ndarrays that are bad. If either C<$x>
1001             or C<$mask> have bad values, those values will be marked
1002             as bad in the output ndarray and the output ndarray will have
1003             its bad value flag set to true.
1004              
1005             =cut
1006              
1007              
1008              
1009              
1010             *copybad = \&PDL::copybad;
1011              
1012              
1013              
1014              
1015              
1016              
1017             =head2 locf
1018              
1019             =for sig
1020              
1021             Signature: (a(n); [o]b(n))
1022             Types: (sbyte byte short ushort long ulong indx ulonglong longlong
1023             float double ldouble cfloat cdouble cldouble)
1024              
1025             =for usage
1026              
1027             $b = locf($a);
1028             locf($a, $b); # all arguments given
1029             $b = $a->locf; # method call
1030             $a->locf($b);
1031              
1032             =for ref
1033              
1034             Last Observation Carried Forward - replace
1035             every BAD value with the most recent non-BAD value prior to it.
1036             Any leading BADs will be set to 0.
1037              
1038             =pod
1039              
1040             Broadcasts over its inputs.
1041              
1042             =for bad
1043              
1044             C processes bad values.
1045             It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
1046              
1047             =cut
1048              
1049              
1050              
1051              
1052             *locf = \&PDL::locf;
1053              
1054              
1055              
1056              
1057              
1058              
1059              
1060             #line 915 "lib/PDL/Bad.pd"
1061              
1062             =head1 AUTHOR
1063              
1064             Doug Burke (djburke@cpan.org), 2000, 2001, 2003, 2006.
1065              
1066             The per-ndarray bad value support is by Heiko Klein (2006).
1067              
1068             CPAN documentation fixes by David Mertens (2010, 2013).
1069              
1070             All rights reserved. There is no warranty. You are allowed to
1071             redistribute this software / documentation under certain conditions. For
1072             details, see the file COPYING in the PDL distribution. If this file is
1073             separated from the PDL distribution, the copyright notice should be
1074             included in the file.
1075              
1076             =cut
1077             #line 1078 "lib/PDL/Bad.pm"
1078              
1079             # Exit with OK status
1080              
1081             1;