function gram_polynomial_test ( )

%*****************************************************************************80
%
%% gram_polynomial_test() tests gram_polynomial().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 June 2019
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../gram_polynomial' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'gram_polynomial_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test gram_polynomial()\n' );

  gram_abscissas_test ( );
  gram_beta_test ( );
  gram_polynomial_coefficients_test ( );

  m = 10;
  x = linspace ( -1.0, 1.0, 101 );
  for n = 0 : 5
    g = gram_polynomial_evaluate ( n, m, x );
    plot ( x, g, 'linewidth', 3 );
    label = sprintf ( 'Gram polynomial p_{%d,%d}(x)', n, m );
    title ( label );
    grid ( 'on' );
    filename = sprintf ( 'gram_%d_%d.png', n, m );
    print ( '-dpng', filename );
    fprintf ( 1, '  Graphics saved as "%s"\n', filename );
    pause ( 5 )
  end
%
%  Check orthogonality.
%
  A = zeros ( 6, 6 );
  m = 25;
  for n1 = 0 : 5
    for n2 = 0 : 5
      A(n1+1,n2+1) = gram_polynomial_inner_product ( n1, n2, m );
    end
  end

  A
%
%  Orthogonal projection of f(x):
%
  f = @(x) ( exp ( x ) );
  m = 50;
  n_max = 10;
  c = zeros ( n_max + 1, 1 );
  for j = 0 : n_max
    c(j+1) = gram_projection ( f, j, m );
  end

  c

  r8poly_print_test ( );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'gram_polynomial_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  timestamp ( );

  rmpath ( '../gram_polynomial' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

