JuliaMath / QuadGK.jl

adaptive 1d numerical Gauss–Kronrod integration in Julia
MIT License
272 stars 37 forks source link

Parametrize I and E types #19

Closed matbesancon closed 5 years ago

matbesancon commented 6 years ago

Right now the I and E types (returned from QuadGK) seem undefined in Segment:

# integration segment (a,b), estimated integral I, and estimated error E
struct Segment
    a::Number
    b::Number
    I
    E
end
isless(i::Segment, j::Segment) = isless(i.E, j.E)

It could be replaced by something like:

struct Segment{T<:Real}
    a::Number
    b::Number
    I::T
    E::T
end
isless(i::Segment, j::Segment) = isless(i.E, j.E)
stevengj commented 6 years ago

The problem is that these depend on the return type of the integrand. Some complicated logic is required to handle the case where the integrand is type-unstable if you want to concretely type these fields.