function jfrac_to_rfrac_test ( )

%*****************************************************************************80
%
%% jfrac_to_rfrac_test() tests jfrac_to_rfrac().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    02 October 2010
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'jfrac_to_rfrac_test():\n' );
  fprintf ( 1, '  jfrac_to_rfrac() converts a J fraction\n' );
  fprintf ( 1, '  to a rational polynomial fraction.\n' );
%
%  Generate the data, but force Q(M+1) to be 1.  
%  That will make it easier to see that the two operations are inverses
%  of each other.  JFRAC_TO_RFRAC is free to scale its output, and chooses
%  a scaling in which Q(M+1) is 1.
%
  m = 6;
  p = rand ( m, 1 );
  q = rand ( m + 1, 1 );

  q(1:m+1) = q(1:m+1) / q(m+1);

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The original rational polynomial coefficients:\n' );
  fprintf ( 1, '\n' );
  for i = 1 : m
    fprintf ( 1, '  %8f', p(i) );
  end
  fprintf ( 1, '\n' );
  for i = 1 : m + 1
    fprintf ( 1, '  %8f', q(i) );
  end
  fprintf ( 1, '\n' );
 
  [ r, s ] = rfrac_to_jfrac ( m, p, q );
 
  fprintf ( 1, '\n' );
  fprintf ( 1, '  The J fraction coefficients:\n' );
  fprintf ( 1, '\n' );
  for i = 1 : m
    fprintf ( 1, '  %8f', r(i) );
  end
  fprintf ( 1, '\n' );
  for i = 1 : m
    fprintf ( 1, '  %8f', s(i) );
  end
  fprintf ( 1, '\n' );
 
  [ p, q ] = jfrac_to_rfrac ( m, r, s );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The recovered rational polynomial:\n' );
  fprintf ( 1, '\n' );
  for i = 1 : m
    fprintf ( 1, '  %8f', p(i) );
  end
  fprintf ( 1, '\n' );
  for i = 1 : m+1
    fprintf ( 1, '  %8f', q(i) );
  end
  fprintf ( 1, '\n' );

  return
end
