Extended Euclidean Algorithm for polynomials over GF(2^m)

by

 

Implementation of the extended Euclidean algorithm for polynomials over GF(2^m)

gfeuclid(G,F,field)
function pol = gfeuclid(G,F,field)


%***************************
%*** Euclidean Algorithm ***
%***************************
%G = gfconv([1 2 3], [3 4],field)
%F = gfconv([1 2], [3 4], field)

[q,r1] = gfdeconv(G,F,field);
%r1

if not((r1(1) == -Inf) & (length(r1) == 1))
    [q,r2] = gfdeconv(F,r1,field)
    %r2
end

if not((r2(1) == -Inf)&(length(r2) == 1))
    
    [q,r3] = gfdeconv(r1,r2,field);
    %r2
    r1 = r2;
    r2 = r3;
    
    %r3
    
    while not((r3(1) == -Inf) & (length(r3) == 1))
        [q,r3] = gfdeconv(r1,r2,field);
        r1 = r2;
        r2 = r3;
    end
end
pol = r1;

Contact us