Skip to content

Commit eb1d032

Browse files
committed
Add mince for non-uniform partition of IntervalBox
1 parent 5383884 commit eb1d032

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/multidim/intervalbox.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,26 @@ as a vector.
138138
end
139139
end
140140

141+
@generated function mince(x::IntervalBox{N,T}, tup::NTuple{N,Int}) where {N,T}
142+
quote
143+
n = maximum(tup)
144+
nodes_matrix = Array{Interval{T},2}(undef, n, N)
145+
fill!(nodes_matrix, emptyinterval(T))
146+
for i in 1:N
147+
nodes_matrix[1:tup[i],i] .= mince(x[i], tup[i])
148+
end
149+
150+
nodes = IntervalBox{$N,T}[]
151+
Base.Cartesian.@nloops $N i _->(1:n) begin
152+
Base.Cartesian.@nextract $N ival d->nodes_matrix[i_d, d]
153+
ibox = Base.Cartesian.@ncall $N IntervalBox ival
154+
isempty(ibox) || push!(nodes, ibox)
155+
end
156+
nodes
157+
end
158+
end
159+
160+
141161
hull(a::IntervalBox{N,T}, b::IntervalBox{N,T}) where {N,T} = IntervalBox(hull.(a[:], b[:]))
142162
hull(a::Vector{IntervalBox{N,T}}) where {N,T} = hull(a...)
143163

0 commit comments

Comments
 (0)