<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Using the call<br>
pow(x, y)<br>
the function<br>
<a class="moz-txt-link-freetext" href="http://www.coin-or.org/CppAD/Doc/pow_int.xml">http://www.coin-or.org/CppAD/Doc/pow_int.xml</a><br>
is used if y has prototype<br>
const int& y<br>
<br>
If y has type Base, or AD<Base>, the function<br>
<a class="moz-txt-link-freetext" href="http://www.coin-or.org/CppAD/Doc/pow.xml">http://www.coin-or.org/CppAD/Doc/pow.xml</a><br>
is used.<br>
<br>
<br>
<br>
On 07/05/2012 02:35 AM, João Leal wrote:
<blockquote
cite="mid:CAE+OZpaDYTE_4R7CzJ6xrLimn8SL0pyYDarPzTZKhyTBwg2nYA@mail.gmail.com"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=ISO-8859-1">
Hello!<br>
<br>
While using CppADCodegen I've noticed that CppAD used
multiplications for <br>
<br>
pow(variable, parameter).<br>
<br>
For instance, the following model<br>
<br>
Z[0] = pow(u[0], 25);<br>
<br>
will produce the following source code in CppADCodegen for forward
zero order:<br>
<br>
var4 = ind[0] * ind[0];<br>
var5 = var4 * var4;<br>
var6 = var5 * var5;<br>
dep[0] = var6 * var6 * var6 * ind[0];<br>
<br>
I would expect CppAD to also use the pow function and not all
these multiplications (not sure which is faster though).<br>
<br>
and the following for the jacobian:<br>
<br>
var4 = ind[0] * ind[0];<br>
var5 = var4 * var4;<br>
var6 = var5 * var5;<br>
var7 = var6 * var6;<br>
var8 = ind[0] * var6;<br>
var9 = ind[0] * var7 + var8 * var6 + var8 * var6;<br>
var10 = var9 * var5 + var9 * var5;<br>
var11 = var10 * var4 + var10 * var4;<br>
jac[0] = var7 * var6 + var11 * ind[0] + var11 * ind[0];<br>
<br>
Is there any way to change this behavior without doing significant
changes to CppAD?<br>
<br>
Best regards,<br>
<br>
João Leal<br>
<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>