Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions src/Initialization/init_IntervalArithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,55 @@ function vertices_list(H::IA.IntervalBox)
return vertices_list(convert(Hyperrectangle, H))
end

const zero_itv(N) = IA.interval(zero(N))
const sym_itv(N) = IA.interval(-one(N), one(N))
const zero_itv_store = Dict{Type,IA.Interval}()
function zero_itv(N)
res = get(zero_itv_store, N, nothing)
if isnothing(res)
res = IA.interval(zero(N))
zero_itv_store[N] = res
end
return res
end

const zero_box_store = Dict{Type,Dict{Integer,IA.IntervalBox}}()
function zero_box(n::Int, N=Float64)
d = get(zero_box_store, N, nothing)
if isnothing(d)
d = Dict{Integer,IA.IntervalBox}()
zero_box_store[N] = d
end
res = get(d, n, nothing)
if isnothing(res)
res = IA.IntervalBox(zero_itv(N), n)
d[n] = res
end
return res
end

zero_box(n::Int, N=Float64) = IA.IntervalBox(zero_itv(N), n)
sym_box(n::Int, N=Float64) = IA.IntervalBox(sym_itv(N), n)
const sym_itv_store = Dict{Type,IA.Interval}()
function sym_itv(N)
res = get(sym_itv_store, N, nothing)
if isnothing(res)
res = IA.interval(-one(N), one(N))
sym_itv_store[N] = res
end
return res
end

const sym_box_store = Dict{Type,Dict{Integer,IA.IntervalBox}}()
function sym_box(n::Int, N=Float64)
d = get(sym_box_store, N, nothing)
if isnothing(d)
d = Dict{Integer,IA.IntervalBox}()
sym_box_store[N] = d
end
res = get(d, n, nothing)
if isnothing(res)
res = IA.IntervalBox(sym_itv(N), n)
d[n] = res
end
return res
end

"""
fast_interval_pow(a::IntervalArithmetic.Interval, n::Int)
Expand Down