function gauss_seidel_stochastic_test01 ( )

%*****************************************************************************80
%
%% gauss_seidel_stochastic_test01() tests gauss_seidel_stochastic().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 February 2022
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'gauss_seidel_stochastic_test01():\n' );
  fprintf ( 1, '  gauss_seidel_stochastic() solves a linear system using\n' );
  fprintf ( 1, '  a stochastic version of the Gauss-Seidel iteration.\n' );

  n = 20;
  x_exact = ( 1 : n )';

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Iterations  ||Ax-b||\n' );
  fprintf ( 1, '\n' );

  for kits = [ 10, 20, 40, 80, 160, 320, 640, 1280, 2560 ]
    A = dif2_matrix ( n );
    b = A * x_exact;
    x = zeros ( n, 1 );  
    x = gauss_seidel_stochastic ( kits, A, b, x );
    l2error = norm ( A * x - b );
    fprintf ( 1, '  %4d        %g\n', kits, l2error );
  end

  return
end
