SHARE
TWEET

rosser_recipe

davidagross Jan 7th, 2014 156 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function R = rosser_recipe(classname)
  2. %ROSSER_RECIPE constructs the classic symmetric eigenvalue test.
  3. %   This matrix was a challenge for many matrix eigenvalue
  4. %   algorithms. But LAPACK's DSYEV routine used in MATLAB has
  5. %   no trouble with it. The matrix is 8-by-8 with integer
  6. %   elements.
  7. %
  8. %   It has:
  9. %       * A double eigenvalue.
  10. %       * Three nearly equal eigenvalues.
  11. %       * Dominant eigenvalues of opposite sign.
  12. %       * A zero eigenvalue.
  13. %       * A small, nonzero eigenvalue.
  14. %
  15. %   Modify the matrices M[1...4] to use your favorite
  16. %   eigenvalues.
  17. %
  18. %   ROSSER_RECIPE(CLASSNAME) produces a matrix of class
  19. %   CLASSNAME. CLASSNAME must be either 'single' or 'double'
  20. %   (the default).
  21. %
  22. %   Created by David A. Gross. Inspired by [1].
  23. %   Construction from [2,3].
  24. %
  25. %REFERENCES
  26. %   [1] http://blogs.mathworks.com/cleve/2014/01/06/ ...
  27. %   the-rosser-matrix/, accessed on 2014/01/07
  28. %
  29. %   [2] Rosser, J.B.; Lanczos, C.; Hestenes, M.R.; Karush, W.
  30. %   Separation of close eigenvalues of a real symmetric matrix
  31. %   (1951), J. Res. Natl. Bur. Stand., Vol. 47, No. 4, p. 291,
  32. %   Appendix 1, https://archive.org/details/jresv47n4p291,
  33. %   accessed on 2014/01/07
  34. %
  35. %   [3] T. Muir, History of Determinants III, 289 (Macmillan
  36. %   and Co., Ltd., London, 1920), http://igm.univ-mlv.fr/ ...
  37. %   ~al/Classiques/Muir/History_3/, accessed on 2014/01/07
  38.  
  39. %   Description Copyright 1984-2005 The MathWorks, Inc.
  40. %   $Revision: 5.10.4.2 $  $Date: 2005/11/18 14:15:39 $
  41.  
  42. if nargin < 1, classname = 'double'; end
  43.  
  44. % make our eigenvalues in 2x2 matrices
  45. M1 = [102  1 ;  1 -102]; % lambda = ± sqrt(102^2 + 1)
  46. M2 = [101  1 ;  1  101]; % lambda = 101 ± 1
  47. M3 = [  1 10 ; 10  101]; % lambda = 51 ± sqrt(51^2-1)
  48. M4 = [ 98 14 ; 14    2]; % lambda = 100, 0
  49.  
  50. B = zeros(8);
  51.  
  52. % explode M[1...4] into an 8x8 matrix
  53. B([1,6],[1,6]) = M1;
  54. B([2,8],[2,8]) = M2;
  55. B([4,5],[4,5]) = M3;
  56. B([3,7],[3,7]) = M4;
  57.  
  58. sylvester88_A = @(a,b,c,d) [ ...
  59.     a  b  c  d ; ...
  60.     b -a -d  c ; ...
  61.     c  d -a -b ; ...
  62.     d -c  b -a ];
  63.  
  64. sylvester44 = @(a,b,c,d) [ ...
  65.     a  b  c  d ; ...
  66.     b -a  d -c ; ...
  67.     c -d -a  b ; ...
  68.     d  c -b -a ];
  69.  
  70. % make Sylvester's "penorthogonant" of determinant 10^8
  71. P = blkdiag(sylvester88_A(2,1,1,2),sylvester44(1,-1,-2,2));
  72.  
  73. % P'*P = 10I
  74. R = P'*B*P;
  75.  
  76. R = cast(R,classname);
  77.  
  78. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top