#
# orbit_size(v,R) will produce the size of the orbit of the vector v under
#  the action of the reflection group corresponding to R.
# orbit_size(v,R,-1) will do the same, but for the (possibly larger) group
#  obtained by adjoining -1.
#
`coxeter/orbit_size`:=proc(v0,R) local v,S,res,EPS,J;
  S:=coxeter['base'](R);
  v:=coxeter['vec2fc'](v0,S);
  if type([op(S),v],'list'('polynom'('rational'))) then EPS:=0
    else EPS:=`coxeter/default`['epsilon']
  fi;
  J:=map(proc(x,y,z) if coxeter['iprod'](x,y)<=z then x fi end,S,v,EPS);
  res:=coxeter['size'](R)/coxeter['size'](J);
  if nargs>2 then
    v:=v-coxeter['vec2fc'](-v0,S);
    if EPS>0 and coxeter['iprod'](v,v)>EPS then res:=2*res
      elif EPS=0 and v<>0 then res:=2*res
    fi
  fi; res
end:
#
save `coxeter/orbit_size`, cat(HomeLib,`/coxeter/orbit_size.m`);
read cat(HomeLib,`/help/coxeter/orbit_size`);
quit;
 
