Merge remote-tracking branch 'bska/master'

This commit is contained in:
Atgeirr Flø Rasmussen 2013-04-30 11:07:13 +02:00
commit 0bf693e8c0

View File

@ -58,74 +58,58 @@ namespace AutoDiff {
return Forward(x, dx); return Forward(x, dx);
} }
Forward& void
operator +=(const Scalar& rhs) operator +=(const Scalar& rhs)
{ {
val_ += rhs; val_ += rhs;
return *this;
} }
Forward& void
operator +=(const Forward& rhs) operator +=(const Forward& rhs)
{ {
val_ += rhs.val_; val_ += rhs.val_;
der_ += rhs.der_; der_ += rhs.der_;
return *this;
} }
Forward& void
operator -=(const Scalar& rhs) operator -=(const Scalar& rhs)
{ {
val_ -= rhs; val_ -= rhs;
return *this;
} }
Forward& void
operator -=(const Forward& rhs) operator -=(const Forward& rhs)
{ {
val_ -= rhs.val_; val_ -= rhs.val_;
der_ -= rhs.der_; der_ -= rhs.der_;
return *this;
} }
Forward& void
operator *=(const Scalar& rhs) operator *=(const Scalar& rhs)
{ {
val_ *= rhs; val_ *= rhs;
der_ *= rhs; der_ *= rhs;
return *this;
} }
Forward& void
operator *=(const Forward& rhs) operator *=(const Forward& rhs)
{ {
der_ = der_*rhs.val_ + val_*rhs.der_; der_ = der_*rhs.val_ + val_*rhs.der_;
val_ *= rhs.val_; val_ *= rhs.val_;
return *this;
} }
Forward& void
operator /=(const Scalar& rhs) operator /=(const Scalar& rhs)
{ {
val_ /= rhs; val_ /= rhs;
der_ /= rhs; der_ /= rhs;
return *this;
} }
Forward& void
operator /=(const Forward& rhs) operator /=(const Forward& rhs)
{ {
der_ = (der_*rhs.val_ - val_*rhs.der_) / (rhs.val_ * rhs.val_); der_ = (der_*rhs.val_ - val_*rhs.der_) / (rhs.val_ * rhs.val_);
val_ /= rhs.val_; val_ /= rhs.val_;
return *this;
} }
template <class Ostream> template <class Ostream>