"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Basic/Ufunc/ufunc.pd" between
PDL-2.076.tar.gz and PDL-2.077.tar.gz

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

ufunc.pd  (PDL-2.076):ufunc.pd  (PDL-2.077)
skipping to change at line 364 skipping to change at line 364
my ($name, $op, $synonym) = @$which; my ($name, $op, $synonym) = @$which;
pp_def( pp_def(
$name, $name,
HandleBad => 1, HandleBad => 1,
Pars => 'a(n); [o]c();', Pars => 'a(n); [o]c();',
Code => Code =>
'$GENERIC() cur = 0; '$GENERIC() cur = 0;
int flag = 0; int flag = 0;
loop(n) %{ loop(n) %{
if( !flag || ($a() '.$op.' cur ) || PDL_ISNAN_$PPSYM()(cur) ) { c PDL_IF_BAD(if ($ISBAD(a())) continue;,)
ur = $a(); flag = 1;} if( !flag || ($a() '.$op.' cur ) || PDL_ISNAN_$PPSYM()(cur) )
%} {cur = $a(); flag = 1;}
if(flag && !PDL_ISNAN_$PPSYM()(cur)) {
$c() = cur;
} else {
$SETBAD(c());
$PDLSTATESETBAD(c);
}
',
BadCode =>
'$GENERIC() cur = 0;
int flag = 0;
loop(n) %{
if( $ISGOOD(a()) && ($a()*0 == 0) && (!flag || $a() '.$op.' cur))
{cur = $a(); flag = 1;}
%} %}
if ( flag ) { $c() = cur; } if ( flag ) { $c() = cur; }
else { $SETBAD(c()); $PDLSTATESETBAD(c); }', else { $SETBAD(c()); $PDLSTATESETBAD(c); }',
CopyBadStatusCode => '', CopyBadStatusCode => '',
Doc => projectdocs($name,$name,''), Doc => projectdocs($name,$name,''),
BadDoc => BadDoc =>
'Output is set bad if all elements of the input are bad, 'Output is set bad if no elements of the input are non-bad,
otherwise the bad flag is cleared for the output ndarray. otherwise the bad flag is cleared for the output ndarray.
Note that C<NaNs> are considered to be valid values; Note that C<NaNs> are considered to be valid values and will "win" over non-C<Na N>;
see L<isfinite|PDL::Math/isfinite> and L<badmask|PDL::Math/badmask> see L<isfinite|PDL::Math/isfinite> and L<badmask|PDL::Math/badmask>
for ways of masking NaNs. for ways of masking NaNs.
', ',
); );
synonym($name, $synonym); synonym($name, $synonym);
pp_def( pp_def(
"${name}_ind", "${name}_ind",
HandleBad => 1, HandleBad => 1,
Pars => 'a(n); indx [o] c();', Pars => 'a(n); indx [o] c();',
Code => Code =>
'$GENERIC() cur = 0; '$GENERIC() cur = 0;
PDL_Indx curind = -1; PDL_Indx curind = -1;
loop(n) %{ loop(n) %{
PDL_IF_BAD(if ($ISBAD(a())) continue;,)
if(curind == -1 || $a() '.$op.' cur || PDL_ISNAN_$PPSYM()(cur)) if(curind == -1 || $a() '.$op.' cur || PDL_ISNAN_$PPSYM()(cur))
{cur = $a(); curind = n;} {cur = $a(); curind = n;}
%} %}
if(curind != -1 && !PDL_ISNAN_$PPSYM()(cur)) { if ( curind != -1 ) { $c() = curind; }
$c() = curind;
} else {
$SETBAD(c());
$PDLSTATESETBAD(c);
}
',
BadCode =>
'$GENERIC() cur = 0;
PDL_Indx curind = -1;
loop(n) %{
if( $ISGOOD(a()) && (curind == -1 || $a() '.$op.' cur))
{cur = $a(); curind = n;}
%}
if ( curind != -1 && !PDL_ISNAN_$PPSYM()(cur) ) { $c() = curind; }
else { $SETBAD(c()); $PDLSTATESETBAD(c); }', else { $SETBAD(c()); $PDLSTATESETBAD(c); }',
CopyBadStatusCode => '', CopyBadStatusCode => '',
Doc => "Like $name but returns the index rather than the value", Doc => "Like $name but returns the index rather than the value",
BadDoc => BadDoc =>
'Output is set bad if all elements of the input are bad, 'Output is set bad if no elements of the input are non-bad,
otherwise the bad flag is cleared for the output ndarray.', otherwise the bad flag is cleared for the output ndarray.
Note that C<NaNs> are considered to be valid values and will "win" over non-C<Na
N>;
see L<isfinite|PDL::Math/isfinite> and L<badmask|PDL::Math/badmask>
for ways of masking NaNs.
',
); );
synonym("${name}_ind", "${synonym}_ind"); synonym("${name}_ind", "${synonym}_ind");
pp_def( pp_def(
"${name}_n_ind", "${name}_n_ind",
HandleBad => 0, # just a marker HandleBad => 1,
Pars => 'a(n); indx [o]c(m);', Pars => 'a(n); indx [o]c(m);',
OtherPars => 'PDL_Indx m_size => m;',
PMCode => PDL::PP::pp_line_numbers(__LINE__, <<EOF),
sub PDL::${name}_n_ind {
my (\$a, \$c, \$m_size) = \@_;
\$m_size //= ref(\$c) ? \$c->dim(0) : \$c; # back-compat with pre-2.077
my \$set_out = 1;
\$set_out = 0, \$c = null if !ref \$c;
\$c = \$c->indx if !\$c->isnull;
PDL::_${name}_n_ind_int(\$a, \$c, \$m_size);
\$set_out ? \$_[1] = \$c : \$c;
}
EOF
Code => Code =>
'$GENERIC() cur = 0; PDL_Indx curind; register PDL_Indx ns = $SIZE(n) ; '$GENERIC() cur = 0; PDL_Indx curind; register PDL_Indx ns = $SIZE(n) ;
if($SIZE(m) > $SIZE(n)) $CROAK("n_ind: m_size > n_size"); if($SIZE(m) > $SIZE(n)) $CROAK("m_size > n_size");
$PDLSTATESETGOOD(c);
loop(m) %{ loop(m) %{
curind = ns; curind = ns;
loop(n) %{ loop(n) %{
PDL_Indx nm; int flag=0; PDL_Indx nm; int flag=0;
for(nm=0; nm<m; nm++) { for(nm=0; nm<m; nm++) {
if($c(m=>nm) == n) {flag=1; break;} if($c(m=>nm) == n) {flag=1; break;}
} }
if(!flag && if(!flag &&
PDL_IF_BAD($ISGOOD(a()) &&,)
((curind == ns) || $a() '.$op.' cur || PDL_ISNAN_$PPSY M()(cur))) ((curind == ns) || $a() '.$op.' cur || PDL_ISNAN_$PPSY M()(cur)))
{cur = $a(); curind = n;} {cur = $a(); curind = n;}
%} %}
$c() = curind; if (curind != ns) { $c() = curind; }
else { $SETBAD(c()); $PDLSTATESETBAD(c); }
%}', %}',
Doc => "Returns the index of C<m> $name elements", CopyBadStatusCode => '',
BadDoc => 'Not yet been converted to ignore bad values', Doc => <<EOF,
=for ref
Returns the index of C<m_size> $name elements. As of 2.077, you can
specify how many by either passing in an ndarray of the given size
(DEPRECATED - will be converted to indx if needed and the input arg will
be set to that), or just the size, or a null and the size.
=for usage
${name}_n_ind(\$pdl, \$out = zeroes(5)); # DEPRECATED
\$out = ${name}_n_ind(\$pdl, 5);
${name}_n_ind(\$pdl, \$out = null, 5);
EOF
BadDoc =>
'Output bad flag is cleared for the output ndarray if sufficient non-bad element
s found,
else remaining slots in C<$c()> are set bad.
Note that C<NaNs> are considered to be valid values and will "win" over non-C<Na
N>;
see L<isfinite|PDL::Math/isfinite> and L<badmask|PDL::Math/badmask>
for ways of masking NaNs.
',
); );
synonym("${name}_n_ind", "${synonym}_n_ind"); synonym("${name}_n_ind", "${synonym}_n_ind");
} # foreach: $which } # foreach: $which
pp_def( pp_def(
'minmaximum', 'minmaximum',
HandleBad => 1, HandleBad => 1,
Pars => 'a(n); [o]cmin(); [o] cmax(); indx [o]cmin_ind(); indx [o]cmax_in d();', Pars => 'a(n); [o]cmin(); [o] cmax(); indx [o]cmin_ind(); indx [o]cmax_in d();',
Code => Code =>
'$GENERIC() curmin = 0, curmax = 0; /* Handle null ndarray --CED */ '$GENERIC() curmin = 0, curmax = 0; /* Handle null ndarray --CED */
skipping to change at line 639 skipping to change at line 657
Returns a list with minimum and maximum values of an ndarray. Returns a list with minimum and maximum values of an ndarray.
=for usage =for usage
($mn, $mx) = minmax($pdl); ($mn, $mx) = minmax($pdl);
This routine does I<not> broadcast over the dimensions of C<$pdl>; This routine does I<not> broadcast over the dimensions of C<$pdl>;
it returns the minimum and maximum values of the whole ndarray. it returns the minimum and maximum values of the whole ndarray.
See L</minmaximum> if this is not what is required. See L</minmaximum> if this is not what is required.
The two values are returned as Perl scalars similar to min/max, The two values are returned as Perl scalars,
and therefore ignore whether the values are bad. and therefore ignore whether the values are bad.
=for example =for example
pdl> $x = pdl [1,-2,3,5,0] pdl> $x = pdl [1,-2,3,5,0]
pdl> ($min, $max) = minmax($x); pdl> ($min, $max) = minmax($x);
pdl> p "$min $max\n"; pdl> p "$min $max\n";
-2 5 -2 5
=cut =cut
 End of changes. 13 change blocks. 
41 lines changed or deleted 60 lines changed or added

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