Skip to content
Open
Changes from all 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
32 changes: 32 additions & 0 deletions src/sage/matrix/matrix2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5037,6 +5037,22 @@ cdef class Matrix(Matrix1):
self.cache('right_kernel', K)
return K

def _test_right_kernel(self, **options):
"""
Check that :meth:`right_kernel` works.

EXAMPLES::

sage: a = matrix([[1,2], [3,4]])
sage: a._test_right_kernel()

"""
tester = self._tester(**options)
# At least we'll check that the basis of the kernel kills the matrix
V = self.right_kernel()
tester.assert_(self.ncols() - self.rank() == V.dimension())
tester.assert_((self * V.basis_matrix().transpose()).is_zero())

def left_kernel(self, *args, **kwds):
r"""
Returns the left kernel of this matrix, as a vector space or free module.
Expand Down Expand Up @@ -5193,6 +5209,22 @@ cdef class Matrix(Matrix1):

kernel = left_kernel

def _test_left_kernel(self, **options):
"""
Check that :meth:`left_kernel` works.

EXAMPLES::

sage: a = matrix([[1,2], [3,4]])
sage: a._test_left_kernel()

"""
tester = self._tester(**options)
# At least we'll check that the basis of the kernel kills the matrix
V = self.left_kernel()
tester.assert_(self.nrows() - self.rank() == V.dimension())
tester.assert_((V.basis_matrix() * self).is_zero())

def kernel_on(self, V, poly=None, check=True):
"""
Return the kernel of self restricted to the invariant subspace V.
Expand Down