[CppAD] pow function

Brad Bell bradbell at seanet.com
Sun Jul 8 05:18:04 EDT 2012


Using  the call
     pow(x, y)
the function
     http://www.coin-or.org/CppAD/Doc/pow_int.xml
is used if y has prototype
     const int& y

If y has type Base, or AD<Base>, the function
     http://www.coin-or.org/CppAD/Doc/pow.xml
is used.



On 07/05/2012 02:35 AM, João Leal wrote:
> Hello!
>
> While using CppADCodegen I've noticed that CppAD used multiplications for
>
>    pow(variable, parameter).
>
> For instance, the following model
>
>    Z[0] = pow(u[0], 25);
>
> will produce the following source code in CppADCodegen for forward 
> zero order:
>
>    var4 = ind[0] * ind[0];
>    var5 = var4 * var4;
>    var6 = var5 * var5;
>    dep[0] = var6 * var6 * var6 * ind[0];
>
> I would expect CppAD to also use the pow function and not all these 
> multiplications (not sure which is faster though).
>
> and the following for the jacobian:
>
>    var4 = ind[0] * ind[0];
>    var5 = var4 * var4;
>    var6 = var5 * var5;
>    var7 = var6 * var6;
>    var8 = ind[0] * var6;
>    var9 = ind[0] * var7 + var8 * var6 + var8 * var6;
>    var10 = var9 * var5 + var9 * var5;
>    var11 = var10 * var4 + var10 * var4;
>    jac[0] = var7 * var6 + var11 * ind[0] + var11 * ind[0];
>
> Is there any way to change this behavior without doing significant 
> changes to CppAD?
>
> Best regards,
>
> João Leal
>
>
> _______________________________________________
> CppAD mailing list
> CppAD at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cppad

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cppad/attachments/20120708/3494593d/attachment.html>


More information about the CppAD mailing list