function rref_solve_test ( )

%*****************************************************************************80
%
%% rref_solve_test() tests rref_solve().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 December 2024
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'rref_solve_test():\n' );
  fprintf ( 1, '  rref_solve() uses the reduced row echelon form \n' );
  fprintf ( 1, '  of a square matrix to solve a linear system.\n' );

  n = 4;

  A = [ ...
     5,  7,  6,  5; ...
     7, 10,  8,  7; ...
     6,  8, 10,  9; ...
     5,  7,  9, 10 ];
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Matrix A:\n' );
  disp ( A );

  x = [ 1; 2; 3; 4 ];
  b = A * x;
  fprintf ( 1, '  Right hand side b:\n' );
  disp ( b );

  x2 = rref_solve ( A, b );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Estimated solution:\n' );
  disp ( x2 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  MATLAB solution:\n' );
  disp ( A \ b );

  b2 = A * x2;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Product A * x:\n' );
  disp ( b2 );

  return
end

