#
# toe(f)    convert the symmetric function f into an e-polynomial.
# toe(f,b)  does the same, assuming f is expressed solely in basis b.
# The final result is collected with respect to e1,e2,e3,...
# If b is not a predefined basis, f must be *linear* in the b[..]'s.
#
`SF/toe`:=proc() local f,bases,sp,i,mu,d,b,c,nrows;
  nrows:=`SF/getrows`(args); f:=args[1];
  bases:=`SF/getbase`(args) minus {'e'};
  sp:=SF['varset'](f,bases minus {'p','h'});
  for b in bases minus {'h','p','s[]'} do
    c:=op(0,b); if sp[c]=[] then next fi;
    if assigned(`SF/dual`[c]) then
      f:=`SF/dualize`(c,sp[c],f); bases:={op(bases),'p'}
    else
      f:=`SF/added`(c,sp[c],f)
    fi
  od;
  if member('s[]',bases) then b:='e';
    if nops(sp['s'])>1 and nrows=0 then b:=NULL; bases:={op(bases),'h'} fi;
    f:=subs({seq(s[op(mu)]=`SF/jt_det`(mu,nrows,b),mu=sp['s'])},f);
  fi;
  if nrows>0 then
    d:=SF['varset'](f,'e');
    f:=subs({seq(cat('e',i)=0,i=nrows+1..d)},f)
  fi;
  if member('p',bases) then f:=`SF/to_ehp`('p','e',f,nrows) fi;
  if member('h',bases) then f:=`SF/to_ehp`('h','e',f,nrows) fi;
  d:=SF['varset'](f,'e');
  collect(f,[seq(cat('e',i),i=1..d)],'distributed',normal);
end: 
#
save `SF/toe`, cat(HomeLib,`/SF/toe.m`);
read cat(HomeLib,`/help/SF/toe`);
quit;

