"Fossies" - the Fresh Open Source Software Archive

Member "PDL-2.080/GENERATED/PDL/Bad.pm" (28 May 2022, 19292 Bytes) of package /linux/misc/PDL-2.080.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Bad.pm" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.079_vs_2.080.

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