-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
linalg.det throws LinAlgError for 0-by-0 matrices #8212
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
Comments
Hi! I'll take a look and see what I can do to fix this. But just a heads up, this is my first time fixing a bug in numpy, so I might not be super quick. |
Because of the ability to compute determinants of a stack of arrays this seems to get a little...messy.
Now, my thought is to do the following: Loop over a and flag any arrays in the stack that are empty. Keep track of the indices where there are empty arrays for later. Does this seem like it will address the issue? |
All "stacked" arrays are always of the same shape, which can be
determined from the overall shape so no loops needed.
|
Hm, so if one member of a stacked array is empty, they are then all empty? This doesn't seem to be explicitly forbidden by numpy:
|
@mhassell: That's a |
@mhassell I think you may draw some inspiration from the code of |
Sure, I'll check it out and try to fix this. Thanks for the pointer. |
Hi, I'd like to know if this is still being worked on? I'd like to try my hand at it otherwise. |
Hi Don86, I've gotten a bit swamped with other stuff, so please do have a go at it. |
I've got this one, but I think there are a tonne more cases in |
I would like to work on this one, @eric-wieser can you point out some of the cases that you were talking about in the previous comment? |
@ashwinpathak20:
Update: mostly fixed! |
Fixes numpy#8212 det: return ones of the right shape slogdet: return sign=ones, log=zeros of the right shape pinv, eigvals(h?), eig(h?): return empty array(s?) of the right shape svd & qr: not implemented, due to complex return value rules
Since LAPACK functions cannot handle 0-by-0 matrices, numpy must explicitly handle those cases. However, while in newer versions of numpy, the inverse is computed correctly, the determinant raises
LinAlgError
:Since the determinant of a zero-by-zero matrix is well-defined, a LinAlgError is IMHO wrong, since it indicates a numerics problem rather than the purely technical fact that the backend cannot handle this.
Thus, expected result:
Numpy version: 1.11.0 (also present in git master)
Python version: 2.7.12
The text was updated successfully, but these errors were encountered: