Don't use updated values for computing derivatives

We must not overwrite the current evaluation point until all the
derivative values have been calculated.  Otherwise, the derivatives
will differ from that of the actual values.
This commit is contained in:
Bård Skaflestad 2013-04-29 23:28:49 +02:00
parent 72e2b1f5ca
commit 72d6d32095

View File

@ -96,8 +96,8 @@ namespace AutoDiff {
Forward&
operator *=(const Forward& rhs)
{
x_ *= rhs.x_;
dx_ *= dx_*rhs.x_ + x_*rhs.dx_;
x_ *= rhs.x_;
return *this;
}
@ -114,8 +114,8 @@ namespace AutoDiff {
Forward&
operator /=(const Forward& rhs)
{
x_ /= rhs.x_;
dx_ = (dx_*rhs.x_ - x_*rhs.dx_) / (rhs.x_ * rhs.x_);
x_ /= rhs.x_;
return *this;
}