# HG changeset patch
# User Rob Beezer <beezer@ups.edu>
# Date 1317790151 25200
# Node ID 64fa7cab253fc0efa9944146d699f1ae4b7ac3bb
# Parent 10f49e34d981dccab46b3c81dc60a14f0ee2d747
11897: fix failing doctest for RDF eigenmatrix
diff git a/sage/matrix/matrix2.pyx b/sage/matrix/matrix2.pyx
a

b


4630  4630  This method is only applicable to exact matrices. 
4631  4631  The "eigenmatrix" routines for matrices with doubleprecision 
4632  4632  floatingpoint entries (``RDF``, ``CDF``) are the best 
4633   alternative. There are also "eigenmatrix" routines for 
 4633  alternative. (Since some platforms return eigenvectors 
 4634  that are the negatives of those given here, this one example 
 4635  is not tested here.) There are also "eigenmatrix" routines for 
4634  4636  matrices with symbolic entries. :: 
4635  4637  
4636  4638  sage: A = matrix(QQ, 3, 3, range(9)) 
… 
… 

4645  4647  [ 13.3484692... 0 0] 
4646  4648  [ 0 1.34846922... 0] 
4647  4649  [ 0 0 0] 
4648   sage: eigenvectors = em[1]; eigenvectors 
 4650  sage: eigenvectors = em[1]; eigenvectors # not tested 
4649  4651  [ 0.440242867... 0.567868371... 0.695493875...] 
4650  4652  [ 0.897878732... 0.278434036... 0.341010658...] 
4651  4653  [ 0.408248290... 0.816496580... 0.408248290...] 
… 
… 

4889  4891  This method is only applicable to exact matrices. 
4890  4892  The "eigenmatrix" routines for matrices with doubleprecision 
4891  4893  floatingpoint entries (``RDF``, ``CDF``) are the best 
4892   alternative. There are also "eigenmatrix" routines for 
 4894  alternative. (Since some platforms return eigenvectors 
 4895  that are the negatives of those given here, this one example 
 4896  is not tested here.) There are also "eigenmatrix" routines for 
4893  4897  matrices with symbolic entries. :: 
4894  4898  
4895  4899  sage: B = matrix(RR, 3, 3, range(9)) 
… 
… 

4904  4908  [ 13.3484692... 0 0] 
4905  4909  [ 0 1.34846922... 0] 
4906  4910  [ 0 0 0] 
4907   sage: eigenvectors = em[1]; eigenvectors 
 4911  sage: eigenvectors = em[1]; eigenvectors # not tested 
4908  4912  [ 0.164763817... 0.799699663... 0.408248290...] 
4909  4913  [ 0.505774475... 0.104205787... 0.816496580...] 
4910  4914  [ 0.846785134... 0.591288087... 0.408248290...] 
… 
… 

5264  5268  [0 0 0] 
5265  5269  sage: P*A == D*P 
5266  5270  True 
 5271  
 5272  TESTS: 
 5273  
 5274  For matrices with floating point entries, some platforms will 
 5275  return eigenvectors that are negatives of those returned by the 
 5276  majority of platforms. This test accounts for that possibility. 
 5277  Running this test independently, without adjusting the eigenvectors 
 5278  could indicate this situation on your hardware. :: 
 5279  
 5280  sage: A = matrix(QQ, 3, 3, range(9)) 
 5281  sage: em = A.change_ring(RDF).eigenmatrix_left() 
 5282  sage: evalues = em[0]; evalues 
 5283  [ 13.3484692... 0 0] 
 5284  [ 0 1.34846922... 0] 
 5285  [ 0 0 6.2265089...e16] 
 5286  sage: evectors = em[1]; 
 5287  sage: for i in range(3): 
 5288  ... scale = evectors[i,0].sign() 
 5289  ... evectors.rescale_row(i, scale) 
 5290  sage: evectors 
 5291  [ 0.440242867... 0.567868371... 0.695493875...] 
 5292  [ 0.897878732... 0.278434036... 0.341010658...] 
 5293  [ 0.408248290... 0.816496580... 0.408248290...] 
5267  5294  """ 
5268  5295  from sage.misc.flatten import flatten 
5269  5296  evecs = self.eigenvectors_left() 
… 
… 

5330  5357  [0 0 0] 
5331  5358  sage: A*P == P*D 
5332  5359  True 
 5360  
 5361  TESTS: 
 5362  
 5363  For matrices with floating point entries, some platforms will 
 5364  return eigenvectors that are negatives of those returned by the 
 5365  majority of platforms. This test accounts for that possibility. 
 5366  Running this test independently, without adjusting the eigenvectors 
 5367  could indicate this situation on your hardware. :: 
 5368  
 5369  sage: B = matrix(QQ, 3, 3, range(9)) 
 5370  sage: em = B.change_ring(RDF).eigenmatrix_right() 
 5371  sage: evalues = em[0]; evalues 
 5372  [ 13.3484692... 0 0] 
 5373  [ 0 1.34846922... 0] 
 5374  [ 0 0 8.86256604...e16] 
 5375  sage: evectors = em[1]; 
 5376  sage: for i in range(3): 
 5377  ... scale = evectors[0,i].sign() 
 5378  ... evectors.rescale_col(i, scale) 
 5379  sage: evectors 
 5380  [ 0.164763817... 0.799699663... 0.408248290...] 
 5381  [ 0.505774475... 0.104205787... 0.816496580...] 
 5382  [ 0.846785134... 0.591288087... 0.408248290...] 
5333  5383  """ 
5334  5384  D,P=self.transpose().eigenmatrix_left() 
5335  5385  return D,P.transpose() 