Ticket #7989: trac-7989-minpoly-test.patch

File trac-7989-minpoly-test.patch, 1.1 KB (added by jason, 13 years ago)
  • sage/matrix/matrix2.pyx

    # HG changeset patch
    # User Jason Grout <jason-sage@creativetrax.com>
    # Date 1263868724 21600
    # Node ID 3326a75ae5acce9bb1d0c15dd74b773d663c545d
    # Parent  13aa97f93ed068689cf30d6be0ba5e1341fdd945
    Implement a generic test for minpoly of matrices.
    
    diff -r 13aa97f93ed0 -r 3326a75ae5ac sage/matrix/matrix2.pyx
    a b  
    12561256                mp *= h**(n-1)
    12571257        self.cache('minpoly', mp)
    12581258        return mp
    1259    
     1259
     1260    def _test_minpoly(self, **options):
     1261        """
     1262        Checks that :meth:`minpoly` works.
     1263
     1264        EXAMPLES::
     1265
     1266            sage: a=matrix([[1,2],[3,4]])
     1267            sage: a._test_minpoly()
     1268
     1269        """
     1270        if self.nrows()==self.ncols():
     1271            tester = self._tester(**options)
     1272            # At least we'll check that the minimal polynomial kills the
     1273            # matrix.
     1274            tester.assert_(self.minpoly().subs(x=self).is_zero())
     1275
    12601276    def charpoly(self, var = 'x', algorithm = None):
    12611277        r"""
    12621278        Returns the characteristic polynomial of self, as a polynomial over