Rozwiązanie zadania "Ilorazy pierścienia wielomianów" #35

Closed
s426211 wants to merge 15 commits from (deleted):zad4 into master
Showing only changes of commit 272a361fb2 - Show all commits

25
main.py
View File

@ -270,12 +270,12 @@ class PolyIntField:
nilpotents = [] nilpotents = []
for e in self.elements: for e in self.elements:
if not e.is_empty(): for n in range(1, self.int_modulo):
for f in self.elements: if ((e ** n) % self.poly_modulo).elements == {}:
if not f.is_empty(): nilpotents.append(list(reversed(list(e.elements.values()))))
if (e ** f) % self.poly_modulo == e: break
nilpotents.append(e)
nilpotents[nilpotents.index([])] = [0]
return nilpotents return nilpotents
def idempotents(self): def idempotents(self):
@ -304,22 +304,21 @@ class PolyIntField:
str_form = "[\n\t" str_form = "[\n\t"
str_form += str([]) + "\n\t" str_form += str([]) + "\n\t"
str_form += str([]) + "\n\t" str_form += str([]) + "\n\t"
str_form += str([]) + "\n\t" str_form += str(self.nilpotents()) + "\n\t"
str_form += str(self.idempotents()) + "\n" str_form += str(self.idempotents()) + "\n"
str_form += "]\n" str_form += "]\n"
return str_form return str_form
if __name__ == "__main__": if __name__ == "__main__":
pf = PolyIntField(2, [1, 1, 1])
print(pf)
poly_field = PolyIntField(3, [1, 1, 2, 2]) poly_field = PolyIntField(3, [1, 1, 2, 2])
print(poly_field) print(poly_field)
# x = poly_field.idempotents() # print(poly_field)
# for e in x:
# print(e)
#
# print()
pf = PolyIntField(2, [1, 1, 1])
print(pf)
# y = pf.idempotents() # y = pf.idempotents()
# for i in y: # for i in y:
# print(i) # print(i)