-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gamma_isf nan #665
Comments
I pulled the relevant C code out of owl, compiled it independently, and ran the following: #include<math.h>
#include "owl_maths.h"
#include "igami.c"
#include <stdio.h>
int main() {
double t = -1;
double x = 0.9;
double y = 0.292000000000000037;
t = igami(x,y);
printf("%.10f\n",t);
return(0);
} This returns the correct value of 1.1000096747. I'm at a loss, this is really bizarre. |
I edited the igami function in-place so it would run in the same context (being called from OCaml) and
|
I have identified the source of the bug. As documented in the INSTALL.md, by default configure.ml sets the default C compiler flags to
Removing When the Because the code relies on numerous calls to owl_isnan, and references owl_posinf and other related values, it seems imprudent to use the I propose a git pr of changing the default I believe that beyond the immediate bug, this change would be more in keeping with the spirit of the OCaml community, which values the correctness guarantees offered by static typing and would also probably appreciate compliance with IEEE 754 standards about floating point numbers. |
I am trying to see what needs to be done to port Owl to OCaml 5.2 and I found a problem in the gamma_isf function, which depends upon the igami function from the cephes mathematics library.
https://github.com/owlbarn/owl/blob/main/src/owl/maths/cephes/igami.c
I am in OCaml 5.2. I am using gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0 on Ubuntu 24.04.
I reproduced the error on OCaml 4.14.2.
It works with the main branch of owl as well as the version of owl on opam.
To reproduce the error, open utop,
#require "owl"
(disabling Float16 warnings if necessary), andThen run
(where this number is 1.0 - 0.708)
This returns nan and it really shouldn't, the correct value is not extreme. It's somewhere in the vicinity of
1.10000967467090516
I am using Ubuntu 24.04, which is very recent so may have bugs.
I was unable to reproduce the error on Ubuntu 22.04 and gcc 11. It may be a problem with my configuration.
I was able to reproduce the error on a second Ubuntu 24.04 + gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0 machine.
The text was updated successfully, but these errors were encountered: