以有限域GF(2)为例,假设矩阵a是有限域GF(2)上的矩阵
a =
1 0 1 1 0 1 1 1
1 1 0 1 1 0 1 1
1 1 1 0 1 1 0 1
0 1 1 1 1 1 1 0
1 1 0 0 0 1 1 1
0 1 1 0 1 0 1 1
0 0 1 1 1 1 0 1
1 0 0 1 1 1 1 0
首先,运行命令b=gf(a,2)
>> b=gf(a,2)
b = GF(2^2) array. Primitive polynomial = D^2+D+1 (7 decimal)
Array elements =
Columns 1 through 8
1 0 1 1 0 1 1 1
1 1 0 1 1 0 1 1
1 1 1 0 1 1 0 1
0 1 1 1 1 1 1 0
1 1 0 0 0 1 1 1
0 1 1 0 1 0 1 1
0 0 1 1 1 1 0 1
1 0 0 1 1 1 1 0
然后运行命令c=inv(b)
>> c=inv(b)
c = GF(2^2) array. Primitive polynomial = D^2+D+1 (7 decimal)
Array elements =
Columns 1 through 6
0 1 1 1 0 1 1 1
1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1
1 1 1 0 1 1 1 0
1 1 0 0 1 0 1 1
0 1 1 0 1 1 0 1
0 0 1 1 1 1 1 0
1 0 0 1 0 1 1 1
c即为a在有限域GF(2)上的逆矩阵。
验证:
>> a*c
ans = GF(2^2) array. Primitive polynomial = D^2+D+1 (7 decimal)
Array elements =
Columns 1 through 6
1 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1
0 0 0 0 0 0
0 0 0 0 0 0
Columns 7 through 8
0 0
0 0
0 0
0 0
0 0
0 0
1 0
0 1