<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Using&nbsp; the call<br>
    &nbsp;&nbsp;&nbsp; pow(x, y)<br>
    the function<br>
    &nbsp;&nbsp;&nbsp; <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>
    &nbsp;&nbsp;&nbsp; const int&amp; y<br>
    <br>
    If y has type Base, or AD&lt;Base&gt;, the function<br>
    &nbsp;&nbsp;&nbsp; <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>
    &nbsp;&nbsp;&nbsp; <br>
    <br>
    On 07/05/2012 02:35 AM, Jo&atilde;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>
      &nbsp;&nbsp; pow(variable, parameter).<br>
      <br>
      For instance, the following model<br>
      <br>
      &nbsp;&nbsp; Z[0] = pow(u[0], 25);<br>
      <br>
      will produce the following source code in CppADCodegen for forward
      zero order:<br>
      <br>
      &nbsp;&nbsp; var4 = ind[0] * ind[0];<br>
      &nbsp;&nbsp; var5 = var4 * var4;<br>
      &nbsp;&nbsp; var6 = var5 * var5;<br>
      &nbsp;&nbsp; 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>
      &nbsp;&nbsp; var4 = ind[0] * ind[0];<br>
      &nbsp;&nbsp; var5 = var4 * var4;<br>
      &nbsp;&nbsp; var6 = var5 * var5;<br>
      &nbsp;&nbsp; var7 = var6 * var6;<br>
      &nbsp;&nbsp; var8 = ind[0] * var6;<br>
      &nbsp;&nbsp; var9 = ind[0] * var7 + var8 * var6 + var8 * var6;<br>
      &nbsp;&nbsp; var10 = var9 * var5 + var9 * var5;<br>
      &nbsp;&nbsp; var11 = var10 * var4 + var10 * var4;<br>
      &nbsp;&nbsp; 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&atilde;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>