Understanding SAGE code

asked 2022-04-19 10:23:12 +0100

osunde gravatar image

updated 2022-04-19 17:48:37 +0100

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!

edit retag flag offensive close merge delete

Comments

Where do you get 0x7f7467c66450 from? It is too large to correspond to an element of the field F.

rburing gravatar imagerburing ( 2022-04-19 14:13:41 +0100 )edit

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 polynomial X^4 + X^3 + 1 as its modulus; look at GF? to read the help string for GF. Once you've defined F, look at F.fetch_int? to read the help string for that.

John Palmieri gravatar imageJohn Palmieri ( 2022-04-19 17:56:52 +0100 )edit