Skip to content

Commit

Permalink
master: pow_op.hpp: fix bug in pow operator.
Browse files Browse the repository at this point in the history
pow.sh: Test that verifies fix.
  • Loading branch information
bradbell committed Mar 19, 2019
1 parent a423932 commit 2196bce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bug/pow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ int main(int argc, char** argv)
//
x[0] = 0.0;
y = f.Forward(0, x);
//
f.check_for_nan(false);
w[0] = 1.0;
dw = f.Reverse(1, w);
//
Expand Down
9 changes: 9 additions & 0 deletions include/cppad/local/pow_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,15 @@ void reverse_powvp_op(
reverse_log_op(
d, i_z, size_t(arg[0]), cap_order, taylor, nc_partial, partial
);

// Special case where partial[ i_z + 2 ] != 0 and x <= 0.
// In this case partial[i_z] * (1 / x) is zero, but should not be zero.
// (This is a subtitle issue related to the azmul operator.)

This comment has been minimized.

Copy link
@svigerske

svigerske Mar 19, 2019

Member

"subtitle"? :D

Base zero(0);
if( partial[i_z + 2] != zero )
{ if( ! GreaterThanZero( taylor[ size_t(arg[0]) * cap_order ] ) )
partial[arg[0]] = numeric_limits<Base>::quiet_NaN();
}
}

} } // END_CPPAD_LOCAL_NAMESPACE
Expand Down

0 comments on commit 2196bce

Please sign in to comment.