function test_eigen_left ( )

%*****************************************************************************80
%
%% test_eigen_left() tests left eigensystems.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 December 2015
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'test_eigen_left():\n' );
  fprintf ( 1, '  Compute the Frobenius norm of the left eigensystem error:\n' );
  fprintf ( 1, '    X*A * LAMBDA*X\n' );
  fprintf ( 1, '  given K left eigenvectors X and eigenvalues LAMBDA.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Title                    N     K      ||A||          ' );
  fprintf ( 1, '||X*A-Lambda*X||\n' );
  fprintf ( 1, '\n' );
%
%  a123
%
  title = 'a123';
  n = 3;
  k = 3;
  a = a123_matrix ( );
  lambda = a123_eigenvalues ( );
  x = a123_eigen_left ( );
  error_frobenius = r8mat_is_eigen_left ( n, k, a, x, lambda );
  norm_frobenius = norm ( a, 'fro' );
  fprintf ( 1, '  %-20s  %4d  %4d  %14g  %14g\n', ...
    title, n, k, norm_frobenius, error_frobenius );
%
%  carry
%
  title = 'carry';
  n = 5;
  k = 5;
  i4_lo = 2;
  i4_hi = 20;
  key = 123456789;
  rng ( key );
  i1 = randi ( [ i4_lo, i4_hi ], 1 );
  a = carry_matrix ( n, i1 );
  lambda = carry_eigenvalues ( n, i1 );
  x = carry_eigen_left ( n, i1 );
  error_frobenius = r8mat_is_eigen_left ( n, k, a, x, lambda );
  norm_frobenius = norm ( a, 'fro' );
  fprintf ( 1, '  %-20s  %4d  %4d  %14g  %14g\n', ...
    title, n, k, norm_frobenius, error_frobenius );
%
%  chow
%
  title = 'chow';
  n = 5;
  k = 5;
  r8_lo = -5.0;
  r8_hi = +5.0;
  key = 123456789;
  rng ( key );
  alpha = r8_lo + ( r8_hi - r8_lo ) * rand ( 1, 1 );
  beta = r8_lo + ( r8_hi - r8_lo ) * rand ( 1, 1 );
  a = chow_matrix ( alpha, beta, n, n );
  lambda = chow_eigenvalues ( alpha, beta, n );
  x = chow_eigen_left ( alpha, beta, n );
  error_frobenius = r8mat_is_eigen_left ( n, k, a, x, lambda );
  norm_frobenius = norm ( a, 'fro' );
  fprintf ( 1, '  %-20s  %4d  %4d  %14g  %14g\n', ...
    title, n, k, norm_frobenius, error_frobenius );
%
%  diagonal
%
  title = 'diagonal';
  n = 5;
  k = 5;
  r8_lo = -5.0;
  r8_hi = +5.0;
  key = 123456789;
  rng ( key );
  d = r8_lo + ( r8_hi - r8_lo ) * rand ( n, 1 );
  a = diagonal_matrix ( n, n, d );
  lambda = diagonal_eigenvalues ( n, d );
  x = diagonal_eigen_left ( n, d );
  error_frobenius = r8mat_is_eigen_left ( n, k, a, x, lambda );
  norm_frobenius = norm ( a, 'fro' );
  fprintf ( 1, '  %-20s  %4d  %4d  %14g  %14g\n', ...
    title, n, k, norm_frobenius, error_frobenius );
%
%  rosser1
%
  title = 'rosser1';
  n = 8;
  k = 8;
  a = rosser1_matrix ( );
  lambda = rosser1_eigenvalues ( );
  x = rosser1_eigen_left ( );
  error_frobenius = r8mat_is_eigen_left ( n, k, a, x, lambda );
  norm_frobenius = norm ( a, 'fro' );
  fprintf ( 1, '  %-20s  %4d  %4d  %14g  %14g\n', ...
    title, n, k, norm_frobenius, error_frobenius );
%
%  symmetric_random
%
  title = 'symmetric_random';
  n = 5;
  k = 5;
  r8_lo = -5.0;
  r8_hi = +5.0;
  key = 123456789;
  rng ( key );
  d = r8_lo + ( r8_hi - r8_lo ) * rand ( n, 1 );
  a = symmetric_random_matrix ( n, d, key );
  lambda = symmetric_random_eigenvalues ( n, d, key );
  x = symmetric_random_eigen_left ( n, d, key );
  error_frobenius = r8mat_is_eigen_left ( n, k, a, x, lambda );
  norm_frobenius = norm ( a, 'fro' );
  fprintf ( 1, '  %-20s  %4d  %4d  %14g  %14g\n', ...
    title, n, k, norm_frobenius, error_frobenius );

  return
end
