-
Notifications
You must be signed in to change notification settings - Fork 152
Constructing StaticArrays with generators or ntuple-like syntax #97
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
Comments
You won't be able to make it much better than this, since the innermost constructor of SVector will accept a tuple. |
The tuple "temporary" will just be eliminated in the compiler optimizations though? |
exactly! |
Agreed. At least when I checked simple cases for this kind of stuff some time ago, That constructor seems fine, We could maybe provide a What I really want is The final problem with |
I believe the compiler has matured enough in julia-1.2 that we can finally get the generator version mentioned by @andyferris to work (see #633 (comment) and related discussion on that issue) |
Alternatively, why not use statically sized range types (e.g., It might be useful to try similar approach for slicing. Ref: perrutquist/StaticNumbers.jl#4 |
For information: I've now implemented generators with static ranges in StaticNumbers, so the following works: using StaticArrays, StaticNumbers
N = static(3)
SVector(i^2 for i in static(1):N) The last statement works even if (Edit: This was broken when |
Just as a record, something like Note that #792 is not a full solution since the length information comes from the output container type. |
* Expose grow_to_structarray! as a public API * Rename: collect_to_structarray! -> _collect_to_structarray! * Add collect_to_structarray!(dest, itr) * Rename: collect_to_structarray! -> append!! * Mention append!! in README
The following presumably creates a temporary:
It would be great to be able to do
without creating the tuple temporary.
The text was updated successfully, but these errors were encountered: