function [ n, x, y, w ] = quadrilateral_witherden_rule ( p )

%*****************************************************************************80
%
%% quadrilateral_witherden_rule() returns a quadrilateral quadrature rule of given precision.
%
%  Discussion:
%
%    The unit hexahedron Q is bounded by the vertices
%    (0,0), (1,0), (1,1), (0,1).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 May 2023
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Freddie Witherden, Peter Vincent,
%    On the identification of symmetric quadrature rules for finite element methods,
%    Computers and Mathematics with Applications,
%    Volume 69, pages 1232-1241, 2015.
%
%  Input:
%
%    integer p: the precision, 0 <= p <= 21.
%
%  Output:
%
%    integer n: the order of the rule.
%
%    real x(n), y(n): the coordinates of quadrature points.
%
%    real w(n): the quadrature weights.
%
  if ( p < 0 ) 
    error ( 'quadrilateral_witherden_rule(): Input p < 0.\n' );
  end

  if ( 21 < p )
    error ( 'quadrilateral_witherden_rule(): Input 21 < p.\n' );
  end

  n = rule_order ( p );

  if ( p <= 1 )
    [ x, y, w ] = rule01 ( );
  elseif ( p <= 3 )
    [ x, y, w ] = rule03 ( );
  elseif ( p <= 5 )
    [ x, y, w ] = rule05 ( );
  elseif ( p <= 7 )
    [ x, y, w ] = rule07 ( );
  elseif ( p <= 9 )
    [ x, y, w ] = rule09 ( );
  elseif ( p <= 11 )
    [ x, y, w ] = rule11 ( );
  elseif ( p <= 13 )
    [ x, y, w ] = rule13 ( );
  elseif ( p <= 15 )
    [ x, y, w ] = rule15 ( );
  elseif ( p <= 17 )
    [ x, y, w ] = rule17 ( );
  elseif ( p <= 19 )
    [ x, y, w ] = rule19 ( );
  elseif ( p <= 21 )
    [ x, y, w ] = rule21 ( );
  end

  return
end

