[ADOL-C] Signature of Hessian driver

Philipp Bender pbender at fzi.de
Tue Sep 23 05:01:15 EDT 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear Kshitij,

I did not come up with this because of code aesthetics :), more
because I integrate ADOL-C with an optimizer which asks me to evaluate
the Hessian and gradient at a specific point, which is passed as const
double*. So I help myself with this:

#ifdef DEBUG

  std::vector< double > x_non_const(x, x+n);
  hessian(0, n, x_non_const.data(), Hess);
  // memory is equal, x_non_const has not been touched ...
  assert(std::memcmp(x_non_const.data(), x, n) == 0);

#else

  double* x_non_const = const_cast<double*>(x);
  hessian(0, n, x_non_const, Hess);

#endif

... which works, but is not really the best construct ever. It should
provide me with the confidence that the values never get touched,
while being still efficient in release mode.

Best regards and thank you,
Philipp
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJUITbbAAoJEMSOzTAqQDLozVgQAIzRdRwWzwqiWHB8GtVaW35x
EdKcFQXxao21VahSV4ClrPmsWqgLw2o2iuI4SmQQqpdnwGsx7SJNOLENOhcmB3yR
mwO629Adx302oOm9EDpsTS2pIlDGlwKNkAa73fHh1JeheMobXxXuZOYkme8+oAFm
BY0HD1+mzZJFzF3miUw6cRLUSwfhPgVQGdmZPBF9une3IZTXV94qgK4TL+EY+S5w
eydbSgwkJvTEPeVv+7QrlUB/k7dP2ICQ2GN7APbAmCjyMli54EZFF3zGtpcnl/1c
8eNtcM/9uY9+NIvcDPrc7GFac2n3PDlFdFSZinMNDt/pckJkE6D2+bIGN9CsaxOJ
p50XvtlvqK96DTprFJFXRfIAoQ0fIwBWasfyhC/bokwN0V9LwREV5fSsOwWEmmlh
yh6mA//0mCFrxVHHCKTa3KkzaEdHxkAzQ3ojhRhzahMDs/XlyfxfiQYswffHj0yP
DXcF8u4nExNe6dlRecQSVGkvZvXpQLVLAnKdhru1MGEKtztrTsYPBNBTVUROSiKS
0Ty2DFhxC0Uin6KSQ/bK3TIfWFTo73Hvw+OH2wilaua2jgoNcvYhbuB5QKm9nh3P
TKFRhU4RgtUJBV01i9RsjAs5MWvdH69FUWcTibqMrA6gY0PB3rP2jH7t/K/ltnr/
Tbaxe5tVtVr8uIyfprXw
=4USu
-----END PGP SIGNATURE-----


More information about the ADOL-C mailing list