function cg_squared_invol ( n )

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

  fprintf ( 1, '\n' );
  fprintf ( 1, 'cg_squared_invol\n' );
  fprintf ( 1, '  Test cg_squared() on the invol matrix.\n' );
  fprintf ( 1, '  Number of variables N = %d\n', n );
%
%  Get the matrix.
%
  A = invol_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 cg_squared ( );
%
  x2 = ones ( n, 1 );

  for it = 1 : 4

    x2 = cg_squared ( A, b, x2 );
%
%  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', it );
    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
