[CppAD] Avoid retaping when constant is changed

Brad Bell bradbell at seanet.com
Wed Jun 28 07:43:00 EDT 2017


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 list
> CppAD at list.coin-or.org
> https://list.coin-or.org/mailman/listinfo/cppad

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


More information about the CppAD mailing list