8000 linalg.det throws LinAlgError for 0-by-0 matrices · Issue #8212 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
linalg.det throws LinAlgError for 0-by-0 matrices #8212
Closed
@mwallerb

Description

@mwallerb

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:

>>> A = numpy.empty((0, 0))
>>> numpy.linalg.inv(A)
array([], shape=(0, 0), dtype=float64)
>>> numpy.linalg.det(A)
LinAlgError: Arrays cannot be empty

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.linalg.det(A)
1.0

Numpy version: 1.11.0 (also present in git master)
Python version: 2.7.12

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0