data = load ( 'cubature_pyr_sym_p16_n285_expand.txt' );
output = fopen ( 'rule16.m', 'w' );
n = size ( data, 1 );

fprintf ( output, 'function [ x, y, z, w ] = rule16 ( )\n' );
fprintf ( output, '\n' );
fprintf ( output, '%%*****************************************************************************80\n' );
fprintf ( output, '%%\n' );
fprintf ( output, '%%%% rule16() returns the pyramid quadrature rule of precision 16.\n' );
fprintf ( output, '%%\n' );
fprintf ( output, '%%  Licensing:\n' );
fprintf ( output, '%%\n' );
fprintf ( output, '%%    This code is distributed under the MIT license.\n' );
fprintf ( output, '%%\n' );
fprintf ( output, '%%  Modified:\n' );
fprintf ( output, '%%\n' );
fprintf ( output, '%%    15 April 2023\n' );
fprintf ( output, '%%\n' );
fprintf ( output, '%%  Author:\n' );
fprintf ( output, '%%\n' );
fprintf ( output, '%%    John Burkardt\n' );
fprintf ( output, '%%\n' );
fprintf ( output, '%%  Reference:\n' );
fprintf ( output, '%%\n' );
fprintf ( output, '%%    Jan Jaskowiec, Natarajan Sukumar,\n' );
fprintf ( output, '%%    High order symmetric cubature rules for tetrahedra and pyramids,\n' );
fprintf ( output, '%%    International Journal for Numerical Methods in Engineering,\n' );
fprintf ( output, '%%    Volume 122, Number 1, pages 148-171, 24 August 2020.\n' );
fprintf ( output, '%%\n' );
fprintf ( output, '%%  Output:\n' );
fprintf ( output, '%%\n' );
fprintf ( output, '%%    x(n), y(n), z(n): the coordinates of quadrature points.\n' );
fprintf ( output, '%%\n' );
fprintf ( output, '%%    w(n): the quadrature weights.\n' );
fprintf ( output, '%%\n' );
fprintf ( output, '  x = [ ...\n' );
for i = 1 : n - 1
  fprintf ( output, '    %24.20f, ...\n', data(i,1) );
end
fprintf ( output, '    %24.20f ];\n', data(n,1) );

fprintf ( output, '\n' );
fprintf ( output, '  y = [ ...\n' );
for i = 1 : n - 1
  fprintf ( output, '    %24.20f, ...\n', data(i,2) );
end
fprintf ( output, '    %24.20f ];\n', data(n,2) );


fprintf ( output, '\n' );
fprintf ( output, '  z = [ ...\n' );
for i = 1 : n - 1
  fprintf ( output, '    %24.20f, ...\n', data(i,3) );
end
fprintf ( output, '    %24.20f ];\n', data(n,3) );

fprintf ( output, '\n' );
fprintf ( output, '  w = [ ...\n' );
for i = 1 : n - 1
  fprintf ( output, '    %24.20f, ...\n', data(i,4) );
end
fprintf ( output, '    %24.20f ];\n', data(n,4) );

fprintf ( output, '\n' );
fprintf ( output, '  return\n' );
fprintf ( output, 'end\n' );

fclose ( output );
