Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/sage/matrix/matrix_gf2e_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,22 @@
break
return pivots

def is_invertible(self):
"""
Return if invertible by checking full rank.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: use the same description as the general function.

Suggested change
Return if invertible by checking full rank.
Return "True" if this matrix is invertible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ​`​`True`​`​ instead.


This comment was marked as resolved.

EXAMPLES::

sage: m = Matrix(GL(2^8, GF(2^8)).random_element())

Check warning on line 972 in src/sage/matrix/matrix_gf2e_dense.pyx

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Warning: slow doctest:

slow doctest:
sage: m.is_invertible()
True
"""
if self._ncols != self._nrows:
return False
if self._nrows != self.rank():
return False
return True

def __invert__(self):
"""
EXAMPLES::
Expand All @@ -980,13 +996,12 @@
cdef Matrix_gf2e_dense A
A = Matrix_gf2e_dense.__new__(Matrix_gf2e_dense, self._parent, 0, 0, 0)

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

if self._nrows:

This comment was marked as resolved.

sig_on()
mzed_invert_newton_john(A._entries, self._entries)
sig_off()
sig_on()
mzed_invert_newton_john(A._entries, self._entries)
sig_off()

return A

Expand Down
Loading