#
# toddq(f) converts a symmetric function f in the omega algebra into
#  a polynomial function of q1,q3,q5,...
# toddq(f,'b'), where 'b' is one of the names p, P[] or Q[], will
#   assume that f is expressed in base b.
#
# N.B. the representation of f in this form is unique, but it runs
# slower than 'toq'.
#
`QF/toddq`:=proc() local poly,i,j,d;
  poly:=QF['toq'](args);
  d:=SF['varset'](poly,'q');
  for i from iquo(d,2) by -1 to 1 do
    poly:=subs(cat('q',2*i)=-(-1)^i*cat('q',i)^2/2
      -convert([seq((-1)^j*cat('q',j)*cat('q',2*i-j),j=1..i-1)],`+`),poly)
  od;
  collect(poly,[seq(cat('q',i),i=1..d)],'distributed',normal)
end:
#
save `QF/toddq`, cat(HomeLib,`/QF/toddq.m`);
read cat(HomeLib,`/help/QF/toddq`);
quit;

