function result = triangle01_monte_carlo ( t, p_num, f_num, ...
  triangle01_sample, triangle_integrand )

%*****************************************************************************80
%
%% triangle01_monte_carlo(): Monte Carlo method to integrate over unit triangle.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    12 February 2010
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real T(2,3), the triangle vertices.
%
%    integer P_NUM, the number of sample points.
%
%    integer F_NUM, the number of functions to integrate.
%
%    external TRIANGLE_UNIT_SAMPLE, the sampling routine.
%
%    external TRIANGLE_INTEGRAND, the integrand routine.
%
%  Output:
%
%    real RESULT(F_NUM), the approximate integrals.
%
  area = triangle_area ( t );

  p = triangle01_sample ( p_num );

  p2 = reference_to_physical_t3 ( t, p_num, p );

  fp = triangle_integrand ( p_num, p2, f_num );

  result = zeros ( f_num, 1 );
  
  for i = 1 : f_num
    result(i) = area * sum ( fp(i,1:p_num) ) / p_num;
  end

  return
end
