#
# cartan_matrix(R) - generate the Cartan matrix of an xtal root system
# index(R) - determine the index of connection of an xtal root system
#
`coxeter/cartan_matrix`:=proc(M) local S,r,s,coS;
  if type(M,'matrix') and M[1,1]=2 then S:=M else
    S:=coxeter['base'](M);
    if S=[] then RETURN(S) fi;
    coS:=coxeter['co_base'](S);
    S:=array([seq([seq(coxeter['iprod'](r,s),s=coS)],r=S)])
  fi;
  if type(S,'matrix'('integer')) then eval(S)
    else ERROR(`not crystallographic`) fi
end:
#
`coxeter/index`:=proc(R) local M;
  M:=`coxeter/cartan_matrix`(R);
  if type(M,'matrix') then linalg['det'](M) else 1 fi
end:
#
save `coxeter/cartan_matrix`, `coxeter/index`,
  cat(HomeLib,`/coxeter/cartan_matrix.m`);
read cat(HomeLib,`/help/coxeter/cartan_matrix`);
read cat(HomeLib,`/help/coxeter/index`);
quit;

