[CppAD] pow function
João Leal
joaoruileal at gmail.com
Thu Jul 5 05:35:04 EDT 2012
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cppad/attachments/20120705/e49731c2/attachment.html>
More information about the CppAD
mailing list