#
# Restrict a class function f on W(R) to some reflection subgroup.
# J can be either a sublist of [1,...,n] indicating a parabolic subgroup,
# or a base for some (not necessarily parabolic) reflection subgroup.
#
`coxeter/restrict`:=proc(f,J,R) local S,S0,w,gens,cc,cc0,res,v,i,j;
  S:=coxeter['base'](R); S0:=J;
  if type(S0,'list'('integer')) then S0:=[seq(S[i],i=S0)] fi;
  v:=coxeter['interior_pt'](S);
  for i to nops(S0) do
    coxeter['vec2fc'](coxeter['reflect'](S0[i],v),S,'w');
    gens[i]:=op(w)
  od;
  cc:=coxeter['class_rep'](R);
  cc0:=coxeter['class_rep'](S0);
  for i to nops(cc0) do
    w:=[seq(gens[j],j=cc0[i])];
    w:=coxeter['class_rep'](w,R);
    if not member(w,cc,'j') then ERROR(`this cannot happen`) fi;
    res[i]:=f[j]
  od;
  [seq(res[i],i=1..nops(cc0))]
end:
#
save `coxeter/restrict`, cat(HomeLib,`/coxeter/restrict.m`);
read cat(HomeLib,`/help/coxeter/restrict`);
quit;

