function [ x, w ] = rule_adjust ( a, b, c, d, n, x, w )

%*****************************************************************************80
%
%% rule_adjust() maps a quadrature rule from [A,B] to [C,D].
%
%  Discussion:
%
%    Most quadrature rules are defined on a special interval, like
%    [-1,1] or [0,1].  To integrate over an interval, the abscissas
%    and weights must be adjusted.  This can be done on the fly,
%    or by calling this routine.
%
%    If the weight function W(X) is not 1, then the W vector will
%    require further adjustment by the user.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    12 October 2005
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real A, B, the endpoints of the definition interval.
%
%    real C, D, the endpoints of the integration interval.
%
%    integer N, the number of abscissas and weights.
%
%    real X(N), the abscissas.
%
%    real W(N), the weights.
%
%  Output:
%
%    real X(N), the adjusted abscissas.
%
%    real W(N), the adjusted weights.
%
  x(1:n) = ( ( b - x(1:n)     ) * c   ...
           + (     x(1:n) - a ) * d ) ...
           / ( b          - a );

  w(1:n) = ( ( d - c ) / ( b - a ) ) * w(1:n);

  return
end
