coin-or / ADOL-C

A Package for Automatic Differentiation of Algorithms Written in C/C++
Other
146 stars 31 forks source link

Improve const correctness of drivers #50

Closed cgraeser closed 1 year ago

cgraeser commented 1 year ago

This changes several input arguments for driver functions to const. The patch only touches the functions that are documented in the freely available documentation https://www3.math.tu-berlin.de/Vorlesungen/SS06/AlgoDiff/adolc-110.pdf.

The changed parameters are documented to be input paramters. Hence declaring them const should be fine. In fact this required that some internal function arguments also had to be made const.

This patch leaves out the functions that are ot documented in the linked manual. It also keeps the lagrange argument of vec_jac() non-const. Changing the latter would require to modify the 4th argument of the internal fos_reverse() method. However, this argument is used for write access and hence the lagrange parameter seems to be modified in fact.

Disclaimer: While I tested all changes with make test (which does not lead to any compiler warnings about const-ness issues), I have no idea about the Adol-C internals. Hence all changes-especially to the internal methods fos_forward(), fos_forward_nk(), and hos_reverse()-should be carefully reviewed by someone how understands the internals.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

cgraeser commented 1 year ago

Update: I noticed that the updated manual is contained in the repository. But the set of documented drivers is still the same. Notice that the documentation of fos_reverse() in short_ref.pdf indicates that this is also an input variable only in contrast to the compiler warning that this is used for write access.

awalther1 commented 1 year ago

Thanks for this commit, everything should be fine.