load "mat_subgroups_of_small_degree.m";

FindDifferent := function (S)

    if #S eq 0 then return S; end if;

    Different := [ S[1] ];

    for i in [2..#S] do
      j := 1; new := true;
      repeat
          new := not (IsGLConjugate (S[i], Different [j]));
          j := j + 1;
      until (new eq false) or (j gt #Different);
      if new then Append (~Different, S[i]); else "i, j, new is ", i, j-1, new;
end if;
    end for;

    return Different;
end function;

testGL:= function(p,a)
	X:=getInsolubleMatrixGroupsOfDimThreeOverGL(p,a);
	Y:= &cat(X);
	Z:=FindDifferent(Y);
	return "search ended for " cat IntegerToString(p^a);
end function;

testSL:= function(p,a)
	X:=getInsolubleMatrixGroupsOfDimThreeOverSL(p,a);
	Y:= &cat(X);
	Z:=FindDifferent(Y);
	return true;
end function;

procedure testListGL(L)
	for x in L do
		print "Testing for p^a = " cat IntegerToString(x[1]) cat "^" cat IntegerToString(x[2]) cat ":";
		testGL(x[1],x[2]);
	end for;
end procedure;

procedure testListSL(L)
	for x in L do
		print "Testing for p^a = " cat IntegerToString(x[1]) cat "^" cat IntegerToString(x[2]) cat ":";
		testSL(x[1],x[2]);
	end for;
end procedure;

procedure testPrimesGL(q,a)
	L:= [[p,a] : p in PrimesInInterval(1,q)];
	testListGL(L);
end procedure;

procedure testPrimePowersGL(n)
	L:= [[p,a] : p in PrimesInInterval(1,n), a in [1..Floor(Log(2,n))] | p^a le n];
	testListGL(L);
end procedure;

procedure testPrimePowerRangeGL(n1,n2)
	L:= [[p,a] : p in PrimesInInterval(1,n2), a in [1..Floor(Log(2,n2))] | p^a le n2 and p^a ge n1];
	testListGL(L);
end procedure;

procedure testPrimePowersSL(n)
	L:= [[p,a] : p in PrimesInInterval(1,n), a in [1..Floor(Log(2,n))] | p^a le n];
	testListSL(L);
end procedure;