function sgtsl_vs_sparse ( n )

%*****************************************************************************80
%
%% SGTSL_VS_SPARSE compares SGTSL versus MATLAB's sparse solver.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    20 December 2011
%
%  Author:
%
%    John Burkardt
%
  if ( nargin < 1 )
    n = 100;
  end
%
%  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.
%
  c(1) = 0.0;
  c(2:n) = -1.0;

  d(1:n) = 2.0;

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

  b(1:n-1,1) = 0.0;
  b(n,1) = n + 1;
%
%  Factor and solve the system in one step.
%
  tic
  [ x, info ] = sgtsl ( n, c, d, e, b );
  t1 = toc;

  x(1:5)
%
%  Repeat for sparse matrix.
%
  b(1:n-1,1) = 0.0;
  b(n,1) = n + 1;

  i = [ 2:n, 1:n, 1:n-1 ];
  j = [ 1:n-1, 1:n, 2:n ];
  v = [ -1.0 * ones(1,n-1), 2.0 * ones(1,n), -1.0 * ones(1,n-1) ];

  A = sparse ( i,j,v, n, n );
  tic
  x = A \ b;
  t2 = toc;
  x(1:5)
%
%  Copy the matrix as a full one.
%
  A = full ( A );
  tic
  x = A \ b;
  t3 = toc;
  x(1:5)
%
%  Compare timings.
%
  fprintf ( 1, '  %d  %g  %g  %g\n', n, t1, t2, t3 );

  return
end
