function n = rule_order ( p )

%*****************************************************************************80
%
%% rule_order() returns the order of the requested quadrature rule.
%
%  Licensing:
%
%    This code is distributed under the GNU GPL license.
%
%  Modified:
%
%    10 June 2023
%
%  Author:
%
%    John Burkardt.
%
%  Reference:
%
%    Hong Xiao, Zydrunas Gimbutas,
%    A numerical algorithm for the construction of efficient quadrature
%    rules in two and higher dimensions,
%    Computers and Mathematics with Applications,
%    Volume 59, 2010, pages 663-676.
%
%  Input:
%
%    integer p: the precision of the quadrature.  1 <= p <= 50.
%
%  Output:
%
%    integer n: the number of nodes in the full rule.
%
  nnodes = [ ...
      1,   3,   6,   6,   7,  12,  15,  16,  19,  25, ...
     28,  33,  37,  42,  49,  55,  60,  67,  73,  79, ...
     87,  96, 103, 112, 120, 130, 141, 150, 159, 171, ...
    181, 193, 204, 214, 228, 243, 252, 267, 282, 295, ...
    309, 324, 339, 354, 370, 385, 399, 423, 435, 453 ];

  if ( 0 == p )
    n = 1;
  elseif ( 1 <= p && p <= 50 )
    n = nnodes(p);
  else
    fprintf ( 1, '\n' );
    fprintf ( 1, 'rule_order(): Fatal error!\n' );
    fprintf ( 1, '  Precision p must be between 0 and 50.\n' );
    error ( 'rule_order(): Fatal error!' );
  end

  return
end

