aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-10-16 11:27:04 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-10-16 11:27:04 +0200
commit44ba4b1d6d5cd39d824bb83876175d0dc39a9cc3 (patch)
tree5c84b49bc499de8a836e57dbc67de668a5484081
parentd177c1f3aca150d36d17c8116504e3ea1e7b30cf (diff)
add operator+ scalar to AutoDiffScalar
-rw-r--r--unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h
index 888aa5c8c..fc5e237ab 100644
--- a/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h
+++ b/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h
@@ -108,6 +108,22 @@ class AutoDiffScalar
inline const DerType& derivatives() const { return m_derivatives; }
inline DerType& derivatives() { return m_derivatives; }
+ inline const AutoDiffScalar<DerType> operator+(const Scalar& other) const
+ {
+ return AutoDiffScalar<DerType>(m_value + other, m_derivatives);
+ }
+
+ friend inline const AutoDiffScalar<DerType> operator+(const Scalar& a, const AutoDiffScalar& b)
+ {
+ return AutoDiffScalar<DerType>(a + b.value(), b.derivatives());
+ }
+
+ inline AutoDiffScalar& operator+=(const Scalar& other)
+ {
+ value() += other;
+ return *this;
+ }
+
template<typename OtherDerType>
inline const AutoDiffScalar<CwiseBinaryOp<ei_scalar_sum_op<Scalar>,DerType,OtherDerType> >
operator+(const AutoDiffScalar<OtherDerType>& other) const