-
-
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
export transpose! and ctranspose! #7814
Conversation
Maybe there should be an error if the two arguments are |
Can't multiple arrays reference the same memory, so that you actually need to compare the pointers of both start and end of both arrays, to ensure they don't overlap? |
These are valid points. Is this correctly checked for all user exposed functions? I never looked into other examples, aside from |
I only brought this up since I tried |
That would indeed be problematic with the current implementation. In place transposition is apparently a hard problem for non-square matrices. Note that this even changes the size of the matrix, which is something that you don’t typically expect for mutating operations on arrays. On 02 Aug 2014, at 19:41, Jeff Bezanson [email protected] wrote:
|
I agree you can only reasonably do it for square matrices, but this is just an example of something somebody might try. |
That’s true. I am totally open on how to deal with this. Only throw an error for this specific case explicitly, and warn against other potential issues in the docs. Or don’t check at all and warn in the docs. On 02 Aug 2014, at 20:17, Jeff Bezanson [email protected] wrote:
|
6c7c7e3
to
1a4c02f
Compare
I think we can merge this once the check is implemented. Throw an error for the specific case and warn against potential issues in docs seems like a reasonable solution. |
4f4112a
to
1af23bb
Compare
I rebased and added documentation, with explicit warning regarding unexpected results if the arrays overlap. Regarding adding the check for the specific case where the two arguments are There are many places where you can basically trigger this kind of problem. I am not sure whether we need to start adding checks now. If you use the mutating methods, aren't you supposed to know what you are doing. |
I don't think that these checks are necessary. If you are using the |
That's a fair point. Let's go ahead and merge. |
4790069
to
9499bb0
Compare
I've rebased and squashed the commits. If no more comments, I will merge tomorrow. |
I think the sparse transpose defines these in reverse order. Should we make it consistent? |
Also, I think these are useful to export, since there are cases where you can significantly avoid memory allocation. |
There doesn’t seem to be a transpose! for sparse matrices. I am not sure if that is what you mean? |
It exists. Look in csparse.jl. |
Now I see. I just tried with I guess the argument of the sparse matrices is in conflict with the typical convention of the first argument being the one that is modified / used as output (e.g. in |
That's right. It needs to be updated with the new convention. |
9499bb0
to
ba1f731
Compare
I've added the sparse functionality. Should I squash those two commits? |
I think it is better to have the commits the way they are, and a separate commit for the sparse transpose for future reference. |
That's what I thought. |
export transpose! and ctranspose!
I think this is ok for @JuliaBackports |
thanks - second commit here doesn't apply cleanly, see conflict diff at https://gist.github.com/aeb8cc230b506e921a84 |
there was a different PR for sparse in-place sorting, that I guess this one depends on due to the conflicts. maybe wait until after 0.3.3, look at backporting that one, then come back to this. |
That's fine with me. I know very little about the sparse functionality, I never use it and never really looked into it. |
I'm not sure adding new exports really needs to be or should be backported. |
Also fine, no preference here. |
I think this one does not need backporting - see my other comment on not backporting the sparse multiplication update. Taking off the backport label. |
This PR proposes to export
transpose!
andctranspose!
. When I was modified these functions a while ago ( #6690 ), I decided not to export them because the originaltranspose!
was also not exported. However, given that a lot of the mutating methods are exported, it would make sense to export these as well.If you agree to merge (before or after 0.3), I can also add them to the docs.