Skip to content

Commit

Permalink
Trac #30161: Zero Matrix has Inverse over Finite Field
Browse files Browse the repository at this point in the history
The bug is outlined in this post:
https://ask.sagemath.org/question/52487/zero-matrix-has-an-inverse-over-
finite-field/

In short, the following lines of code should throw an error, but they do
not.

{{{
M = Matrix([0], ring=GF(4))
M.inverse()
}}}

Instead they return the matrix [1].

URL: https://trac.sagemath.org/30161
Reported by: gh-prismika
Ticket author(s): Martin Albrecht
Reviewer(s): Samuel Lelièvre
  • Loading branch information
Release Manager committed Jul 28, 2020
2 parents d35315a + ccaf79d commit 37c62d2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sage/matrix/matrix_gf2e_dense.pyx
Expand Up @@ -1019,8 +1019,13 @@ cdef class Matrix_gf2e_dense(matrix_dense.Matrix_dense):
cdef Matrix_gf2e_dense A
A = Matrix_gf2e_dense.__new__(Matrix_gf2e_dense, self._parent, 0, 0, 0)

if self._nrows and self._nrows == self._ncols:
if self.rank() != self._nrows:
raise ZeroDivisionError("Matrix does not have full rank.")

if self._nrows:
sig_on()
mzed_invert_newton_john(A._entries, self._entries)
sig_off()

return A

Expand Down

0 comments on commit 37c62d2

Please sign in to comment.