Ticket #14508: trac_14508_matrix_jordan_form.patch

File trac_14508_matrix_jordan_form.patch, 2.0 KB (added by itolkov, 8 years ago)
  • sage/matrix/matrix2.pyx

    # HG changeset patch
    # User Igor Tolkov <itolkov@gmail.com>
    # Date 1367552918 25200
    # Node ID a91ee327fa367ed79e91718bb27788d98066f23b
    # Parent  c8ae9724d3cfad1837a130d50ac5c83a811ec221
    Trac 14508: bugfix in jordan_form
    
    diff --git a/sage/matrix/matrix2.pyx b/sage/matrix/matrix2.pyx
    a b  
    85418541            Traceback (most recent call last):
    85428542            ...
    85438543            ValueError: Jordan normal form not implemented over inexact rings.
     8544           
     8545        Here we need to specify a field (#14508).
     8546       
     8547        ::
     8548       
     8549            sage: c = matrix([[0,1,0],[0,0,1],[1,0,0]]);
     8550            sage: c.jordan_form(CyclotomicField(3))
     8551            [         1|         0|         0]
     8552            [----------+----------+----------]
     8553            [         0|     zeta3|         0]
     8554            [----------+----------+----------]
     8555            [         0|         0|-zeta3 - 1]
    85448556       
    85458557        If you need the transformation matrix as well as the Jordan form of
    85468558        ``self``, then pass the option ``transformation=True``.
     
    87868798            else:
    87878799                return self, self.parent().identity_matrix()
    87888800       
    8789         if (base_ring is None and not self.base_ring().is_exact()) or \
    8790             (not base_ring is None and not base_ring.is_exact()):
     8801        if base_ring is None:
     8802            base_ring = self.base_ring()
     8803
     8804        if not base_ring.is_exact():
    87918805            raise ValueError("Jordan normal form not implemented over inexact rings.")
    87928806       
    8793         if base_ring is None:
    8794             A = self
    8795             base_ring = self.base_ring()
    8796 
    8797         # make sure we're working with a field..
    8798         if not base_ring.is_field():
     8807        # Make sure we're working with a field.
     8808        if base_ring.is_field():
     8809            A = self.change_ring(base_ring)
     8810        else:
    87998811            try:
    88008812                base_field = base_ring.fraction_field()
    88018813            except (NotImplementedError, TypeError, AttributeError):