[CppAD] Multiplication of scalar (double) and Vector (AD< AD<double> >)

Leitz, Thomas thomas.leitz at fau.de
Tue Dec 15 09:55:36 EST 2015


Hello,

I'm using CppAD with Eigen. Multiplication of a double with an Eigen-Vector like this:

---

template<typename Type>
using Vector = Eigen::Matrix<Type, Eigen::Dynamic, 1>;

Vector< AD< AD<double> > > tmp;

tmp = tmp + 0.5 * tmp;

---

gives the following error


 error: invalid operands to binary expression ('double' and 'Vector<AD<AD<double> > >' (aka 'Eigen::Matrix<CppAD::AD<CppAD::AD<double> >, -1, 1, 0, -1, 1>'))

    tmp = tmp + 0.5 * tmp;


The error goes away if I do

---
tmp = tmp + AD<double>(0.5) * tmp;
---

Is this the right way to do it?
Btw. an AD< AD<double> > can be multiplied by a double just fine.

Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cppad/attachments/20151215/8876e798/attachment.html>


More information about the CppAD mailing list