function tridiag_test ( )

%*****************************************************************************80
%
%% tridiag_test tests tridiag.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 June 2019
%
%  Author:
%
%    John Burkardt
%
  n = 100;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'tridiag_test\n' );
  fprintf ( 1, '  tridiag factors and solves a tridiagonal linear system.\n' );
  fprintf ( 1, '  The matrix size is N = %d\n', n );
  fprintf ( 1, '\n' );
%
%  Set up the linear system, by storing the values of the
%  subdiagonal, diagonal, and superdiagonal in C, D, and E,
%  and the right hand side in B.
%
  a(1) = 0.0;
  a(2:n) = -1.0;

  b(1:n) = 2.0;

  c(1:n-1) = -1.0;
  c(n) = 0.0;

  f(1:n-1) = 0.0;
  f(n) = n + 1;
%
%  Factor and solve the system in one step.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Factor the matrix and solve the system.\n' );

  iflag = 0;

  [ x, alpha, beta, ier ] = tridiag ( a, b, c, f, n, iflag )
 
  if ( ier ~= 0 )
    fprintf ( 1, '\n' );
    fprintf ( 1, '  Error: ier = %d\n', ier );
    return
  end
%
%  Print the results.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  The first and last 5 entries of the solution:\n' );
  fprintf ( 1, '  (Should be 1,2,3,4,5,...,n,n-1):\n' );
  fprintf ( 1, '\n' );

  for i = 1 : n
    if ( i <= 5 || n-5 < i ) 
      fprintf ( 1, '  %6d  %14f\n', i, x(i) );
    end
    if ( i == 5 )
      fprintf ( 1, '  ......  ..............\n' );
    end
  end
 
  return
end
