-
Notifications
You must be signed in to change notification settings - Fork 71
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
Improve mince and add method for non-uniform partition of IntervalBox #467
Conversation
Codecov Report
@@ Coverage Diff @@
## master #467 +/- ##
==========================================
- Coverage 91.53% 91.22% -0.31%
==========================================
Files 25 25
Lines 1748 1812 +64
==========================================
+ Hits 1600 1653 +53
- Misses 148 159 +11
Continue to review full report at Codecov.
|
Some benchmarking:
|
src/multidim/intervalbox.jl
Outdated
end | ||
|
||
nodes = IntervalBox{$N,T}[] | ||
Base.Cartesian.@nloops $N i _->(1:n) begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this part requires carefull review? I am not familiar with the macros used, but I could delve into it if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review @Kolaru and also for offering getting into the details of this part of the code.
Here, I simply used the original method, and adapt it to obtain the desired behavior; maybe there are better ways, but for the time being, this is good enough. The original code was inspired from this section of the manual, which admittedly I have mostly forgotten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounded like a fun multidimensional challenge so I spent some time on it and I believe the following is equivalent:
function mince(x::IntervalBox{N,T}, ncuts::NTuple{N,Int}) where {N,T}
minced_intervals = [mince(x[i], ncuts[i]) for i in 1:N]
minced_boxes = Vector{IntervalBox{N,T}}(undef, prod(ncuts))
for (k, cut_indices) in enumerate(CartesianIndices(ncuts))
minced_boxes[k] = IntervalBox([minced_intervals[i][cut_indices[i]] for i in 1:N])
end
return minced_boxes
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Kolaru for the suggestion! I am also changing the other method (avoiding then the @generated
). I would like to include you as coauthor of this commit; is it ok with you? (I already have the commit ready, but prefer to wait for your reply before pushing it.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure let me know if it needs any input from my side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed it, so you can have a look
Co-authored-by: Benoît Richard <kolaru@hotmail.com>
All look good, thanks. |
Thanks a lot! |
Closes #444