function simplex_gm_rule_test09 ( )

%*****************************************************************************80
%
%% simplex_gm_rule_test09() tests gm_unit_rule_set().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    02 March 2017
%
%  Author:
%
%    John Burkardt
%
  e_test = [ ...
    0, 0, 0; ...
    1, 0, 0; ...
    0, 1, 0; ...
    0, 0, 1; ...
    2, 0, 0; ...
    1, 1, 0; ...
    1, 0, 1; ...
    0, 2, 0; ...
    0, 1, 1; ...
    0, 0, 2 ]';

  fprintf ( 1, '\n' );
  fprintf ( 1, 'simplex_gm_rule_test09():\n' );
  fprintf ( 1, '  gm_unit_rule_set() determines the weights and abscissas\n' );
  fprintf ( 1, '  of a Grundmann-Moeller quadrature rule for\n' );
  fprintf ( 1, '  the M dimensional unit simplex,\n' );
  fprintf ( 1, '  using a rule of index RULE,\n' );
  fprintf ( 1, '  which will have degree of exactness 2*RULE+1.\n' );

  fprintf ( 1, '  In this test, look at all the monomials up to\n' );
  fprintf ( 1, '  some maximum degree, choose a few low order rules\n' );
  fprintf ( 1, '  and determine the quadrature error for each.\n' );

  m = 3;
  volume = simplex_unit_volume ( m );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Simplex volume = %g\n', volume );

  fprintf ( 1, '\n' );
  fprintf ( 1, '         N        1               X               Y ' );
  fprintf ( 1,'              Z               X^2              XY             XZ' );
  fprintf ( 1, '              Y^2             YZ               Z^2\n' );
  fprintf ( 1, '\n' );

  for rule = 0 : 5

    n = gm_rule_size ( rule, m );

    [ w, x ] = gm_unit_rule_set ( rule, m, n );

    fprintf ( 1, '  %8d', n );

    for k = 1 : 10

      e(1:m) = e_test(1:m,k);

      value = monomial_value ( m, n, e, x  );

      result = w' * value;

      fprintf ( 1, '  %14.6g', result );
    end

    fprintf ( 1, '\n' );

  end

  return
end
