function r83v_cg_test ( )

%*****************************************************************************80
%
%% R83V_CG_TEST tests R83V_CG.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 February 2016
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'R83V_CG_TEST\n' );
  fprintf ( 1, '  R83V_CG applies CG to an R83V matrix.\n' );
%
%  Set A to the second difference matrix.
%
  n = 10;

  [ a, b, c ] = r83v_dif2 ( n, n );
%
%  Choose a random solution.
%
  seed = 123456789;
  [ x1, seed ] = r8vec_uniform_01 ( n, seed );
%
%  Compute the corresponding right hand side.
%
  ax = r83v_mv ( n, n, a, b, c, x1 );
%
%  Call the CG routine.
%
  x2 = ones ( n, 1 );
  x3 = r83v_cg ( n, a, b, c, ax, x2 );
%
%  Compute the residual.
%
  r = r83v_res ( n, n, a, b, c, x3, ax );
  r_norm = norm ( r(1:n) );
%
%  Compute the error.
%
  x1 = x1(:);
  x3 = x3(:);
  e_norm = norm ( x1 - x3 );
%
%  Report.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Number of variables N = %d\n', n );
  fprintf ( 1, '  Norm of residual ||Ax-b|| = %g\n', r_norm );
  fprintf ( 1, '  Norm of error ||x1-x2|| = %g\n', e_norm );

  return
end
