-
Notifications
You must be signed in to change notification settings - Fork 72
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
What is required to use custom types in Interval
s?
#476
Comments
Update: IntervalArithmetic.jl/src/intervals/conversion.jl Lines 25 to 69 in 5f3114d
|
In principle what is needed is all arithmetic operations with rounding mode i. e. In other words, you need a lot. What kind of numeric type are you interested in? If your type is build on existing one, e.g. struct MyType
x::Float64
end it is tempting to try struct MyType{T}
x::T
end and use |
Unfortunately, I do need to go the Right now, the |
A simpler reproduction of what I'm trying to do is here: https://discourse.julialang.org/t/x-y-works-but-x-y-doesnt/62703 |
Here's an even simpler repro: using IntervalArithmetic
struct Foo <: Real
v
end
convert(Interval{Foo}, Interval(Foo(0.0), Foo(1.0)))
I'm just not sure why it isn't hitting the correct |
This is a separate issue (#317 and #320) that just appears here out of poor luck. Still it is a symptom of the fact that the package is currently quite brittle when it comes to type management (it was never designed to support generic types). In other words implementing what you are proposing here might be an uphill battle. |
Thanks! I ended up finding success writing a manual implementation Base.convert(::Type{Interval{T}}, x::Interval{T}) where {T <: TracedThing} = x where |
I don't know if this is still useful or not, but changing this line to convert(::Type{Interval{T}}, x::Interval{T}) where {T<:Real} = x that is, explicitly stating that |
This fix was already proposed in #320... |
I have a custom numeric type, and I'd like to use it in conjunction (composition?) with IntervalAnalysis.jl. What function implementations are necessary in order to make this happen? Is there an API of sorts for what types can be used as the lower/upper bounds?
I'm currently facing the current error:
But I'm not able to find the
atomic
function in the public API: https://juliaintervals.github.io/pages/apiDocs/apiIntervalArithmetic/index.html.The text was updated successfully, but these errors were encountered: