function bernstein_matrix_test2 ( )

%*****************************************************************************80
%
%% BERNSTEIN_MATRIX_TEST2 tests BERNSTEIN_MATRIX.
%
%  Discussion:
%
%    Here we use the Bernstein matrix to describe Bernstein polynomials
%    in terms of standard monomials.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    10 January 2014
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'BERNSTEIN_MATRIX_TEST2\n' );
  fprintf ( 1, '  BERNSTEIN_MATRIX returns a matrix which\n' );
  fprintf ( 1, '  transforms a polynomial coefficient vector\n' );
  fprintf ( 1, '  from the the Bernstein basis to the power basis.\n' );
  fprintf ( 1, '  We can use this to get explicit values of the\n' );
  fprintf ( 1, '  4-th degree Bernstein polynomial coefficients as\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '    B(4,K)(X) = C4 * x^4\n' );
  fprintf ( 1, '              + C3 * x^3\n' );
  fprintf ( 1, '              + C2 * x^2\n' );
  fprintf ( 1, '              + C1 * x\n' );
  fprintf ( 1, '              + C0 * 1\n' );

  n = 5;
  fprintf ( 1, '\n' );
  fprintf ( 1, '     K       C4           C3            C2' );
  fprintf ( 1, '            C1             C0\n' );
  fprintf ( 1, '\n' );

  a = bernstein_matrix ( n );

  for k = 1 : n

    x = zeros ( n, 1 );
    x(k) = 1.0;

    ax = a * x;

    fprintf ( 1, '  %4d  ', k );
    for i = 1 : n
      fprintf ( 1, '%14g', ax(i) );
    end
    fprintf ( 1, '\n' );

  end

  return
end

