-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Fixed segfault when adding OffsetArray and UniformScaling #38544
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Could this just be
for i in intersect(axes(A)...)
? Or less crypticallyintersect(axes(A,1), axes(A,2))
.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.
Yes, intersect is exactly the needed function:
julia/base/range.jl
Line 824 in 809f27c
By the way, we can remove checksquare(A) test now. Is a new pull request needed to examine this proposal?
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.
For the intersect thing just update the PR. Removing
checksquare
seems like it would merit discussion in a separate PR.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.
Although I guess this PR does raise the question whether this is really the right thing to do. So far, we've basically been looking at UniformScaling as an automatically resizing matrix, so it's not entirely clear what it should do with an OffsetArray. @timholy thoughts?
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.
@fp4code could you elaborate on the use case where you wanted this operation? That could perhaps guide intuition as to what it should do.
Uh oh!
There was an error while loading. Please reload this page.
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.
There is two choices.
Uh oh!
There was an error while loading. Please reload this page.
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.
Please can you help me about how to update a PR here? With just a new commit, or do you want a rebase?
Uh oh!
There was an error while loading. Please reload this page.
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.
Worth noting that
A = Matrix(I, 3, 4)
does work. But it is a bit more strange forA + I
to work, because normally you'd expect this to make sense:This property would also fail for an
A
with mismatched offsets. I guess that argues for option 2, makingchecksquare(A)
check the axes. In which case there is no need to alterfor i in axes(A, 1)
.Is
checksquare
used in other contexts where allowing different index ranges on left & right would make sense?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.
It doesn't really matter since the PR is likely to get squashed upon merge. Might be easiest to just add a commit.
Uh oh!
There was an error while loading. Please reload this page.
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.
Not really. But
checksquare
is problematic now, because it is used to return the size and not the common axis range. Worst, the multiple argumentchecksquare
, used in lapack.jl, is not efficient. See here for examplejulia/stdlib/LinearAlgebra/src/lapack.jl
Line 6152 in 3074306
The multiple arguments
checksquare
julia/stdlib/LinearAlgebra/src/LinearAlgebra.jl
Line 227 in 3074306
push!
calls. After this call, lapack function is checking that all matrices have the same dimensions. Well, thechecksquare(A...)
need to be replaced in lapack.jl by a more efficient function,get_common_size_of_square_matrices(A...)
. And here in uniformscaling.jlchecksquare(A)
could be replaced byr = get_range_of_square_matrix(A)
, replacingfor i in axes(A, 1)
byfor i in r
.