-
Notifications
You must be signed in to change notification settings - Fork 312
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
Add generic initializers for statically-dimensioned array types #1385
Add generic initializers for statically-dimensioned array types #1385
Conversation
Hm, new clippy lints should be fixed in a different PR, I think |
I originally decided on the name |
With my most recent updates, I believe all static-related simplification that can be done within the current Rust feature set is implemented. This can be revisited in the future once rust-lang/rust#76560 lands. |
I added some basic tests for the new initializers. The other changes should all be covered by the existing tests since they were just implementation refactorings. |
I was having some problems with getting |
I'm sorry about the delay here. I now understand that this PR adds IxD (quibble: too similar to the existing name IxDyn). We can't accept this change at the moment, we don't want an aliasing dimensionality - two different ways to create a (statically known) two dimensional ndarray. However, of course we need to use const generics better, and incremental changes is the way to get there, but I can't see us taking this path. Something fruitful would be removing Ix2 and replacing with a better implementation, while preserving backwards compat with existing code as much as possible. (Introduce new type alias Ix2 and function Ix2?). |
Yeah, I had concerns about the name too. This is not adding a distinct type, only an additional alias, so |
I suppose underlying the exact methodology, I am seeking a way to access arbitrary diagonal elements of an unknown statically-dimensioned ndarray. I was doing this with a combination of |
Actually, I missed that basic arrays already implement |
Seems like that does work; I think I tried that before, but was missing a trait constraint in my generalized code. |
This takes advantage of const generics to provide general initializers for the statically-dimensioned array types. (2-6 dimensions, with the current implementations). This reduces the reliance on macros for array initialization, and enables other crates to operate more succinctly when working with an unknown-dimension static array type. I'm unsure how well this fits with the existence of the dynamic array index implementation, and the name of the new type alias
IxD
is open for discussion. No additional test cases have been implemented for this functionality yet.