May 11, 2021
R Code for GF(27)

The links below give the addition and multiplication tables, and code snippets to implement, for several p,n for Galois fields GF(p^n).

qinfo - data frame to hold all information for specified Galois field
qinfo$inverses - multiplicative inverses (ordered, starting with 1)
qinfo$ainverses - additive inverses (ordered, starting with 0)
qinfo$fqadd - matrix for addition table
qinfo$fqmul - matrix for multiplication table

if (q == 27) {
# generator: x^3 + 2x^2 + 1 (irreducible) ==> x^3 = x^2 + 2
qinfo$inverses =
c(01,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,09,08,07,06,05,04,03,02)
qinfo$ainverses=
c(00,14,15,16,17,18,19,20,21,22,23,24,25,26,01,02,03,04,05,06,07,08,09,10,11,12,13)
qinfo$fqadd=
matrix(c(
00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,
01,14,10,22,02,19,18,12,05,16,04,07,11,03,00,17,25,23,21,08,24,06,13,15,25,20,09,
02,10,15,11,23,03,20,19,13,06,17,05,08,12,04,00,18,26,24,22,09,25,07,14,16,26,21,
03,22,11,16,12,24,04,21,20,14,07,18,06,09,13,05,00,19,01,25,23,10,26,08,15,17,01,
04,02,23,12,17,13,25,05,22,21,15,08,19,07,10,14,06,00,20,02,26,24,11,01,09,16,18,
05,19,03,24,13,18,14,26,06,23,22,16,09,20,08,11,15,07,00,21,03,01,25,12,02,10,17,
06,18,20,04,25,14,19,15,01,07,24,23,17,10,21,09,12,16,08,00,22,04,02,26,13,03,11,
07,12,19,21,05,26,15,20,16,02,08,25,24,18,11,22,10,13,17,09,00,23,05,03,01,14,04,
08,05,13,20,22,06,01,16,21,17,03,09,26,25,19,12,23,11,14,18,10,00,24,06,04,02,15,
09,16,06,14,21,23,07,02,17,22,18,04,10,01,26,20,13,24,12,15,19,11,00,25,07,05,03,
10,04,17,07,15,22,24,08,03,18,23,19,05,11,02,01,21,14,25,13,16,20,12,00,26,08,06,
11,07,05,18,08,16,23,25,09,04,19,24,20,06,12,03,02,22,15,26,14,17,21,13,00,01,09,
12,11,08,06,19,09,17,24,26,10,05,20,25,21,07,13,04,03,23,16,01,15,18,22,14,00,02,
13,03,12,09,07,20,10,18,25,01,11,06,21,26,22,08,14,05,04,24,17,02,16,19,23,15,00,
14,00,04,13,10,08,21,11,19,26,02,12,07,22,01,23,09,15,06,05,25,18,03,17,20,24,16,
15,17,00,05,14,11,09,22,12,20,01,03,13,08,23,02,24,10,16,07,06,26,19,04,18,21,25,
16,25,18,00,06,15,12,10,23,13,21,02,04,14,09,24,03,25,11,17,08,07,01,20,05,19,22,
17,23,26,19,00,07,16,13,11,24,14,22,03,05,15,10,25,04,26,12,18,09,08,02,21,06,20,
18,21,24,01,20,00,08,17,14,12,25,15,23,04,06,16,11,26,05,01,13,19,10,09,03,22,07,
19,08,22,25,02,21,00,09,18,15,13,26,16,24,05,07,17,12,01,06,02,14,20,11,10,04,23,
20,24,09,23,26,03,22,00,10,19,16,14,01,17,25,06,08,18,13,02,07,03,15,21,12,11,05,
21,06,25,10,24,01,04,23,00,11,20,17,15,02,18,26,07,09,19,14,03,08,04,16,22,13,12,
22,13,07,26,11,25,02,05,24,00,12,21,18,16,03,19,01,08,10,20,15,04,09,05,17,23,14,
23,15,14,08,01,12,26,03,06,25,00,13,22,19,17,04,20,02,09,11,21,16,05,10,06,18,24,
24,25,16,15,09,02,13,01,04,07,26,00,14,23,20,18,05,21,03,10,12,22,17,06,11,07,19,
25,20,26,17,16,10,03,14,02,05,08,01,00,15,24,21,19,06,22,04,11,13,23,18,07,12,08,
26,09,21,01,18,17,11,04,15,03,06,09,02,00,16,25,22,20,07,23,05,12,14,24,19,08,13
),q)
qinfo$fqmul=
matrix(c(
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,
00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,
00,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,01,
00,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,01,02,
00,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,01,02,03,
00,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,01,02,03,04,
00,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,01,02,03,04,05,
00,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,01,02,03,04,05,06,
00,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,01,02,03,04,05,06,07,
00,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,01,02,03,04,05,06,07,08,
00,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,01,02,03,04,05,06,07,08,09,
00,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,01,02,03,04,05,06,07,08,09,10,
00,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,01,02,03,04,05,06,07,08,09,10,11,
00,13,14,15,16,17,18,19,20,21,22,23,24,25,26,01,02,03,04,05,06,07,08,09,10,11,12,
00,14,15,16,17,18,19,20,21,22,23,24,25,26,01,02,03,04,05,06,07,08,09,10,11,12,13,
00,15,16,17,18,19,20,21,22,23,24,25,26,01,02,03,04,05,06,07,08,09,10,11,12,13,14,
00,16,17,18,19,20,21,22,23,24,25,26,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,
00,17,18,19,20,21,22,23,24,25,26,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,
00,18,19,20,21,22,23,24,25,26,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,
00,19,20,21,22,23,24,25,26,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,
00,20,21,22,23,24,25,26,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,
00,21,22,23,24,25,26,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,
00,22,23,24,25,26,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,
00,23,24,25,26,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,
00,24,25,26,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,
00,25,26,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,
00,26,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,
),q)
} # if (q==27)