@@ -6,8 +6,8 @@ const libm = OpenLibm_jll.libopenlibm
6
6
for f in (:sin , :cos , :tan , :asin , :acos , :acosh , :atanh , :log , :log2 , :log10 ,
7
7
:lgamma , :log1p )
8
8
@eval begin
9
- ($ f)(x:: Float64 ) = ccall (($ (string (f)),libm), Float64, (Float64,), x)
10
- ($ f)(x:: Float32 ) = ccall (($ (string (f," f" )),libm), Float32, (Float32,), x)
9
+ Base . @assume_effects :total ($ f)(x:: Float64 ) = ccall (($ (string (f)),libm), Float64, (Float64,), x)
10
+ Base . @assume_effects :total ($ f)(x:: Float32 ) = ccall (($ (string (f," f" )),libm), Float32, (Float32,), x)
11
11
($ f)(x:: Real ) = ($ f)(float (x))
12
12
if $ f != = :lgamma
13
13
($ f)(x) = (Base.$ f)(x)
25
25
26
26
# Would be more efficient to remove the domain check in Base.sqrt(),
27
27
# but this doesn't seem easy to do.
28
+ Base. @assume_effects :nothrow sqrt (x:: T ) where {T<: Union{Float16, Float32, Float64} } = x < 0.0 ? T (NaN ) : Base. sqrt (x)
28
29
sqrt (x:: T ) where {T<: AbstractFloat } = x < 0.0 ? T (NaN ) : Base. sqrt (x)
29
30
sqrt (x:: Real ) = sqrt (float (x))
30
31
31
32
# Don't override built-in ^ operator
32
- pow (x:: Float64 , y:: Float64 ) = ccall ((:pow ,libm), Float64, (Float64,Float64), x, y)
33
- pow (x:: Float32 , y:: Float32 ) = ccall ((:powf ,libm), Float32, (Float32,Float32), x, y)
33
+ Base . @assume_effects :total pow (x:: Float64 , y:: Float64 ) = ccall ((:pow ,libm), Float64, (Float64,Float64), x, y)
34
+ Base . @assume_effects :total pow (x:: Float32 , y:: Float32 ) = ccall ((:powf ,libm), Float32, (Float32,Float32), x, y)
34
35
# We `promote` first before converting to floating pointing numbers to ensure that
35
36
# e.g. `pow(::Float32, ::Int)` ends up calling `pow(::Float32, ::Float32)`
36
37
pow (x:: Real , y:: Real ) = pow (promote (x, y)... )
0 commit comments