<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Try the following<br>
tmp = tmp + AD< AD<double> > (0.5) * tmp<br>
For example, the following program:<br>
<br>
# include <cppad/cppad.hpp><br>
# include <cppad/example/cppad_eigen.hpp><br>
int main(void)<br>
{ bool ok = true;<br>
//<br>
typedef CppAD::AD< CppAD::AD<double> >
Scalar;<br>
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1>
Vector;<br>
//<br>
Vector tmp(1);<br>
tmp[0] = 1.0;<br>
tmp = tmp + Scalar(1.0) * tmp;<br>
//<br>
ok &= tmp[0] == 2.0;<br>
if( ok )<br>
return 0;<br>
return 1;<br>
}<br>
~ <br>
<br>
<br>
On 12/15/2015 7:55 AM, Leitz, Thomas wrote:<br>
</div>
<blockquote cite="mid:D295E847.4594%25thomas.leitz@fau.de"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=us-ascii">
<div>
<div>
<div><span>Hello,</span></div>
</div>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div>
<div>
<br>
</div>
<div>
I'm using CppAD with Eigen. Multiplication of a double with
an Eigen-Vector like this:</div>
<div>
<br>
</div>
<div>
---</div>
<div>
<br>
</div>
<div>
<div>template<typename Type></div>
<div>using Vector = Eigen::Matrix<Type, Eigen::Dynamic,
1>;</div>
</div>
<div>
<br>
</div>
<div>
<div>Vector< AD< AD<double> > > tmp;</div>
<div><br>
</div>
<div>tmp = tmp + 0.5 * tmp;</div>
</div>
<div>
<br>
</div>
<div>
---</div>
<div>
<br>
</div>
<div>
gives the following error</div>
<div>
<br>
</div>
<div>
<p><b> </b><b>error: </b><b>invalid operands to binary
expression ('double' and
'Vector<AD<AD<double> > >' (aka
'Eigen::Matrix<CppAD::AD<<wbr>CppAD::AD<double>
>, -1, 1, 0, -1, 1>'))</b></p>
<p> tmp = tmp + 0.5 * tmp;</p>
</div>
<div>
<br>
</div>
<div>
<br>
</div>
<div>
The error goes away if I do</div>
<div>
<br>
</div>
<div>
---</div>
<div>
tmp = tmp + AD<double>(0.5) * tmp;</div>
<div>
---</div>
<div>
<br>
</div>
<div>
Is this the right way to do it?</div>
<div>
Btw. an AD< AD<double> > can be multiplied by a
double just fine. </div>
<div>
<br>
</div>
<div>
Thomas</div>
</div>
</span>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
CppAD mailing list
<a class="moz-txt-link-abbreviated" href="mailto:CppAD@list.coin-or.org">CppAD@list.coin-or.org</a>
<a class="moz-txt-link-freetext" href="http://list.coin-or.org/mailman/listinfo/cppad">http://list.coin-or.org/mailman/listinfo/cppad</a>
</pre>
</blockquote>
<br>
</body>
</html>