Aufgabe 4: (Python-Klasse Poly zum Rechnen im Erweiterungskörper 𝔽2m)
Schreiben Sie eine Klasse Poly in folgender Weise:
class Poly(list):
def __init__(self, lst):
if len(lst)<Poly.m:
lst=[0]*(Poly.m-len(lst))+lst
self[:]=lst
@staticmethod
def zero():
return Poly([])
@staticmethod
def one():
return Poly([1])
def __add__(self, other):
def mulx(self):
def __mul__(self, other):
if __name__ == "__main__":
Poly.m=4
Poly.z=Poly([0,0,1,1])
p=Poly([0,1,0,1])
q=Poly([1,1,0,1])
r=p+q
print(r)
assert r==[1,0,0,0]
r=p*q
print(r)
assert r==[1,1,0,0]