How to call some special functions in julia v0.6?

Hello. Apparently, some of the special functions are moved to SpecialFunctions.jl in julia v0.6, e.g., besselj0. When I call this function, it generates the following warning:

julia> using SpecialFunctions
julia> x=0.01:0.001:5; y=besselj0(x);
WARNING: besselj0{T <: Number}(x::AbstractArray{T}) is deprecated, use ($(Expr(:globalref, Compat, Symbol("@compat"))))(besselj0.(x)) instead.

Well, at this point, I still got the correct output array, but I also try to run what the warning message suggested. Then, I got the error:

julia> ($(Expr(:globalref, Compat, Symbol("@compat"))))(besselj0.(x))
ERROR: unsupported or misplaced expression $

What should I call for those special functions like besselj? Interestingly enough, some of the other special functions such as gamma was not moved to SpecialFunctions.jl, and worked without any warning and error messages:

julia> z=gamma(x);

Thanks for your help!

You should use broadcast notation: besselj0.(x) and gamma.(x).

I just did some further experiments and got the following:

julia> x=0.01:0.001:5; y=besselj0.(x);
julia> z=gamma.(x);
julia> z=gamma(x);

All of them worked correctly now without any errors. Then, why gamma accepts .(x) and (x) as its argument and why besselj0 does accept .(x) and tries to deprecate (x) argument?

1 Like

Thanks a lot, dlfivefifty! I just found out that and posted it before reading your message. However, a question remains. Why some of the special functions not moved to SpecialFunctions.jl, such as gamma does not issue the deprecated warning? It still accepts both gamma(x) and gamma.(x), but the former doesn’t generate any warning unlike besselj0.

The deprecation is for functions that typically evaluate scalars when called with vectors. This required that functions was specifically defined for f(x::AbstractArray). This is now solved with the dot call notation, you can read about it here:

Thanks for suggesting the element wise operation!