function xs = r8vec_scale_ab ( n, x, a, b )
%*****************************************************************************80
%
%% r8vec_scale_ab() scales an R8VEC to [A,B].
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 07 October 2018
%
% Author:
%
% John Burkardt
%
% Input:
%
% integer N, the number of entries in the vector.
%
% real X(N), the vector to be scaled.
%
% real A, B, the new limits.
%
% Output:
%
% real XS(N), the scaled vector.
%
xs = x(:);
xmin = min ( xs );
xmax = max ( xs );
if ( 0.0 < xmax - xmin )
xs = a + ( b - a ) * ( xs - xmin ) / ( xmax - xmin );
else
xs = ( a + b ) / 2.0;
end
return
end