# HG changeset patch
# User Rob Beezer <beezer@ups.edu>
# Date 1271652660 25200
# Node ID 4ddb93f40eea558c3cab3fb9c6308699c9937ad8
# Parent ef74a6ed21179df343f658c015d7b068bb28c0f3
Trac 8710: Fix doctests for RDF eigenvectors
diff r ef74a6ed2117 r 4ddb93f40eea sage/matrix/matrix_double_dense.pyx
a

b


632  632  No attempt is made to determine if an eigenvalue has multiplicity 
633  633  greater than one, so all the eigenspaces returned have dimension one. 
634  634  
 635  The SciPy routines used for these computations produce eigenvectors 
 636  normalized to have length 1, but on different hardware they may vary 
 637  by a sign. So for doctests we have normalized output by creating an 
 638  eigenspace with a canonical basis. 
 639  
635  640  EXAMPLES:: 
636   
 641  
637  642  sage: m = matrix(RDF, [[5, 3, 2, 8],[10, 2, 4, 2],[1, 10, 10, 17],[2, 7, 6, 13]]) 
638  643  sage: spectrum = m.eigenspaces_left() 
639   sage: spectrum[0] 
640   (2.0, Vector space of degree 4 and dimension 1 over Real Double Field 
641   User basis matrix: 
642   [0.5 0.5 0.5 0.5]) 
 644  sage: spectrum[0][0] 
 645  2.0 
 646  sage: (RDF^4).subspace(spectrum[0][1].basis()) 
 647  Vector space of degree 4 and dimension 1 over Real Double Field 
 648  Basis matrix: 
 649  [1.0 1.0 1.0 1.0] 
643  650  
644  651  sage: e, V = spectrum[2] 
645  652  sage: v = V.basis()[0] 
… 
… 

688  695  No attempt is made to determine if an eigenvalue has multiplicity 
689  696  greater than one, so all the eigenspaces returned have dimension one. 
690  697  
 698  The SciPy routines used for these computations produce eigenvectors 
 699  normalized to have length 1, but on different hardware they may vary 
 700  by a sign. So for doctests we have normalized output by creating an 
 701  eigenspace with a canonical basis. 
 702  
 703  
691  704  EXAMPLES:: 
692  705  
693  706  sage: m = matrix(RDF, [[9, 14, 19, 74],[1, 2, 4, 11],[4, 12, 6, 32],[0, 2, 1, 1]]) 
… 
… 

697  710  [ 4.0 12.0 6.0 32.0] 
698  711  [ 0.0 2.0 1.0 1.0] 
699  712  sage: spectrum = m.eigenspaces_right() 
700   sage: spectrum[0] 
701   (2.0, Vector space of degree 4 and dimension 1 over Real Double Field 
702   User basis matrix: 
703   [ 0.258198889747 0.516397779494 0.774596669241 0.258198889747]) 
 713  sage: spectrum[0][0] 
 714  2.0 
 715  sage: (RDF^4).subspace(spectrum[0][1].basis()) 
 716  Vector space of degree 4 and dimension 1 over Real Double Field 
 717  Basis matrix: 
 718  [ 1.0 2.0 3.0 1.0] 
704  719  
705  720  sage: e, V = spectrum[2] 
706  721  sage: v = V.basis()[0] 
… 
… 

782  797  eigenvalues or zero eigenvalues should be addressed in the 
783  798  calling routine. 
784  799  
 800  The SciPy routines used for these computations produce eigenvectors 
 801  normalized to have length 1, but on different hardware they may vary 
 802  by a sign. So for doctests we have normalized output by forcing their 
 803  eigenvectors to have their first nonzero entry equal to one. 
 804  
785  805  EXAMPLES:: 
786  806  
787  807  sage: m = matrix(RDF, [[5, 3, 2, 8],[10, 2, 4, 2],[1, 10, 10, 17],[2, 7, 6, 13]]) 
… 
… 

791  811  [ 1.0 10.0 10.0 17.0] 
792  812  [ 2.0 7.0 6.0 13.0] 
793  813  sage: spectrum = m.left_eigenvectors() 
 814  sage: for i in range(len(spectrum)): 
 815  ... spectrum[i][1][0]=matrix(RDF, spectrum[i][1]).echelon_form()[0] 
794  816  sage: spectrum[0] 
795   (2.0, [(0.5, 0.5, 0.5, 0.5)], 1) 
 817  (2.0, [(1.0, 1.0, 1.0, 1.0)], 1) 
796  818  sage: spectrum[1] 
797   (1.0, [(0.615457454897, 0.492365963917, 0.492365963917, 0.369274472938)], 1) 
 819  (1.0, [(1.0, 0.8, 0.8, 0.6)], 1) 
798  820  sage: spectrum[2] 
799   (2.0, [(0.800640769025, 0.32025630761, 0.480384461415, 0.160128153805)], 1) 
 821  (2.0, [(1.0, 0.4, 0.6, 0.2)], 1) 
800  822  sage: spectrum[3] 
801   (1.0, [(0.316227766017, 0.316227766017, 0.632455532034, 0.632455532034)], 1) 
 823  (1.0, [(1.0, 1.0, 2.0, 2.0)], 1) 
802  824  """ 
803  825  if not self.is_square(): 
804  826  raise ArithmeticError, "self must be a square matrix" 
… 
… 

835  857  eigenvalues or zero eigenvalues should be addressed in the 
836  858  calling routine. 
837  859  
 860  The SciPy routines used for these computations produce eigenvectors 
 861  normalized to have length 1, but on different hardware they may vary 
 862  by a sign. So for doctests we have normalized output by forcing their 
 863  eigenvectors to have their first nonzero entry equal to one. 
 864  
838  865  EXAMPLES:: 
839   
 866  
840  867  sage: m = matrix(RDF, [[9, 14, 19, 74],[1, 2, 4, 11],[4, 12, 6, 32],[0, 2, 1, 1]]) 
841  868  sage: m 
842  869  [ 9.0 14.0 19.0 74.0] 
… 
… 

844  871  [ 4.0 12.0 6.0 32.0] 
845  872  [ 0.0 2.0 1.0 1.0] 
846  873  sage: spectrum = m.right_eigenvectors() 
 874  sage: for i in range(len(spectrum)): 
 875  ... spectrum[i][1][0]=matrix(RDF, spectrum[i][1]).echelon_form()[0] 
847  876  sage: spectrum[0] 
848   (2.0, [(0.258198889747, 0.516397779494, 0.774596669241, 0.258198889747)], 1) 
 877  (2.0, [(1.0, 2.0, 3.0, 1.0)], 1) 
849  878  sage: spectrum[1] 
850   (1.0, [(0.547722557505, 0.36514837167, 0.73029674334, 0.182574185835)], 1) 
 879  (1.0, [(1.0, 0.666666666667, 1.33333333333, 0.333333333333)], 1) 
851  880  sage: spectrum[2] 
852   (2.0, [(0.693375245282, 0.138675049056, 0.693375245282, 0.138675049056)], 1) 
 881  (2.0, [(1.0, 0.2, 1.0, 0.2)], 1) 
853  882  sage: spectrum[3] 
854   (1.0, [(0.426401432711, 0.213200716356, 0.852802865422, 0.213200716356)], 1) 
855   """ 
 883  (1.0, [(1.0, 0.5, 2.0, 0.5)], 1) 
 884  """ 
856  885  if not self.is_square(): 
857  886  raise ArithmeticError, "self must be a square matrix" 
858  887  if self._nrows == 0: 