-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Additional tools for type-stable multidimensional coding #15030
Conversation
If we're going to have |
|
Note that we also have |
|
Good point about Yes, a second argument to tail to get the nth tail is a standard extension. Interestingly, that is distinct from The standard extension to |
If you give |
Sorry, I should have stated that
which would make an array of size
I seem to remember that Jeff once posted a gist containing examples of implementing arithmetic at compile-time, and this PR is kind of aiming in that general direction. |
|
Didn't know that. I'm fine with whatever name seems sensible. |
|
I was going to suggest I like For reference: there are relatively few calls to |
One place where such manipulations are currently ugly: this impenetrable function (called from, e.g., here) could be written more clearly as
where These are the kinds of manipulations I frequently need to make when writing code for arbitrary dimensions and inputs whose dimensionality may not match. |
1ed27d6
to
345aa5b
Compare
I've stripped out any ambiguous/problematic stuff (the |
345aa5b
to
5095d82
Compare
Additional tools for type-stable multidimensional coding
This has a couple of goals:
CartesianIterator
/CartesianRange
For the 2nd goal (which is the "WIP" part of this), a key step is providing more comprehensive tools for working with tuples. For this reason, I decided to export
tail
(which we've had in Base for ages), add a correspondinghead
(which I define locally and have found useful on quite a few occasions), and rewritentuple
so it doesn't use generated functions. Everything else looks reasonable at the level of@code_native
, e.g.,but my attempted rewrite of
ntuple
was Not Good:Compare
master
(which uses a generated function, though for N=3 we don't call it):I presume that #13359 strikes again?
If it's the best choice for now, I can drop the rewrite of
ntuple
, but I thought I'd throw it out there in case anyone has ideas.