"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Basic/Pod/PP.pod" between
PDL-2.078.tar.gz and PDL-2.079.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

PP.pod  (PDL-2.078):PP.pod  (PDL-2.079)
skipping to change at line 1015 skipping to change at line 1015
=head3 $ISGOODVAR(c_var,pdl) =head3 $ISGOODVAR(c_var,pdl)
As above, but this time checking that the cached value As above, but this time checking that the cached value
isn't bad. isn't bad.
=head3 $SETBADVAR(c_var,pdl) =head3 $SETBADVAR(c_var,pdl)
To copy the bad value for an ndarray into a c variable, use To copy the bad value for an ndarray into a c variable, use
C<$SETBADVAR(foo,a)>. C<$SETBADVAR(foo,a)>.
I<TODO:> mention the C<FindBadStatusCode> and
C<CopyBadStatusCode> options to C<pp_def>, as well as the
C<BadDoc> key.
I<TODO:> mention C<$PPISBAD()> etc macros. I<TODO:> mention C<$PPISBAD()> etc macros.
=head2 PDL STATE macros =head2 PDL STATE macros
If you want access to the value of the badflag for a given If you want access to the value of the badflag for a given
ndarray, you can use the PDL STATE macros: ndarray, you can use the PDL STATE macros,
for use in L</CopyBadStatusCode> and L</FindBadStatusCode>.
=over 4 =over 4
=item $ISPDLSTATEBAD(pdl) =item $ISPDLSTATEBAD(pdl)
=item $ISPDLSTATEGOOD(pdl) =item $ISPDLSTATEGOOD(pdl)
=item $SETPDLSTATEBAD(pdl) =item $SETPDLSTATEBAD(pdl)
=item $SETPDLSTATEGOOD(pdl) =item $SETPDLSTATEGOOD(pdl)
=back =back
And for use in C<Code> sections:
=over 4
=item $PDLSTATEISBAD(pdl)
=item $PDLSTATEISGOOD(pdl)
=item $PDLSTATESETBAD(pdl)
=item $PDLSTATESETGOOD(pdl)
=back
=head2 Bad-value examples =head2 Bad-value examples
Using these macros, the above code could be specified as: Using these macros, the above code could be specified as:
Code => '$c() = $a() + $b();', Code => '$c() = $a() + $b();',
BadCode => ' BadCode => '
if ( $ISBAD(a()) || $ISBAD(b()) ) { if ( $ISBAD(a()) || $ISBAD(b()) ) {
$SETBAD(c()); $SETBAD(c());
} else { } else {
$c() = $a() + $b(); $c() = $a() + $b();
skipping to change at line 1668 skipping to change at line 1679
=back =back
If bad values are being used, care must be taken to ensure the If bad values are being used, care must be taken to ensure the
propagation of the badflag when inplace is being used; propagation of the badflag when inplace is being used;
consider this excerpt from F<Basic/Bad/bad.pd>: consider this excerpt from F<Basic/Bad/bad.pd>:
pp_def('setbadtoval',HandleBad => 1, pp_def('setbadtoval',HandleBad => 1,
Pars => 'a(); [o]b();', Pars => 'a(); [o]b();',
OtherPars => 'double newval', OtherPars => 'double newval',
Inplace => 1, Inplace => 1,
CopyBadStatusCode => CopyBadStatusCode => 'PDL->propagate_badflag( b, 0 );',
'/* propagate badflag if inplace AND it has changed */
if ( a == b && $ISPDLSTATEBAD(a) )
PDL->propagate_badflag( b, 0 );
/* always make sure the output is "good" */
$SETPDLSTATEGOOD(b);
',
... ...
Since this routine removes all bad values, the output ndarray had Since this routine removes all bad values, the output ndarray had
its bad flag cleared. If run inplace (so C<a == b>), then we have to its bad flag cleared. This is then propagated to both parents and children.
tell all the children of C<a> that the bad flag has been cleared (to
save time we make sure that we call C<< PDL->propagate_badflag >> only
if the input ndarray had its bad flag set).
NOTE: one idea is that the documentation for the routine could be NOTE: one idea is that the documentation for the routine could be
automatically flagged to indicate that it can be executed inplace, automatically flagged to indicate that it can be executed inplace,
ie something similar to how C<HandleBad> sets C<BadDoc> if it's not ie something similar to how C<HandleBad> sets C<BadDoc> if it's not
supplied (it's not an ideal solution). supplied (it's not an ideal solution).
=head3 FTypes =head3 FTypes
# in slices.pd # in slices.pd
FTypes => {CHILD => '$COMP(totype)'}, FTypes => {CHILD => '$COMP(totype)'},
skipping to change at line 2142 skipping to change at line 2143
If set to 0, cause the routine to print a warning if any of the input ndarrays If set to 0, cause the routine to print a warning if any of the input ndarrays
have their bad flag set. have their bad flag set.
=head3 BadCode =head3 BadCode
Give the code to be used if bad values may be present in the input ndarrays. Give the code to be used if bad values may be present in the input ndarrays.
Only used if C<< HandleBad => 1 >>. Only used if C<< HandleBad => 1 >>.
If C<HandleBad> is true and C<BadCode> is not supplied, the C<Code> If C<HandleBad> is true and C<BadCode> is not supplied, the C<Code>
section will be reused, on the assumption it will use section will be reused, on the assumption it will use
C<#ifdef PDL_BAD_CODE> to handle bad values. C<#ifdef PDL_BAD_CODE> to handle bad values.
As of 2.073, you can also use C<PDL_IF_BAD(iftrue,iffalse)>. As of 2.073, you can, and are recommended to, use C<PDL_IF_BAD(iftrue,iffalse)>.
=head3 CopyBadStatusCode
As of 2.079, this is deprecated due to being largely unnecessary;
instead, just use C<$PDLSTATESETBAD(pdlname)> in your C<Code> section
and the badflag setting will be propagated to all its parents and
children.
The default code here sets the bad flag of the output ndarrays if
C<$BADFLAGCACHE()> is true after the code has been
evaluated. Sometimes C<CopyBadStatusCode> is set to an empty string,
with the responsibility of setting the badflag of the output ndarray
left to the C<BadCode> section (e.g. the C<xxxover> routines
in F<Basic/Primitive/primitive.pd>).
=head3 GenericTypes =head3 GenericTypes
An array reference. The array may contain any subset of the one-character An array reference. The array may contain any subset of the one-character
strings given below, which specify which types your operation will strings given below, which specify which types your operation will
accept. The meaning of each type is: accept. The meaning of each type is:
B - signed byte (i.e. signed char) B - signed byte (i.e. signed char)
S - signed short (two-byte integer) S - signed short (two-byte integer)
U - unsigned short U - unsigned short
 End of changes. 6 change blocks. 
18 lines changed or deleted 33 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)