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

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

  if ( 20 < p )
    error ( 'triangle_witherden_rule(): Input 20 < p.\n' );
  end

  n = rule_order ( p );
  if ( p == 0 )
    [ a, b, c, w ] = rule00 ( );
  elseif ( p == 1 )
    [ a, b, c, w ] = rule01 ( );
  elseif ( p == 2 )
    [ a, b, c, w ] = rule02 ( );
  elseif ( p == 3 )
    [ a, b, c, w ] = rule03 ( );
  elseif ( p == 4 )
    [ a, b, c, w ] = rule04 ( );
  elseif ( p == 5 )
    [ a, b, c, w ] = rule05 ( );
  elseif ( p == 6 )
    [ a, b, c, w ] = rule06 ( );
  elseif ( p == 7 )
    [ a, b, c, w ] = rule07 ( );
  elseif ( p == 8 )
    [ a, b, c, w ] = rule08 ( );
  elseif ( p == 9 )
    [ a, b, c, w ] = rule09 ( );
  elseif ( p == 10 )
    [ a, b, c, w ] = rule10 ( );
  elseif ( p == 11 )
    [ a, b, c, w ] = rule11 ( );
  elseif ( p == 12 )
    [ a, b, c, w ] = rule12 ( );
  elseif ( p == 13 )
    [ a, b, c, w ] = rule13 ( );
  elseif ( p == 14 )
    [ a, b, c, w ] = rule14 ( );
  elseif ( p == 15 )
    [ a, b, c, w ] = rule15 ( );
  elseif ( p == 16 )
    [ a, b, c, w ] = rule16 ( );
  elseif ( p == 17 )
    [ a, b, c, w ] = rule17 ( );
  elseif ( p == 18 )
    [ a, b, c, w ] = rule18 ( );
  elseif ( p == 19 )
    [ a, b, c, w ] = rule19 ( );
  elseif ( p == 20 )
    [ a, b, c, w ] = rule20 ( );
  end

  return
end

