function r8poly_division_test ( )

%*****************************************************************************80
%
%% r8poly_division_test() tests r8poly_division().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    13 April 2009
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'r8poly_division_test():\n' );
  fprintf ( 1, '  r8poly_division() computes the quotient and\n' );
  fprintf ( 1, '  remainder for polynomial division.\n' );
  fprintf ( 1, '\n' );
%
%  1: Divide X^3 + 2*X^2 - 5*X - 6  by X-2.  
%     Quotient is 3+4*X+X^2, remainder is 0.
%
%  2: Divide X^4 + 3*X^3 + 2*X^2 - 2  by  X^2 + X - 3.
%     Quotient is X^2 + 2*X + 3, remainder 8*X + 7.
%
%  3: Divide X^3 - 2*X^2 + 0*X - 4  by  X - 3.
%     Quotient is X^2 + X + 3, remainder 5.
%
  ntest = 3;
  
  for test = 1 : ntest

    if ( test == 1 )
      na = 3;
      a(1:na+1) = [ -6.0, -5.0, 2.0, 1.0 ];
      nb = 1;
      b(1:nb+1) = [ -2.0, 1.0 ];
    elseif ( test == 2 )
      na = 4;
      a(1:na+1) = [ -2.0, 5.0, 2.0, 3.0, 1.0 ];
      nb = 2;
      b(1:nb+1) = [ -3.0, 1.0, 1.0 ];
    elseif ( test == 3 )
      na = 3;
      a(1:na+1) = [ -4.0, 0.0, -2.0, 1.0 ];
      nb = 1;
      b(1:nb+1) = [ -3.0, 1.0 ];
    end

    r8poly_print ( a, '  The polynomial to be divided, A:' );
    r8poly_print ( b, '  The divisor polynomial, B:' );

    [ nq, q, nr, r ] = r8poly_division ( na, a, nb, b );
 
    r8poly_print ( q, '  The quotient polynomial, Q:' );
    r8poly_print ( r, '  The remainder polynomial, R:' );

  end

  return
end
