Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid generated function in generic_exp #41

Open
andreasnoack opened this issue Aug 15, 2020 · 0 comments
Open

Avoid generated function in generic_exp #41

andreasnoack opened this issue Aug 15, 2020 · 0 comments

Comments

@andreasnoack
Copy link
Contributor

The current implementation relies on methods being defined for special number types before

@generated function exp_pade_p(x, ::Val{k}, ::Val{m}) where {k, m}
factorial = Base.factorial big
p = map(Tuple(0:k)) do j
num = factorial(k + m - j) * factorial(k)
den = factorial(k + m) * factorial(k - j)*factorial(j)
(float eltype)(x)(num // den) * (x <: Number ? 1 : I)
end
:(@evalpoly(x, $(p...)))
end
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant