function [ n, a, b, c, d, w ] = tetrahedron_witherden_rule ( p )

%*****************************************************************************80
%
%% tetrahedron_witherden_rule() returns a tetrahedron quadrature rule of given precision.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 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 <= 10.
%
%  Output:
%
%    integer n: the order of the rule.
%
%    real a(n), b(n), c(n), d(n): the barycentric coordinates of quadrature points.
%
%    real w(n): the quadrature weights.
%
  if ( p < 0 ) 
    error ( 'tetrahedron_witherden_rule(): Input p < 0.\n' );
  end

  if ( 10 < p )
    error ( 'tetrahedron_witherden_rule(): Input 10 < p.\n' );
  end

  n = rule_order ( p );
  if ( p == 0 )
    [ a, b, c, d, w ] = rule00 ( );
  elseif ( p == 1 )
    [ a, b, c, d, w ] = rule01 ( );
  elseif ( p == 2 )
    [ a, b, c, d, w ] = rule02 ( );
  elseif ( p == 3 )
    [ a, b, c, d, w ] = rule03 ( );
  elseif ( p == 4 )
    [ a, b, c, d, w ] = rule04 ( );
  elseif ( p == 5 )
    [ a, b, c, d, w ] = rule05 ( );
  elseif ( p == 6 )
    [ a, b, c, d, w ] = rule06 ( );
  elseif ( p == 7 )
    [ a, b, c, d, w ] = rule07 ( );
  elseif ( p == 8 )
    [ a, b, c, d, w ] = rule08 ( );
  elseif ( p == 9 )
    [ a, b, c, d, w ] = rule09 ( );
  elseif ( p == 10 )
    [ a, b, c, d, w ] = rule10 ( );
  end

  return
end

