-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH: Allow use of svd on empty arrays #11424
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
Conversation
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.
Looks good to me
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.
The changes are probably good, I guess there are practically tests run now when deleting those lines, but... IIRC the svd should probably have a specific form at least when full_matrices
is set to True, and I doubt that this is already being tested?
@@ -2771,6 +2770,15 @@ static NPY_INLINE void | |||
if ('N' == params.JOBZ) { | |||
delinearize_@REALTYPE@_matrix(args[1], params.S, &s_out); | |||
} else { | |||
if ('A' == params.JOBZ && min_m_n == 0) { | |||
/* Lapack has betrayed us and left these uninitialized, |
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.
NIT: comment should start on the next line.
Heh, that was quicker then possible ;), LGTM with the new test now. |
Hmm, actually, I am not 100% sure right now if this goes into Lapack, I am a bit worried that things might not work for annoying lapack implementations. And the thing is on a quick look over I am not sure it does not sometimes go into lapack. @eric-wieser are you pretty sure it is either not going in or lapack standard should error out cleanly? |
|
This does go into lapack, but it passes parameters that conform. Typically our mistakes in this area have been setting I'd probably say put it in - there's no way for lapack to produce an invalid result here, since in the 0-size case all of the outputs are overwritten after the call anyway. If it returns an error code, then we can handle that if/when we get a report of it. And if it clobbers arbitrary memory... Then I think the authors of the lapack implementation need strong words. |
OK, if you are certain enough that this is safe. I don't really know these lapack details well, vaguely remember that max(M, 1) thing. It also seems a bit like we are already doing this without complains in other functions, so seems fine. |
OK, tests succeed, so will put this in. Thanks Eric! |
part of #8654
Revived from over a year ago
cc @convexset