[ADOL-C] piecewise defined functions

Philipp Bender pbender at fzi.de
Tue Sep 23 09:37:26 EDT 2014


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

Dear list,

as always when learning a new tool ... as soon as one issue seems
solved, the next one shows up, so this is my second question today ...

I have a function which can be considered as piecewise. It's a
polygonal line strip, and the function returns the shortest distance
to one of the strips, but with some interpolation tricks to circumvent
discontinuities and so on. So contrary to "usual" piecewise
definitions, I cannot simply look at the parameters to see which
definition I have to use at this particular point.

Basically, I do this (Pseudocode):

fun(x, y):
  dist = big number
  iterate over all segments of the line strip:
    dist'  = segment.distance(x, y)
    dist = min(dist, dist')

  return dist

and somewhere else:

trace_on(0)
fun(...)
trace_off()

Now, I think I cannot simply declare this to be a template and stop
thinking. I assume that now *every* segment's operation stack gets
recorded in the tape, and I end up with something wrong.

My idea was to first have a dry run with doubles (not adoubles), just
to obtain the correct index. Then, with adoubles x and y, call
segment[index].distance(x, y). So with N segments, I need N+1 calls
(instead of N). Not that this would be a problem, I mention it only to
explain what I mean.

Is there an error in my thinking, do I miss something here?

Best regards,
Philipp

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJUIXeWAAoJEMSOzTAqQDLou9oQAIV7vj4SEGMdN0N1GK3+VnK3
eSKCeYJdLFLOq0XvZtyiL8BG/lwJQj+scsj9DLYDsEkLCNPcGvpYYECy6uZA0qzU
qEcDJWzaNX9k7Tur7FLvqn918gPiY81gtQm7Krwci6TB5l5o7RxiwKBVBPMBZH9x
sMXCydKXRxbsaj3LGGFp6QHDy58PzIsOaoKgDH1wWFg5qHb2ilRv0vRAIWcUyE3W
2QqINgm8pP4WGHBx7/7DSvkdCKCzci+tzzV6RBF2FJ2gOHZRPs9Ai8nuGwtoO7gz
Di+6a8N73mBpCajNAwigNeFXXR//70K9mtA5kG/b8Naxu7nhrR95MieLAOnnJb8/
+a4XY2NN7gRuIVYHh3RoEejUdKfsSDGeMyCtZ+JTOtrqK8QOyJPbfHP/E9nyFCkc
p7TTfETv+Lg4IP1gNfHYPq9o3rPj+F+wNUDh+x8qUmZlX1WJlFUEvedWfxUWIVbX
ilUuPQNCOq/mkCd8igLjI7tYMDJrUxDckjYZK4GDpT09Dl68o/WyLNGS4Zand6Ij
F/tfoqZIPVvES8RaE7TLAleaUlNpm4pcTVxSwtJm1yblLQq71+hiuIS6jgSXXSEj
QiCUwbPUXgqaL9sDZ1cHnkFJyK3K33gh9AKj0t3ETsL6YY2yj0PWT6g7cpN0WPNo
6VH3WvkKFV73Zw1FkYdh
=LOJQ
-----END PGP SIGNATURE-----


More information about the ADOL-C mailing list