diff options
author | Christoph Hertzberg <chtz@informatik.uni-bremen.de> | 2013-11-07 18:32:24 +0100 |
---|---|---|
committer | Christoph Hertzberg <chtz@informatik.uni-bremen.de> | 2013-11-07 18:32:24 +0100 |
commit | ae83f5ede96cb1171fb5fd9303777a9035748ca9 (patch) | |
tree | 727b5ba43aee85da5f30728fefbc35642337be48 /unsupported/Eigen/src/AutoDiff | |
parent | 76c230a84d4857722e4a72e9007302a504af0fb7 (diff) |
Fixed bug #702 and added unit test.
Thanks to Alexander Werner for the report.
Diffstat (limited to 'unsupported/Eigen/src/AutoDiff')
-rw-r--r-- | unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h index 8d42e69b9..590797973 100644 --- a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h +++ b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h @@ -599,12 +599,10 @@ atan2(const AutoDiffScalar<DerTypeA>& a, const AutoDiffScalar<DerTypeB>& b) PlainADS ret; ret.value() = atan2(a.value(), b.value()); - Scalar tmp2 = a.value() * a.value(); - Scalar tmp3 = b.value() * b.value(); - Scalar tmp4 = tmp3/(tmp2+tmp3); + Scalar squared_hypot = a.value() * a.value() + b.value() * b.value(); - if (tmp4!=0) - ret.derivatives() = (a.derivatives() * b.value() - a.value() * b.derivatives()) * (tmp2+tmp3); + // if (squared_hypot==0) the derivation is undefined and the following results in a NaN: + ret.derivatives() = (a.derivatives() * b.value() - a.value() * b.derivatives()) / squared_hypot; return ret; } |