function [ o, c, e ] = polynomial_add ( o1, c1, e1, o2, c2, e2 )

%*****************************************************************************80
%
%% polynomial_add() adds two polynomials.
%
%  Discussion:
%
%    Thanks to Meritt Reynolds for suggesting changes that would ensure that
%    the output of this function was in the form of column vectors,
%    28 November 2015.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 November 2015
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer O1, the "order" of polynomial 1.
%
%    real C1(O1), the coefficients of polynomial 1.
%
%    integer E1(O1), the indices of the exponents of polynomial 1.
%
%    integer O2, the "order" of polynomial 2.
%
%    real C2(O2), the coefficients of polynomial 2.
%
%    integer E2(O2), the indices of the exponents of polynomial 2.
%
%  Output:
%
%    integer O, the "order" of the polynomial sum.
%
%    real C(O,1), the coefficients of the polynomial sum.
%
%    integer E(O,1), the indices of the exponents of the polynomial sum.
%  
%
%  Destroy all row vectors!
%
  c1 = c1(:);
  e1 = e1(:);

  c2 = c2(:);
  e2 = e2(:);

  o = o1 + o2;
  c = [ c1(1:o1); c2(1:o2) ];
  e = [ e1(1:o1); e2(1:o2) ];

  [ c, e ] = polynomial_sort ( o, c, e );
  [ o, c, e ] = polynomial_compress ( o, c, e );

  return
end

