Skip to content

Override * and ^ in a way that different packages can interpret the result differently #27

Open
@dlfivefifty

Description

@dlfivefifty

In ApproxFun.jl, I'd like to do function approximation on a square via:

Fun((x,y) -> exp(x*y), (0..1)^2)

Of course, (0..1)^2 has a completely different interpretation in the setting of ValidatedNumerics.jl. Overriding ^ in either package would be type piracy.

My proposal is to add a placeholder type to this package that can be interpreted by other packages however they please:

# in IntervalSets.jl
struct IntervalProduct{NT<:Tuple}
   intervals::NT
end

*(a::AbstractInterval, b::AbstractInterval, c::AbstractInterval...) = IntervalProduct(a,b,c...)

Then ApproxFun can override Fun(::Function, d::IntervalProduct) to interpret d as a rectangle, while ValidedNumerics.jl can override ValidatedNumerics.Interval(::IntervalProduct) to interpret it as an interval arithmetic operation.

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