mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fixed bug #702 and added unit test.
Thanks to Alexander Werner for the report.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user