Understanding SAGE code
Hey, I want to implement a functionality I found in sage math code into my matlab code, to do so I need to understand what is happening which I really dont, could someone ellaborate and explain the steps? X is apparently creating a GF2 which gives the output x that is in F2 while F is a definition of the X^4+X^3+1? And F_mul somehow ends up with this 0x7f7467c66450 And that I cannot really understand
X = GF(2).polynomial_ring().gen()
F = GF(2**4, name="a", modulus=X**4+X**3+1)
def F_mult(x, y):
return (F.fetch_int(x) * F.fetch_int(y)).integer_representation()
Thanks a bunch!
Where do you get
0x7f7467c66450
from? It is too large to correspond to an element of the fieldF
.X
is the generator of a polynomial ring with coefficients in the field F_2. The field F (of size 2^4) is defined using the particular polynomialX^4 + X^3 + 1
as its modulus; look atGF?
to read the help string forGF
. Once you've definedF
, look atF.fetch_int?
to read the help string for that.