-
Notifications
You must be signed in to change notification settings - Fork 98
Closed
Description
We use the abs() function, e.g.
| * abs(current_image_estimate[z][y][x] - current_image_estimate[z + dz][y + dy][x + dx]) |
It turns out that with g++-8 (and presumably any version), this falls back to the C version of
abs, which will convert its argument to an integer type.
To fix this, we have to explicitly use std::abs (which has an overload for float and double in <cmath>).
Impact` of this is rather dramatic. When running test_priors.cxx, I get the following for the gradient of the RDP potential:
RDP old 0.590537 RDP new 0.287209
RDP old 0.893955 RDP new 0.326926
RDP old 0.319332 RDP new 0.20883
RDP old 0.00598219 RDP new 0.00592888
RDP old 0.373463 RDP new 0.229309
RDP old 0.980504 RDP new 0.332455
RDP old -0.00389029 RDP new -0.00386772
RDP old 0.348276 RDP new 0.220149
RDP old 0 RDP new 0
RDP old 0.153586 RDP new 0.123653
RDP old 0.893202 RDP new 0.326867
RDP old 0.493659 RDP new 0.265453
RDP old 0.773317 RDP new 0.315314
RDP old 0.18338 RDP new 0.141967
RDP old -0.159962 RDP new -0.129018
RDP old 0.731704 RDP new 0.31015
RDP old 0.973774 RDP new 0.332113
This is despite the tests all working, including a test on numerical vs analytic gradient which is surprising. Possibly this is because we use abs() consistently...