-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
RelativeDifferencePrior gives wrong results due to use of abs() #1409
Comments
@Imraj-Singh, you faithfully reproduce this bug in #1408 |
Looks like this was introduced in the PR for the RDP #335. @robbietuk, making you aware. It is possible that this bug only transpired once we moved to C++-11, or certain compiler versions. I don't know. |
Other places that use Library: (worrying!)
Utilities:
Relatively harmless as error checking:
Test code: Commented out code, hence harmless (but confusing): |
We use the
abs()
function, e.g.STIR/src/recon_buildblock/RelativeDifferencePrior.cxx
Line 416 in 8ced2d7
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:
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...The text was updated successfully, but these errors were encountered: