[ADOL-C] advector example

Kshitij Kulshreshtha kshitij at math.upb.de
Fri Mar 22 17:55:15 EDT 2013


advector can indeed deal with changing indices in an array at a
different evaluation point.

The constructor advector(const std::vector<adouble>& v) will indeed copy
the elements. This is standard practice when dealing with STL classes.
If it did not copy then there would be the chance of some other part of
the code changing the memory contents from under the STL-container, and
there would be no warning for this.

The easiest way to do this efficiently is to construct the advector
using advector(size_t n) and then assigning the elements using the
operator [](size_t i) or using a dynamic_cast<vector<adouble>& >() to
access the std::vector inside the advector. This would avoid copying.
You anyway need to assign the elements at some point.

The index for accessing the elements, which may change at a different
evaluation point must however be an adouble or an expression with
adoubles and the indexing is done with operator [](const badouble& i)

Hope this helps

As on 2013-03-22 22:24, Antoine De Blois did write:
> Hi everyone,
> I was trying to find a way to avoid retaping when the index of an array changes  for a different taping point. I found today the advector, which sounds very promising for my application.
> I want to have the advector 's as members of a class and I want to efficiently construct the advector. I don't think that the
> advector(const std::vector<adouble>& v) will be efficient due to the involved copies. Is it done this way to avoid the lvalue issue?
> Is there any C++ code example someone is willing to share? I tried to search quickly on the web but I could not find any. This article confirms that ADOL-C can do what I want:
> "Computing derivatives in a meshless simulation using permuation in ADOL-C." Kulshreshtha
> Thank you for your time,
> A
> _______________________________________________
> ADOL-C mailing list
> ADOL-C at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/adol-c

Dr. Kshitij Kulshreshtha

Institut für Mathematik,
Universität Paderborn,
Warburger Straße 100,
33098 Paderborn.

Büro: A3.235

Arnikaweg 62
33100 Paderborn.

More information about the ADOL-C mailing list