function A = eigen_test ( nprob )
% A = eigen_test ( nprob ) returns a test matrix for eigenproblems.
%    Input, real NPROB, the problem number
%    Output, real A(N,N), a test matrix.

%  Author: John Burkardt
%  Modified by M. M. Sussman
%  $Date: 2014/01/18 18:20:14 $

%  matrix 1
%  Eigenvalues are 2, 1, -1.5.
%
if ( nprob == 1 )

  A = [ 0  -1   1
        7  5.5 -7
        5  2.5 -4];

%  matrix 2
%  Eigenvalues are 4.73, 3.0, 1.27
%  (See Atkinson, page 624).
elseif ( nprob == 2 )

  A = [  2 1 0 
         1 3 1 
         0 1 4 ];

%  matrix 3
%  Eigenvalues are 6.2749, -1.2749, -2
%  eigenvalue of smallest magnitude is negative
elseif ( nprob == 3 )

  A = [ 1  2  3
        2  1  4
        3  2  1];

%  matrix 4
%  Eigenvalues are 0.20, 0.75, 1.55, 2.45, 3.24, 3.80.
%  (See Atkinson, page 620).
elseif ( nprob == 4 )

  A = [  2 1 0 0 0 0 
         1 2 1 0 0 0 
         0 1 2 1 0 0 
         0 0 1 2 1 0 
         0 0 0 1 2 1 
         0 0 0 0 1 2 ];

%  matrix 5
%  Eigenvalues are 2, -2, 1+sqrt(3)i, 1-sqrt(3)i
elseif ( nprob == 5 )

  A = [  2.4 -4.4  2.0  1.6 
         2.8 -4.8  2.0  3.2 
         3.2 -5.2  4.0  0.8
         3.6 -3.6  2.0  0.4 ];

%  matrix 6
%  Eigenvalues are apporximately 22.4, 6,3,2,1.61
%  -6*inv(dif2(5))
elseif ( nprob == 6 )

  A = [5  4  3  2  1
       4  8  6  4  2
       3  6  9  6  3
       2  4  6  8  4
       1  2  3  4  5];

% matrix 7
% dif2 matrix, size 50: slowly converging for power method.
elseif ( nprob == 7 )
  A=diag(2*ones(50,1),0)-diag(ones(49,1),1)-diag(ones(49,1),-1);

%  matrix 8
%  Eigenvalues are -4.1496, -2.1747, 3.3243
elseif ( nprob == 8 )

  A = [ -2 1  0 
         1 3  1 
         0 1 -4 ];

%  No such problem.
else
  error( 'eigen_test: No such problem number!' );
end
