-
-
Notifications
You must be signed in to change notification settings - Fork 484
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 RowVectorView type #1232
base: main
Are you sure you want to change the base?
Add RowVectorView type #1232
Conversation
If this moves forward, it would be nice if the docs were updated to be like what I did in #1266, assuming that also moves forward. |
Add a view type for row vectors equivalent to the view type for column vectors.
c79906c
to
06e8547
Compare
I updated the doc comments accordingly... Honestly, it's pretty demotivating making such a simple PR on explicit request (#1229 (comment)) and then getting no feedback at all. |
@Andlon @sebcrozet It seems like this fell through the cracks ... |
I'm sorry. Believe me, it's also very demotivating not to have time to review all the open PRs! Alas, the breaking changes here require careful consideration, which I think is why I did not manage to "simply merge" this before. Unfortunately this is still the case for now. I don't think |
I am not sure what you mean. There already was a
Which breaking change do you mean? There should be none. |
I think the alleged breaking change might be in the adjustment to the unsafe trait impls for I think you are also correct that the |
@Andlon Is my understanding accurate that this isn't a breaking change? If so then I can merge this. |
I believe it's a breaking change, because existing generic code might just have |
Hmm, I think you're right. I can test it out. My thinking was that that shouldn't matter, because it's also implemented for the This is a problem with the lack of intersection/lattice impls, right? If the bound was just |
Yup, you're right. Tragic! use nalgebra::{Dim, IsContiguous, ViewStorage, U1};
fn first<'a, T, R: Dim, CStride: Dim>(storage: ViewStorage<'a, T, R, U1, U1, CStride>) {
second(storage);
}
fn second<S: IsContiguous>(storage: S) {}
fn main() {} Compiles against A shame because this does seem like a great addition and an obvious hole in the API -- should we save this for a major version bump, then? The alternative could be to have a |
Thank you for the consideration and review of this change. I did not foresee this breaking change, so I am glad you caught it. It is indeed very unfortunate.
That was the motivation for this PR and the issue it stems from.
Just a random thought, could this also be addressed using specialization? Not that that seems to happen anytime soon either... As I am currently not using nalgebra anymore, I don't have the time to explore possible other resolutions to the issue. So please handle and change this PR however you see fit. |
I think I'd be fine with the breaking change. I think it makes the non-generic usage more symmetric/consistent. Generic code anyway doesn't have to rely on the So I think my vote is to accept the breaking change, and merge when we're ready for merging breaking changes. |
Add a view type for row vectors equivalent to the view type for column vectors. This should address issue #1229 with the explicit request for a PR. To make conversions from and to slices possible I had to change some lines of
unsafe
code in base/matrix_view.rs as described below. I think those changes should be fine, but please give them a thorough review.Changes to
unsafe
codeTo implement the
From
trait for conversion from and to slices forRowVectorView
I had to adjust the implementation ofIsContiguous
forViewStorage
to avoid conflicting impls. The way I did this is to impose stronger trait bounds on the standing implementation to make room for the additional implementation for a 'ViewStorage' where the column stride is statically 1. Since the case where both the column and row stride are statically 1 would not be covered anymore with the additional trait bounds, I also added a implementation specifically for this special case.