# HG changeset patch
# User darij grinberg <darijgrinberg@gmail.com>
# Date 1381365647 25200
# Node ID 375e81f56dda840b5c8542017ac8e77d39c24f40
# Parent e3743b7a749fbdf97b95f945897237b7b75fe932
trac #14508: better now?
diff git a/sage/matrix/matrix2.pyx b/sage/matrix/matrix2.pyx
a

b

cdef class Matrix(matrix1.Matrix): 
8785  8785  Traceback (most recent call last): 
8786  8786  ... 
8787  8787  ValueError: Jordan normal form not implemented over inexact rings. 
8788   
8789   Here we need to specify a field (#14508). 
8790   
8791   :: 
8792   
 8788  
 8789  Here we need to specify a field, since the eigenvalues are not defined 
 8790  in the smallest ring containing the matrix entries (:trac:`14508`):: 
 8791  
8793  8792  sage: c = matrix([[0,1,0],[0,0,1],[1,0,0]]); 
8794  8793  sage: c.jordan_form(CyclotomicField(3)) 
8795  8794  [ 1 0 0] 
… 
… 
cdef class Matrix(matrix1.Matrix): 
8797  8796  [ 0 zeta3 0] 
8798  8797  [++] 
8799  8798  [ 0 0zeta3  1] 
8800   
 8799  
8801  8800  If you need the transformation matrix as well as the Jordan form of 
8802   ``self``, then pass the option ``transformation=True``. 
8803   
8804   :: 
8805   
 8801  ``self``, then pass the option ``transformation=True``. For example:: 
 8802  
8806  8803  sage: m = matrix([[5,4,2,1],[0,1,1,1],[1,1,3,0],[1,1,1,2]]); m 
8807  8804  [ 5 4 2 1] 
8808  8805  [ 0 1 1 1] 
… 
… 
cdef class Matrix(matrix1.Matrix): 
8821  8818  [0 1 0 0] 
8822  8819  [0 0 4 1] 
8823  8820  [0 0 0 4] 
8824   
8825   Note that for matrices over inexact rings and associated numerical 
8826   stability problems, we do not attempt to compute the Jordan normal 
8827   form. 
8828   
8829   :: 
8830   
 8821  
 8822  Note that for matrices over inexact rings, we do not attempt to 
 8823  compute the Jordan normal form, since it is not numerically 
 8824  stable:: 
 8825  
8831  8826  sage: b = matrix(ZZ,3,3,range(9)) 
8832  8827  sage: jf, p = b.jordan_form(RealField(15), transformation=True) 
8833  8828  Traceback (most recent call last): 
8834  8829  ... 
8835  8830  ValueError: Jordan normal form not implemented over inexact rings. 
8836   
 8831  
8837  8832  TESTS:: 
8838  8833  
8839  8834  sage: c = matrix(ZZ, 3, [1]*9); c 
… 
… 
cdef class Matrix(matrix1.Matrix): 
9064  9059  return self 
9065  9060  else: 
9066  9061  return self, self.parent().identity_matrix() 
9067   
 9062  
 9063  inferred_base_ring = base_ring 
 9064  
9068  9065  if base_ring is None: 
9069   base_ring = self.base_ring() 
9070   
9071   if not base_ring.is_exact(): 
 9066  inferred_base_ring = self.base_ring() 
 9067  
 9068  if not inferred_base_ring.is_exact(): 
9072  9069  raise ValueError("Jordan normal form not implemented over inexact rings.") 
9073  9070  
9074  9071  # Make sure we're working with a field. 
9075   if base_ring.is_field(): 
9076   A = self.change_ring(base_ring) 
 9072  if inferred_base_ring.is_field(): 
 9073  if base_ring is not None: 
 9074  A = self.change_ring(inferred_base_ring) 
 9075  else: 
 9076  A = self 
9077  9077  else: 
9078  9078  try: 
9079   base_field = base_ring.fraction_field() 
 9079  base_field = inferred_base_ring.fraction_field() 
9080  9080  except (NotImplementedError, TypeError, AttributeError): 
9081  9081  raise ValueError("Matrix entries must be from a field, not {0}". 
9082   format(base_ring)) 
 9082  format(inferred_base_ring)) 
9083  9083  A = self.change_ring(base_field) 
9084  9084  
9085  9085  # Compute the eigenvalues of the matrix, with multiplicities. Here, 