Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Update the code for n-d #4
Update the code for n-d #4
Changes from 6 commits
aac5264
bd1a08d
bf93fb3
4ac6fda
0513987
c2633b9
84dbc07
7088c68
2c0dae3
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Here, I believe you'd like to use something like
D::NDIM
.Unfortunately,
D::NDIM: Option<usize>
, so you'd need something like.unwrap()
, but executed at compile time.https://docs.rs/ndarray/0.15.6/ndarray/trait.Dimension.html#associatedconstant.NDIM
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.
A simpler alternative might be to split the bulk of the function, and then implement thin wrappers around (one per
Dimension
).Even the implementors of
Dimension
itself are just 7 (+ 1).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.
Otherwise, you should be able to use a const function to unwrap it, defining an associated constant, and try to use the associated constant in the signature.
https://users.rust-lang.org/t/compile-time-const-unwrapping/51619
EDIT: Unfortunately, const panic is not stabilized, because of an issue with Rust 2021 rust-lang/rust#85194, maybe you could check if const pattern matching is allowed
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.
A const function to unwrap IxN at compile time you mean?
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.
Indeed, in order to turn it into a
usize
(if you can notpanic
, you can always turnIxDyn
into a0
, it's useless anyhow, and it should not happen, so I wouldn't care that much).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 think this cannot be done. Or at least I cannot find a way of passing the
D
to the const function:and in any case, if I use a function that could depend on one of the parameters:
Not sure whether that means there's no way of doing what I want to do (without creating a path per dimension, at that point I rather leave the
N
)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'd really like to solve this issue. But if it's not simple, we could postpone.
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'd like to as well, but I haven't been able to...