Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
this PR includes a bugfix in
uni5_for.c
traceOperatorVector.cpp
uni5_for.c
:There was a bug when calculating the derivative of
fmax
orfmin
at the tie-point with the tape-based forward mode. In principle, there was a missingelse
that encapsulates the pointer increment:Targ1++
andTarg2++
. Due to the missingelse
, the pointers got sometimes incremented twice, when the loop macroFOR_0_LE_i_LT_k
was not defined.traceOperatorVector.cpp
I also corrected the tests for the tie-points of
fmax
andfmin
, based on following assumption for the "correct" behavior:If we have two adouble variables
a
andb
that are equal, the derivativeyd
offmax
calculated byfov_forward
is given by the column-wise maximum of the provided tangent matrixxd
. Meaning, ifxd[0][0] = 1.3, xd[1][0] = -1.3, xd[0][1] = -1.3, xd[1][1] = 4.0
we would getyd = [1.3, 4.0] (= [std::fmax(xd[0][0], xd[1][0]), std::fmax(xd[0][1], xd[1][1])])
. If on the other hand,b
is a constant (double
)yd
is given by the maximum between the correspondingxd
entries and0.0
(i.e. [std::fmax(xd[0][0], 0.0), std::fmx(xd[0][1], 0.0)]).