function r8mat_scale_ab_test ( )

%*****************************************************************************80
%
%% r8mat_scale_ab_test() tests r8mat_scale_ab().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 October 2018
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'r8mat_scale_ab_test():\n' );
  fprintf ( 1, '  r8mat_scale_ab() shifts and scales the columns of an R8MAT\n' );
  fprintf ( 1, '  so they each have min A and max B\n' );

  m = 5;
  n = 3;
  a = -5.0;
  b = 15.0;
  x = a + ( b - a ) * rand ( m, n );
 
  r8mat_print ( m, n, x, '  Array X:' );
  mu = mean ( x );
  sigma = std ( x );
  xmax = max ( x );
  xmin = min ( x );
  fprintf ( 1, '\n' );
  r8vec_transpose_print ( n, mu, '  mean(X):' );
  r8vec_transpose_print ( n, sigma, '  std(X):' );
  r8vec_transpose_print ( n, xmax, '  max(X):' );
  r8vec_transpose_print ( n, xmin, '  min(X):' );

  a = -1.0;
  b = +1.0;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Rescale to interval [%g,%g]\n', a, b );

  xs = r8mat_scale_ab ( m, n, x, a, b );

  r8mat_print ( m, n, xs, '  Array XS:' );
  mu = mean ( xs );
  sigma = std ( xs );
  xmax = max ( xs );
  xmin = min ( xs );
  fprintf ( 1, '\n' );
  r8vec_transpose_print ( n, mu, '  mean(XS):' );
  r8vec_transpose_print ( n, sigma, '  std(XS):' );
  r8vec_transpose_print ( n, xmax, '  max(XS):' );
  r8vec_transpose_print ( n, xmin, '  min(XS):' );

  return
end
