@@ -2,7 +2,7 @@ __precompile__(true)
22
33module ColorVectorSpace
44
5- using Colors, FixedPointNumbers, Compat
5+ using Colors, FixedPointNumbers, SpecialFunctions, Compat
66import StatsBase: histrange
77
88import Base: == , + , - , * , / , ^ , < , ~
@@ -22,13 +22,10 @@ import Base: conj, sin, cos, tan, sinh, cosh, tanh,
2222 sind, tand, acosd, acotd, acscd, asecd,
2323 asind, atand, rad2deg, deg2rad,
2424 log, log2, log10, log1p, exponent, exp,
25- exp2, expm1, cbrt, sqrt, erf,
26- erfc, erfcx, erfi, dawson,
25+ exp2, expm1, cbrt, sqrt,
2726 significand, lgamma,
28- gamma, lfact, frexp, modf, airy, airyai,
29- airyprime, airyaiprime, airybi, airybiprime,
30- besselj0, besselj1, bessely0, bessely1,
31- eta, zeta, digamma, float, middle
27+ gamma, lfact, frexp, modf,
28+ float, middle
3229
3330export dotc
3431
@@ -53,7 +50,11 @@ _nan(::Type{T}, ::Type{C}) where {T<:AbstractFloat,C<:TransparentRGB} = (x = con
5350# # Generic algorithms
5451mapreduce (f, op:: Union{typeof(&), typeof(|)} , a:: MathTypes ) = f (a) # ambiguity
5552mapreduce (f, op, a:: MathTypes ) = f (a)
56- Base. r_promote (:: typeof (+ ), c:: MathTypes ) = mapc (x-> Base. r_promote (+ , x), c)
53+ if isdefined (Base, :r_promote )
54+ Base. r_promote (:: typeof (+ ), c:: MathTypes ) = mapc (x-> Base. r_promote (+ , x), c)
55+ else
56+ Base. promote_sys_size_add (c:: MathTypes ) = mapc (Base. promote_sys_size_add, c)
57+ end
5758
5859for f in (:trunc , :floor , :round , :ceil , :eps , :bswap )
5960 @eval $ f (g:: Gray{T} ) where {T} = Gray {T} ($ f (gray (g)))
@@ -198,13 +199,15 @@ const unaryOps = (:~, :conj, :abs,
198199 :sind , :tand , :acosd , :acotd , :acscd , :asecd ,
199200 :asind , :atand , :rad2deg , :deg2rad ,
200201 :log , :log2 , :log10 , :log1p , :exponent , :exp ,
201- :exp2 , :expm1 , :cbrt , :sqrt , :erf ,
202- :erfc , :erfcx , :erfi , :dawson ,
202+ :exp2 , :expm1 , :cbrt , :sqrt ,
203203 :significand , :lgamma ,
204- :gamma , :lfact , :frexp , :modf , :airy , :airyai ,
205- :airyprime , :airyaiprime , :airybi , :airybiprime ,
206- :besselj0 , :besselj1 , :bessely0 , :bessely1 ,
207- :eta , :zeta , :digamma )
204+ :gamma , :lfact , :frexp , :modf ,
205+ :(SpecialFunctions. erf), :(SpecialFunctions. erfc),
206+ :(SpecialFunctions. erfcx), :(SpecialFunctions. erfi), :(SpecialFunctions. dawson),
207+ :(SpecialFunctions. airy), :(SpecialFunctions. airyai),
208+ :(SpecialFunctions. airyprime), :(SpecialFunctions. airyaiprime), :(SpecialFunctions. airybi), :(SpecialFunctions. airybiprime),
209+ :(SpecialFunctions. besselj0), :(SpecialFunctions. besselj1), :(SpecialFunctions. bessely0), :(SpecialFunctions. bessely1),
210+ :(SpecialFunctions. eta), :(SpecialFunctions. zeta), :(SpecialFunctions. digamma))
208211for op in unaryOps
209212 @eval ($ op)(c:: AbstractGray ) = $ op (gray (c))
210213end
@@ -288,8 +291,13 @@ dotc(x::AbstractGray, y::AbstractGray) = dotc(promote(x, y)...)
288291float (:: Type{T} ) where {T<: Gray } = typeof (float (zero (T)))
289292
290293# Mixed types
291- (+ )(a:: MathTypes , b:: MathTypes ) = (+ )(Base. promote_noncircular (a, b)... )
292- (- )(a:: MathTypes , b:: MathTypes ) = (- )(Base. promote_noncircular (a, b)... )
294+ if VERSION < v " 0.7.0-DEV.2138"
295+ (+ )(a:: MathTypes , b:: MathTypes ) = (+ )(Base. promote_noncircular (a, b)... )
296+ (- )(a:: MathTypes , b:: MathTypes ) = (- )(Base. promote_noncircular (a, b)... )
297+ else
298+ (+ )(a:: MathTypes , b:: MathTypes ) = (+ )(promote (a, b)... )
299+ (- )(a:: MathTypes , b:: MathTypes ) = (- )(promote (a, b)... )
300+ end
293301
294302Compat. @dep_vectorize_2arg Gray max
295303Compat. @dep_vectorize_2arg Gray min
0 commit comments