Skip to content

Compatibility with QuadGK #597

@aurelio-amerio

Description

@aurelio-amerio

Hello, the update of QuadGK (a popular library for numerical integration) from v2.5 to v2.6 broke compatibility with Unitful.

To restore compatibility, one would have to extend the QuadGK function cachedrule to also work with quantities with something like

@generated function cachedrule(::Type{T}, n::Integer) where {T<:AbstractQuantity}
    TF = typeof(float(real(one(T))))
    cache = haskey(rulecache, TF) ? rulecache[TF] : (rulecache[TF] = Dict{Int,NTuple{3,Vector{TF}}}())
    :(haskey($cache, n) ? $cache[n] : ($cache[n] = kronrod($T, n)))
end

Unitful and QuadGK don't have each other as dependencies, so it would not be possible to extend either without adding more dependencies.

Do you think it would be beneficial to create a new julia package (like UnitfulQuad or something similar) to make Unitful talk nicely with QuadGK, or do you have any suggestions on how to proceed? I think out of the box numerical integration with units is a strong selling point for Julia!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions