ExponentialUtilities.jl icon indicating copy to clipboard operation
ExponentialUtilities.jl copied to clipboard

Avoid generated function in generic_exp

Open andreasnoack opened this issue 5 years ago • 0 comments

The current implementation relies on methods being defined for special number types before https://github.com/SciML/ExponentialUtilities.jl/blob/fce7ae64e8507baf7ce98d268e46478c7a1540ab/src/exp.jl#L127-L135 is being called, see item 4 in https://docs.julialang.org/en/v1/manual/metaprogramming/#Generated-functions-1. If not then you'll hit a world age error. E.g.

julia> using ExponentialUtilities

julia> f = t -> exp_generic(t)
#1 (generic function with 1 method)

julia> f(0.3)
1.3498588075760032

julia> using ForwardDiff

julia> ForwardDiff.derivative(f, 0.2)
ERROR: MethodError: no method matching ForwardDiff.Dual{ForwardDiff.Tag{var"#1#2",Float64},Float64,1}(::Int64)
The applicable method may be too new: running in world age 27795, while current world is 27806.

andreasnoack avatar Aug 15 '20 10:08 andreasnoack