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 1a958042e1 - Show all commits

152
main.py
View File

@ -289,22 +289,24 @@ class PolyIntField:
return idempotents
def zero_divisors(self):
zero_divisors = []
zero_divisors = [[0]]
for e in self.elements:
if not e.is_empty():
for f in self.elements:
if not f.is_empty():
if Poly.gcd((e * f), self.poly_modulo).is_empty():
zero_divisors.append(e)
if (e * f % self.poly_modulo).elements == {}:
zero_divisors.append(
list(reversed(list(e.elements.values()))))
break
return zero_divisors
def __str__(self):
str_form = "[\n\t"
str_form += str([]) + "\n\t"
str_form += str([]) + "\n\t"
str_form += str(self.nilpotents()) + "\n\t"
str_form += str([]) + ",\n\t"
str_form += str(self.zero_divisors()) + ",\n\t"
str_form += str(self.nilpotents()) + ",\n\t"
str_form += str(self.idempotents()) + "\n"
str_form += "]\n"
return str_form
@ -312,146 +314,8 @@ class PolyIntField:
if __name__ == "__main__":
pf = PolyIntField(2, [1, 1, 1])
print(pf)
poly_field = PolyIntField(3, [1, 1, 2, 2])
print(poly_field)
# print(poly_field)
# y = pf.idempotents()
# for i in y:
# print(i)
# y = Poly(3, [0, 1, 2])
# d = Poly(3, [1, 1, 2, 2])
# # print(y ** 2 % d)
# h = y ** 2
# print(h)
# print(h % d)
# for p in poly_field.elements:
# print(p)
# print(p.elements)
# print(len(poly_field.elements))
# a = Poly(3, [0, 0, 0])
# b = Poly(3, [1, 2])
# print((a * b).is_empty())
# x = Poly(5, [1, 0, 4, 0, 2, 1])
# y = Poly(5, [4, 0, 0, 0, 1])
# print(x % y)
# o = Poly(5, [1, 0, 1, 2, 2, 1])
# print(o)
#
# p = Poly(5, [4, 0, 0, 0, 1])
# print(p)
# print(o / p)
# n = Poly(5, [1, 0, 1])
# m = Poly(5, [2, 4])
# print(n / m)
# a = Poly(5, [1, 0, 4, 0, 2, 1, 0, 0])
# # print(a)
# b = Poly(5, [4, 0, 0, 0, 1])
# # print(b)
# # print(a + b)
# print(a % b)
# d = Poly(5, [3, 1, 4])
# # print(d)
# e = Poly(5, [4, 0, 0, 0, 1])
# # print(e)
# print(e / d)
# c = Poly(5, [4, 0, 0, 0, 1])
# d = Poly(5, [3, 1, 4, 0, 0, 0])
# print(c)
# print(d)
# print(c % d)
# e = Poly(10, [-4, 0, -2, 3])
# f = Poly(10, [-3, 1])
# print(e / f)
# print(e % f)
# print(f / e)
# print(f % e)
# print(e * f)
# print(f * e)
# print(e + f)
# print(f + e)
# print(e - f)
# print(f - e)
# print(e)
# print(f)
# print(Poly.gcd(e, f))
# a = Poly(5, [1, 0, 1, 0, 2, 1])
# b = Poly(5, [4, 0, 0, 0, 1])
# print(a)
# print(b)
# # print(Poly.gcd(a, b))
# print(a % b)
# c = a % b
# print(b % c)
# print(Poly.gcd(a, b))
# p = Poly(4, [6, 0, 8, 3])
# o = Poly(4, [7, 1])
# print(Poly.gcd(o, p))
# print(Poly.gcd(b, a))
# t = Poly(5, [1, 0, 4, 0, 2, 1])
# y = Poly(5, [4, 0, 0, 0, 1])
# print(Poly.gcd(t, y))
# print((a % b).elements)
# d = Poly(10, [2, 0, 6, 0, 1])
# e = Poly(10, [5, 0, 1])
# print(d / e)
# print(a - Poly(10, [0, 0, -3, 1]))
# p = Poly(5, [-4, 0, -2, 1])
# print(p)
# c = p * p
# print(c.elements)
# print(c)
# print(p ** 2)
# print(p)
# print(d)
# print(p)
# print(p + d)
# d = Poly(5, [-3, 1])
# g = Poly(5, [1, 2, 1])
# print(d)
# print(g)
# print()
#
# # print(g)
# print(g - d)
# print(d - g)
#
# print()
# print(d + g)
# print(g + d)
#
# print()
# print(d * g)
# print(g * d)
# print(d)
# print(g)
# print(g - d)
# print(p / d)
# print(p.elements[0])
# a = PolyIntField(3, [1, 1, 2, 2])
# for e in a.elements:
# print(e.elements)
# print()
# print(a.elements[4])
# print(a.elements[8])
# print(a.elements[4] * a.elements[8])
# a.elements[3] / a.elements[1]