Merge pull request #535 from atgeirr/bug-in-scalar-autodiff

Fix bug in scalar autodiff
This commit is contained in:
Bård Skaflestad 2015-11-10 14:02:49 +01:00
commit 308a3fd57e
2 changed files with 2 additions and 2 deletions

View File

@ -256,7 +256,7 @@ namespace Opm
const AutoDiff<Scalar>& rhs) const AutoDiff<Scalar>& rhs)
{ {
Scalar a = Scalar(lhs) / rhs.val(); Scalar a = Scalar(lhs) / rhs.val();
Scalar b = -Scalar(lhs) / (rhs.val() * rhs.val()); Scalar b = (-Scalar(lhs) / (rhs.val() * rhs.val())) * rhs.der();
return AutoDiff<Scalar>::function(a, b); return AutoDiff<Scalar>::function(a, b);
} }

View File

@ -154,7 +154,7 @@ BOOST_AUTO_TEST_CASE(Division)
const double atol = 1.0e-14; const double atol = 1.0e-14;
AdFW a = AdFW::variable(10.0); AdFW a = AdFW::variable(10.0);
AdFW b = AdFW::variable(1.0); AdFW b = AdFW::function(1.0, 4.0);
AdFW aob = a / b; AdFW aob = a / b;
BOOST_CHECK_CLOSE(aob.val(), a.val() * b.val(), atol); BOOST_CHECK_CLOSE(aob.val(), a.val() * b.val(), atol);