0

Here is a working pari/gp implementation of my variation of AKS test (see here). Problem is that my code is extremely slow. Is there something that I could change in code to achieve a better running time?
xmat(r,n,a) = [2*x, a; 1, 0]*Mod(1,x^r-1)*Mod(1,n);
AKSv2(n)={
if(!(ispower(n)==0),print("C...