function svsort_test ( )

%*****************************************************************************80
%
%% svsort_test() tests svsort().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    30 July 2016
%
%  Author:
%
%    John Burkardt
%
  n = 5;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'SVSORT_TEST\n' );
  fprintf ( 1, '  SVSORT sorts a vector D, and the corresponding columns\n' );
  fprintf ( 1, '  of a matrix V.\n' );

  d = rand ( n, 1 );

  v = zeros ( n, n );

  for i = 1 : n
    for j = 1 : n
      v(i,j) = 10 * i + j;
    end
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  First row = entries of D.\n' );
  fprintf ( 1, '  Corresponding columns of V below.\n' );
  fprintf ( 1, '\n' );
  for j = 1 : n
    fprintf ( 1, '%14.6g', d(j) );
  end
  fprintf ( 1, '\n' );
  fprintf ( 1, '\n' );
  for i = 1 : n
    for j = 1 : n
      fprintf ( 1, '%14.6g', v(i,j) );
    end
    fprintf ( 1, '\n' );
  end

  [ d, v ] = svsort ( n, d, v );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  After sorting D and rearranging V:\n' );
  fprintf ( 1, '\n' );
  for j = 1 : n
    fprintf ( 1, '%14.6g', d(j) );
  end
  fprintf ( 1, '\n' );
  fprintf ( 1, '\n' );
  for i = 1 : n
    for j = 1 : n
      fprintf ( 1, '%14.6g', v(i,j) );
    end
    fprintf ( 1, '\n' );
  end

  return
end

