-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
18267 1x1 NaN matrix eigenvalue #18526
18267 1x1 NaN matrix eigenvalue #18526
Conversation
I think the problem is the |
How about |
I am not so sure about the 1x1 issymmetrical case. It is the "same" NaN when transposed so maybe it isn't incorrect for it to be considered symmetrical. Anyway, I can redo it to be checked in the issymmetric function if that is deemed the better solution (obviously you guys know better than me). |
Symmetry is issymmetric(x::Number) = x == x |
I updated it. I did not realize that Julia didn't evaluate NaN == NaN in any case. I am going to submit a new pr for the By the way, I know about methods() and applicable(), but is there a way to tell, given a multiple dispatch method name and a possible input, which method specifically would be called (the line number and the parameter types/function signature)? When I was trying to determine which issymmetric and eigfact! was being called, I had to resort to putting print statements in every candidate and rebuilding, which was inefficient. |
Try |
for eltya in (NaN16, NaN32, NaN) | ||
@test_throws(ArgumentError, eig(fill(eltya, 1, 1))) | ||
@test_throws(ArgumentError, eig(fill(eltya, 2, 2))) | ||
test_matrix = rand(3,3) |
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.
probably rand(eltya, 3, 3)
rand(typeof(eltya), 3, 3)
to avoid repeating this for Float64
3 times?
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, I did not consider this behavior. Thanks.
@@ -100,7 +100,7 @@ end | |||
for eltya in (NaN16, NaN32, NaN) | |||
@test_throws(ArgumentError, eig(fill(eltya, 1, 1))) | |||
@test_throws(ArgumentError, eig(fill(eltya, 2, 2))) | |||
test_matrix = rand(3,3) | |||
test_matrix = rand(typeof(eltya,3,3) |
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.
missing a close paren
return false | ||
end | ||
return true | ||
end |
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 don't think that this is sufficient although it will fix the eig
issue. For larger matrices, we'd have to check that whole diagonal so instead the loop ranges below should be made one larger to include the diagonal.
@mcognetta It would be great to get this merged soon. Do you have time to finish up the PR? |
Sorry, been a little busy. Ill do it now. |
Thanks for fixing this. |
Thanks for the help. |
Added a check when computing the eigenvalue of a matrix for if the matrix is a 1x1 matrix with NaN elements. Previously this case incorrectly returned a value (not NaN) while the 2x2 and larger dimensional cases threw an error.
This is my first contribution to Julia, so any help or feedback is greatly appreciated.
#18267