[CppAD] The ADFun Assignment Statement
Brad Bell
bradbell at seanet.com
Thu Dec 24 08:31:32 EST 2009
In response to a user request (see below), the ADFun assignment operation
g = f
has been changed; see
http://www.coin-or.org/CppAD/Doc/funconstruct.xml#Assignment%20Operator
Now all of the information stored in the ADFun object on the right, f,
is copied to the target on the left, g. While this is backward
compatible, it may use more memory than previously.
If you have Taylor coefficients stored in f, and you do not want to copy
the Taylor coefficients, you can use the call
f.capacity_taylor(0)
to remove the Taylor coefficients currently stored in f; see
http://www.coin-or.org/CppAD/Doc/capacity_taylor.xml
If you have forward mode sparsity information in f, and you do not want
to copy sparsity information, you can use the calls
f.size_forward_bool(0)
f.size_forward_set(0)
to remove the sparsity information stored in f; see
http://www.coin-or.org/CppAD/Doc/funconstruct.xml#Assignment%20Operator.Sparsity%20Patterns
Suppose that you want to keep the information in f, but make lots of
copies without the information in g[0], g[1], ... , g[n-1] (perhaps each
g[i] is an ADFun object to be used by a different thread). I would suggest
h = f;
h.capacity_taylor(0);
h.size_forward_bool(0);
h.size_forward_set(0);
for(i = 0; i < n; i++);
g[i] = h;
Brad Bell wrote:
>
>
> The key ideas are this:
> 1. All the information stored in the ADFun object is copied by the
> ADFun assignment statement.
> 2. You can control the number of Taylor coefficients stored with
> f.capacity_taylor(k)
> 3. You can control if the sparsity information is stored with
> f.size_forward_pack(0)
> f.size_forward_set(0).
>
> As always, the svn download is immediately available. The tarballs and
> help will be built early tomorrow morning (Eastern Standard Time).
>
> P.S.
> I have worked some more on the optimization of sequences of additions.
> https://projects.coin-or.org/CppAD/changeset/1612
>
> Dominik Skanda wrote:
>> Hello,
>>
>> I have an additional question concerning the copy
>> constructor. Is it possible to incorporate a method to copy
>> a ADFUN object with the taylorseries to n-th order?
>> For example
>>
>> ADFun<Base> f, g;
>>
>>
>> CppAD::copy(f,g,3); //this means copy g to f and all Taylor
>> coefficients till order 3 !!
>>
>> Many thanks in advance!
>> Dominik
>>
>>
>
>
More information about the CppAD
mailing list