Skip to content

Instantly share code, notes, and snippets.

@fujidig
Last active February 5, 2016 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fujidig/7ae6aa7a4244a5332194 to your computer and use it in GitHub Desktop.
Save fujidig/7ae6aa7a4244a5332194 to your computer and use it in GitHub Desktop.
\\ determine that order of g equals to n
isprimitive(g, n, e=1) = {
my(factors, p);
if (g^n != e, return(0));
factors = factor(n);
for (i = 1, matsize(factors)[1],
p = factors[i, 1];
if (g^(n/p) == e, return(0)));
return(1);
}
\\ identity matrix
E = matid;
\\ right & left shift matrix
R(n, k) = { return(matrix(n, n, i, j, i + k == j)); }
L(n, k) = { return(R(n, -k)); }
\\ convert to matrix on F_2
to_f2(mat) = { return(matrix(matsize(mat)[1], matsize(mat)[2], i, j, Mod(mat[i, j], 2))); }
n = 64;
T = to_f2((E(n) + L(n, 17)) * (E(n) + R(n, 7)) * (E(n) + L(n, 13)));
print(isprimitive(Mod(x, charpoly(T, x)), 2^n - 1));
@fujidig
Copy link
Author

fujidig commented Feb 4, 2016

Thanks. I understood. I fixed it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment