\\examples from docu
nf = nfinit(y^2+1);
PR = idealprimedec(nf,5); #PR
hi = [];
hf = [PR, [1/3,-1/3]];
A = alginit(nf, [3,hf,hi]);
algsplittingfield(A).pol
K = nfsplitting(x^4+x+1);
gal = galoisinit(K);
al = alggroupcenter(gal,,&cc);
algiscommutative(al)
#cc[3]
\\end examples

\\test ordering in simpledec
print("ordering");
Sn(n) = [Vecsmall(numtoperm(n,i)) | i <- [0..n!-1]];
D2n(n)=
{
  [[vectorsmall(2*n,i,if(i==n,1,i==2*n,n+1,i+1)),
    vectorsmall(2*n,i,if(i==1,n+1,i==n+1,1,2*n+2-i))],Vecsmall([n,2])];
}
testordering(al)={
 my(jac, ss, dec);
 jac=algradical(al);
 if(jac==0, ss=al, ss=algquotient(al,jac));
 dec=algsimpledec(ss)[2];
 print(apply(algdim,dec));
 print([#algcenter(x) | x<-dec]);
};
setrand(1);
{for(n=1,4,
  print("S",n);
  al = alggroup(Sn(n),7);
  print(algisassociative(al));
  testordering(al);
);}
{for(n=1,3,
  print("S",n);
  al = alggroup(Sn(n));
  print(algisassociative(al));
  testordering(al);
);}
{for(n=4,16,
  print("D",2*n);
  al = alggroup(D2n(n),691);
  if(n<10,print(algisassociative(al)));
  testordering(al);
);}
{for(n=4,12,
  print("D",2*n);
  al = alggroup(D2n(n));
  if(n<10,print(algisassociative(al)));
  testordering(al);
);}

\\alggroup
print("alggroup");
K = nfsplitting(x^3-x+1);
gal = galoisinit(K);
al = alggroup(gal)
algissemisimple(al)
alggroup([Vecsmall([2,1]),Vecsmall([1,2])]);
alggroup([Vecsmall([1,2])]);
alggroup([Vecsmall([1,2,3]), Vecsmall([1,3,2])])
gal = galoisinit(nfsplitting(x^4+7));
alggroup(gal);
gal = galoisinit(nfsplitting(x^6+7));
alggroup(gal);

\\alggroupcenter
{for(n=1,5,
  print("S",n);
  al = alggroupcenter(Sn(n),7);
  print(algisassociative(al));
  print(algiscommutative(al));
  print(algdim(al) == #algsimpledec(al)[2]);
);}
{for(n=1,4,
  print("S",n);
  al = alggroupcenter(Sn(n));
  print(algisassociative(al));
  print(algiscommutative(al));
  print(algdim(al) == #algsimpledec(al)[2]);
);}
conjD2neven(n)=2+(n-2)/2+2;
conjD2nodd(n)=1+(n-1)/2+1;
conjD2n(n)=if(n%2,conjD2nodd(n),conjD2neven(n));
firstprime1mod(n) =
{
  p = 2;
  while(p%n!=1, p=nextprime(p+1));
  p;
}
{for(n=3,20,
  print("D",2*n);
  p = firstprime1mod(2*n);
  al = alggroupcenter(D2n(n),p);
  print(algdim(al) == conjD2n(n));
  print(algisassociative(al));
  print(algiscommutative(al));
  print(algdim(al) == #algsimpledec(al)[2]);
);}
{forprime(p=5,30,
  print("D",2*p);
  al = alggroupcenter(D2n(p));
  print(algdim(al) == conjD2n(p));
  print(algdim(al) > #algsimpledec(al)[2]);
);}
alggroupcenter(Sn(3),0);

\\ #2525
testdec(al,dec) =
{
  my(quo,proj,lif,z,e);
  z = algrandom(al,5);
  print("testing decomposition.");
  for(i=1,#dec,
    [quo,proj,lif] = dec[i];
    if(proj*algsqr(al,z) != algsqr(quo,proj*z), print("not alg hom: i=", i););
    if(proj*lif != matid(algdim(quo)),
      print("map is not a lift of proj: i=",i)
    );
    e = lif*vectorv(algdim(quo),j,j==1);
    if(algsqr(al,e)!=e, print("lift of 1 is not an idempotent: i=", i););
  );
};

\\Bill: random slow cases
G=galoisinit(x^24-24*x^22+253*x^20-1540*x^18+5984*x^16-15488*x^14+27026*x^12-31448*x^10+23540*x^8-10528*x^6+2416*x^4-192*x^2+1);
al = alggroup(G);
setrand(2); dec=algsimpledec(al,1)[2]; testdec(al,dec);
setrand(8690); dec=algsimpledec(al,1)[2]; testdec(al,dec);
setrand(1294); dec=algsimpledec(al,1)[2]; testdec(al,dec);



\\bad inputs
alggroupcenter(['x,'y]);
alggroupcenter('x,1); \\Bill's bug
alggroup("a");
alggroup(["a"]);
alggroup(["a", "b", "c"]);
alggroup([Vecsmall([1]), Vecsmall([1,2]), Vecsmall([1,2,3])]);
alggroup([Vecsmall([1]), Vecsmall([2,3]), Vecsmall([1,2,3])]);


