Closed roystgnr closed 5 years ago
Oh, hell, even this isn't enough, is it? When a == 0, b == 1, we'll be evaluating pow(0,0) and getting NaN instead of 1. Maybe we'll be stuck with another if_else after all.
Still, this seems to be a solid upgrade over the previous code, so let's move to it for now.
We were previously trying to avoid an extra pow call by simply dividing the result of the original call by the base, but this gives 0/0 => NaN when the base is 0, even for the b > 1 case where the derivative should be well-defined.
Hopefully this fixes the aside @dschwen pointed out in #35.
This ends up forcing an extra std::pow call in the DualNumber case, which isn't great for efficiency, but isn't the yet-another-if_else efficiency disaster I was fearing.