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

MethodError: no method matching kronrod(::Type{ForwardDiff.Dual{ForwardDiff.Tag{typeof(test), Float64}, Float64, 1}}, ::Int64)

Open ZhangFengshun opened this issue 1 year ago • 2 comments

image

ZhangFengshun avatar Oct 11 '24 15:10 ZhangFengshun

See https://github.com/JuliaMath/QuadGK.jl/issues/13#issuecomment-1430408697

A workaround is probably to define:

QuadGK.cachedrule(::Type{<:ForwardDiff{<:Any, T}}, n::Integer) where {T<:Number} =
    QuadGK._cachedrule(typeof(float(real(one(T)))), Int(n))

stevengj avatar Oct 11 '24 19:10 stevengj

I recently had the same issue with a package of mine. I solved it by including the lines

import QuadGK: kronrod
QuadGK.kronrod(::Type{<:ForwardDiff.Dual{T,V,N}}, n::Integer) where {T,V,N} = QuadGK.kronrod(V, n)

Now, this is still a work around, from the little I read today, it seems to me an issue that should be solved within ForwardDiff.jl.

I'm not familiar with the inner code of QuadGK, tbh, so this might be totaly equivalent to @stevengj solution. I went this way because the error was complaining of krondor().

AntoninoDAnna avatar May 19 '25 13:05 AntoninoDAnna