-
Notifications
You must be signed in to change notification settings - Fork 28
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
Performance compared to other implementations & supported types #63
Comments
Seems like this is the same for other functions which make ccalls to libm: Lines 6 to 13 in 65a5928
e.g., a trivial implementation of function sin_nan(x::T)::T where {T}
isfinite(x) || return T(NaN)
return sin(x)
end
@btime NaNMath.sin(1.0)
# > 9.758 ns (0 allocations: 0 bytes)
@btime sin_nan(1.0)
# > 1.492 ns (0 allocations: 0 bytes) However, some functions are the same performance, like Line 17 in 65a5928
(side note - why doesn't that |
this method
is indeed faster
but there will be an error:
|
@hurricane007 not sure I see your issue. Just define log_nan(x::Integer) = log_nan(Float64(x)) log won't return integers anyways |
@MilesCranmer Hi Miles, it is about the method from @johanbluecreek |
Hi,
I noticed that if I implement my own
log
function where I take care of the branch-cut by hand, it performs better than theNaNMath.log
:this shows that
NaNMath.log
performs some ~36% slower thanlog_nan
. (This issue was discovered in the discussion here [1])An implementation like
log_nan
above also provides support forFloat16
andBigFloat
, which both givesStackOverflowError
error forNaNMath.log
:I have only tested
log
, other functions inNaNMath
may have similar issues.[1] MilesCranmer/SymbolicRegression.jl#109
The text was updated successfully, but these errors were encountered: