I am working with Galois field. I obtained all the 256 values, and now i want to make the matrix form of the obtained values.

4 次查看(过去 30 天)
clear all;
close all;
clc;
m = 8;
p = 2;
prim_poly = p^8+p^6+p^5+p^1+p^0;
a = gf(35, m, prim_poly);
b = gf(15, m, prim_poly);
c = gf(0, m, prim_poly);
d = gf(5, m, prim_poly);
x_gf = gf([a b; c d] , m , prim_poly);
determinant = det(gf(x_gf, m, prim_poly));
% Check singularity
if determinant == 0
disp('The linear fractional transformation is singular.');
else
disp('The linear fractional transformation is not singular.');
end
%s = zeros(1,256);
for x_gf = 0:255
e = conv(a, x_gf);
f = conv(c, x_gf);
h = e + b;
j = f + d;
i = gf(1./j, m, prim_poly);
results = gf(conv(h, i),m, prim_poly)
end

回答(2 个)

Fangjun Jiang
Fangjun Jiang 2023-8-30
results = zeros(1,256);
for x_gf = 0:255
e = conv(a, x_gf);
f = conv(c, x_gf);
h = e + b;
j = f + d;
i = gf(1./j, m, prim_poly);
results(x_gf+1) = gf(conv(h, i),m, prim_poly)
end
  1 个评论
Voss
Voss 2023-8-30
clear all;
close all;
clc;
m = 8;
p = 2;
prim_poly = p^8+p^6+p^5+p^1+p^0;
a = gf(35, m, prim_poly);
b = gf(15, m, prim_poly);
c = gf(0, m, prim_poly);
d = gf(5, m, prim_poly);
x_gf = gf([a b; c d] , m , prim_poly);
determinant = det(gf(x_gf, m, prim_poly));
Warning: Lookup tables not defined for this order 2^8 and
primitive polynomial 355. Arithmetic still works
correctly but multiplication, exponentiation, and
inversion of elements is faster with lookup tables.
Use gftable to create and save the lookup tables.
% Check singularity
if determinant == 0
disp('The linear fractional transformation is singular.');
else
disp('The linear fractional transformation is not singular.');
end
The linear fractional transformation is not singular.
%s = zeros(1,256);
results = zeros(1,256);
for x_gf = 0:255
e = conv(a, x_gf);
f = conv(c, x_gf);
h = e + b;
j = f + d;
i = gf(1./j, m, prim_poly);
results(x_gf+1) = gf(conv(h, i),m, prim_poly)
end
Unable to perform assignment because value of type 'gf' is not convertible to 'double'.

Caused by:
Error using double
Conversion to double from gf is not possible.

请先登录,再进行评论。


Voss
Voss 2023-8-30
clear all;
close all;
clc;
m = 8;
p = 2;
prim_poly = p^8+p^6+p^5+p^1+p^0;
a = gf(35, m, prim_poly);
b = gf(15, m, prim_poly);
c = gf(0, m, prim_poly);
d = gf(5, m, prim_poly);
x_gf = gf([a b; c d] , m , prim_poly);
determinant = det(gf(x_gf, m, prim_poly));
Warning: Lookup tables not defined for this order 2^8 and
primitive polynomial 355. Arithmetic still works
correctly but multiplication, exponentiation, and
inversion of elements is faster with lookup tables.
Use gftable to create and save the lookup tables.
% Check singularity
if determinant == 0
disp('The linear fractional transformation is singular.');
else
disp('The linear fractional transformation is not singular.');
end
The linear fractional transformation is not singular.
%s = zeros(1,256);
results = cell(1,256);
for x_gf = 0:255
e = conv(a, x_gf);
f = conv(c, x_gf);
h = e + b;
j = f + d;
i = gf(1./j, m, prim_poly);
results{x_gf+1} = gf(conv(h, i),m, prim_poly);
end
disp(results);
Columns 1 through 16 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 17 through 32 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 33 through 48 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 49 through 64 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 65 through 80 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 81 through 96 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 97 through 112 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 113 through 128 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 129 through 144 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 145 through 160 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 161 through 176 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 177 through 192 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 193 through 208 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 209 through 224 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 225 through 240 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} Columns 241 through 256 {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf} {1×1 gf}
results{1}
ans = GF(2^8) array. Primitive polynomial = D^8+D^6+D^5+D+1 (355 decimal) Array elements = 3
results{2}
ans = GF(2^8) array. Primitive polynomial = D^8+D^6+D^5+D+1 (355 decimal) Array elements = 67

类别

Help CenterFile Exchange 中查找有关 Model References 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by