#
# Compute tensor product multiplicities and branching multiplicities via
#  the Brauer-Klimyk Rule. The smaller of the two irreps should be u.
# Calling sequence:  `weyl/klimyk`(u,v,J,R), where
#  J is the set of nodes to delete ( = {} for tensor products),
#  v is the second dominant weight ( = 0 for branching).
# Note that branching to arbitrary root subsystems is possible with
#  only slight modifications.
#
`weyl/klimyk`:=proc() local res,S,coS,v0,wt,wm,a,u,m,Nghbr;
  res:=0; S:=coxeter['base'](args[4]);
  a:=ilcm(op(map(denom,S))); S:=map((x,y)->y*x,S,a);
  coS:=coxeter['co_base'](S);
  wt:=weyl['weights'](S);
  v0:=a*args[2]+convert(wt,`+`);
  wm:=weyl['weight_mults'](a*args[1],S);
  Nghbr:=`weyl/neighbor`(S,args[3],0);
  if type(wm,`+`) then wm:=[op(wm)] else wm:=[wm] fi;
  for a in wm do
    u:=op(indets(a)); m:=coeff(a,u);
    u:=convert(zip((x,y)->x*y,[op(u)],wt),`+`);
    res:=res+m*`weyl/orbit_sum`(u,v0,S,coS,Nghbr,'skew');
  od; res
end:
#
save `weyl/klimyk`, cat(HomeLib,`/weyl/klimyk.m`);
quit;

