[CppAD] Avoid retaping when constant is changed

Hilario Tomé tome.hilario at gmail.com
Wed Jun 28 07:51:35 EDT 2017


Thank you Brad for the answer, I thought of doing what you suggested, but I
would later face the problem of having to manually trim the jacobian when I
call the jacobian method of the adfun object, and also the extra
computation not needed when computing the full jacobian, do you have any
work around for this?

Best,

On Wed, Jun 28, 2017 at 1:43 PM, Brad Bell <bradbell at seanet.com> wrote:

> I would try the following approach:
>
> Use c (or any other name) to denote the constant (a scalar) and let n be
> the length of the vector x.
> Then do the following;
>     Vector< AD<double> > a_xc(n+1);
>     for(size_t j = 0; j < n; j++)
>         a_xc[j] = x[j];
>     a_xc[n] = c;
>     Independent( a_xc );
>     Vector< AD<double> > a_x(n);
>     AD<double> a_c;
>     for(size_t j = 0; j < n; j++)
>         a_x[j] = a_xc[j];
>    a_c = a_xc[n];
> In other words make c a variable. That way you can change is value when
> computing derivatives.
>
>
>
>
>
>
>
> On 06/28/2017 04:27 AM, Hilario Tomé wrote:
>
> Dear all,
>
>
>
> I would like to know if it's possible to record a pointer to an external
> value in the tape. The use case is to have formulas like y = constant*x.
> Once the ADfun object is created if I change the value of constant I have
> to retape right now, and sometimes the re-taping operation is to costly,
> especially if sparsity operations are involved.
>
>
>
> Best,
>
> --
> Hilario.
>
>
> _______________________________________________
> CppAD mailing listCppAD at list.coin-or.orghttps://list.coin-or.org/mailman/listinfo/cppad <https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_cppad&d=DwMDaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=GH3eJ7xA3ZBR9rQvT_fJhDgld4V8Nzy-5rXbR27Kb5c&m=1mBE6bNs5eNxiLDQVywSDTN4TIfnDxcxIe-wUHbDd80&s=sjbUY3bPGw7yzllPcFdDlP6RIXCLMUiM62_VWPzTCwU&e=>
>
>
>
> _______________________________________________
> CppAD mailing list
> CppAD at list.coin-or.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.
> coin-2Dor.org_mailman_listinfo_cppad&d=DwICAg&c=Ngd-
> ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=GH3eJ7xA3ZBR9rQvT_
> fJhDgld4V8Nzy-5rXbR27Kb5c&m=1mBE6bNs5eNxiLDQVywSDTN4TIfnDxcxIe-wUHbDd80&s=
> sjbUY3bPGw7yzllPcFdDlP6RIXCLMUiM62_VWPzTCwU&e=
>
>


-- 
Hilario.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cppad/attachments/20170628/2fe96cb2/attachment.html>


More information about the CppAD mailing list