@@ -9,9 +9,20 @@ for f in (:sin, :cos, :tan, :asin, :acos, :acosh, :atanh, :log, :log2, :log10,
9
9
($ f)(x:: Float64 ) = ccall (($ (string (f)),libm), Float64, (Float64,), x)
10
10
($ f)(x:: Float32 ) = ccall (($ (string (f," f" )),libm), Float32, (Float32,), x)
11
11
($ f)(x:: Real ) = ($ f)(float (x))
12
+ if $ f != = :lgamma
13
+ ($ f)(x) = (Base.$ f)(x)
14
+ end
12
15
end
13
16
end
14
17
18
+ for f in (:sqrt ,)
19
+ @eval ($ f)(x) = (Base.$ f)(x)
20
+ end
21
+
22
+ for f in (:max , :min )
23
+ @eval ($ f)(x, y) = (Base.$ f)(x, y)
24
+ end
25
+
15
26
# Would be more efficient to remove the domain check in Base.sqrt(),
16
27
# but this doesn't seem easy to do.
17
28
sqrt (x:: T ) where {T<: AbstractFloat } = x < 0.0 ? T (NaN ) : Base. sqrt (x)
@@ -22,11 +33,13 @@ pow(x::Float64, y::Float64) = ccall((:pow,libm), Float64, (Float64,Float64), x,
22
33
pow (x:: Float32 , y:: Float32 ) = ccall ((:powf ,libm), Float32, (Float32,Float32), x, y)
23
34
# We `promote` first before converting to floating pointing numbers to ensure that
24
35
# e.g. `pow(::Float32, ::Int)` ends up calling `pow(::Float32, ::Float32)`
25
- pow (x:: Number , y:: Number ) = pow (promote (x, y)... )
26
- pow (x:: T , y:: T ) where {T<: Number } = pow (float (x), float (y))
36
+ pow (x:: Real , y:: Real ) = pow (promote (x, y)... )
37
+ pow (x:: T , y:: T ) where {T<: Real } = pow (float (x), float (y))
38
+ pow (x, y) = ^ (x, y)
27
39
28
40
# The following combinations are safe, so we can fall back to ^
29
41
pow (x:: Number , y:: Integer ) = x^ y
42
+ pow (x:: Real , y:: Integer ) = x^ y
30
43
pow (x:: Complex , y:: Complex ) = x^ y
31
44
32
45
"""
0 commit comments