Autodiff: fix scalr - active_scalar

This commit is contained in:
Gael Guennebaud 2011-05-14 22:38:41 +02:00
parent 9a06055870
commit d4fd298fbb

View File

@ -221,9 +221,11 @@ class AutoDiffScalar
return AutoDiffScalar<DerType&>(m_value - b, m_derivatives);
}
friend inline const AutoDiffScalar<DerType&> operator-(const Scalar& a, const AutoDiffScalar& b)
friend inline const AutoDiffScalar<CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const DerType> >
operator-(const Scalar& a, const AutoDiffScalar& b)
{
return AutoDiffScalar<DerType&>(a - b.value(), b.derivatives());
return AutoDiffScalar<CwiseUnaryOp<internal::scalar_opposite_op<Scalar>, const DerType> >
(a - b.value(), -b.derivatives());
}
template<typename OtherDerType>