Closed mcmillan03 closed 3 years ago
I am nervous about specifying behavior that is happening deep within the compiler. I would like to say that max(x,NaN) returns the value that the compiler used to build the GraphBLAS library would return. Comparing against a NaN is problematic and had better be rare. I don't want to define a behavior that slows down execution for cases without a NaN just to make sure we cover all exceptional cases.
The ANSI C11 specification states that fmax, fmin, fmaxf, and fminf have the "omit NaN" behavior, which is the fastest option anway. However, if a library uses comparisons to compute MIN or MAX monoids, instead of fmin, fmax, etc, it might not get this behavior.
I use the ANSI C11 spec, with "omit NaN".
We can close this issue and leave it up to the implementation.
How do the operators behave with Nan and Inf? what is 'max(x,NaN)'?
See 'fmax' in ANSI C11, which is the "omit nan" behavior, so that 'max(x,NaN)=x' for all 'x'. That is faster since it allows MAX to terminate earlier.
See also 'max' in MATLAB. MATLAB also has a way of specifying that 'max(x,NaN)=NaN'.