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

%*****************************************************************************80
%
%% hexahedron_witherden_rule() returns a hexahedron quadrature rule of given precision.
%
%  Discussion:
%
%    The unit hexahedron H is bounded by the vertices
%    (0,0,0), (1,0,0), (1,1,0), (0,1,0), (0,0,1), (1,0,1), (1,1,1), (0,1,1).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 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 <= 11.
%
%  Output:
%
%    integer n: the order of the rule.
%
%    real x(n), y(n), z(n): the coordinates of quadrature points.
%
%    real w(n): the quadrature weights.
%
  if ( p < 0 ) 
    error ( 'hexahedron_witherden_rule(): Input p < 0.\n' );
  end

  if ( 11 < p )
    error ( 'hexahedron_witherden_rule(): Input 11 < p.\n' );
  end

  n = rule_order ( p );

  if ( p <= 1 )
    [ x, y, z, w ] = rule01 ( );
  elseif ( p <= 3 )
    [ x, y, z, w ] = rule03 ( );
  elseif ( p <= 5 )
    [ x, y, z, w ] = rule05 ( );
  elseif ( p <= 7 )
    [ x, y, z, w ] = rule07 ( );
  elseif ( p <= 9 )
    [ x, y, z, w ] = rule09 ( );
  elseif ( p <= 11 )
    [ x, y, z, w ] = rule11 ( );
  end

  return
end

