function bicg_lesp ( n )

%*****************************************************************************80
%
%% bicg_lesp() tests bicg() for the Lesp matrix.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 March 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the size of the system.
%
  if ( nargin < 1 )
    n = 10;
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, 'bicg_lesp():\n' );
  fprintf ( 1, '  Test bicg() on the Lesp matrix.\n' );
  fprintf ( 1, '  Number of variables N = %d\n', n );
%
%  Get the matrix.
%
  A = lesp_matrix ( n );
  fprintf ( 1, '  Estimated condition number = %g\n', cond ( A ) );
%
%  Choose a random solution.
%
  x1 = rand ( n, 1 );
%
%  Compute the corresponding right hand side.
%
  b = A * x1;
%
%  Call bicg ( );
%
  x2 = ones ( n, 1 );

  it_max = 100;
  tol = 0.00000001;

  for it2 = 1 : 2

    [ x2, error, it, flag ] = bicg_mine ( A, x2, b, it_max, tol );
%
%  Compute the residual.
%
    r = b - A * x2;
    r_norm = norm ( r );
%
%  Compute the error.
%
    e_norm = norm ( x1 - x2 );
%
%  Report.
%
    fprintf ( 1, '\n' );
    fprintf ( 1, '  Full iteration number = %d\n', it2 );
    fprintf ( 1, '  Norm of residual |Ax-b| = %g\n', r_norm );
    fprintf ( 1, '  Norm of error |x1-x2| = %g\n', e_norm );

  end

  return
end
