Hauptübersicht

Klasse Poly

Klasse Poly
Polynome
Poly(list) liefert Polynom mit den Koeffizienten aus list (aufsteigend).
Die Koeffizienten müssen die Ringaxiome erfüllen,
für Division und Modulo-Operator (//, %, divmod) auch Körperaxiome,
und die Abfrage auf Gleichheit mit 0 implementieren.
Kurzform für Polynom mit Mod-Objekten:
Beispiel
Poly([Mod(1,2),Mod(0,2),Mod(1,2)])
Dafür auch Kurzschreibweise:
Poly([1,0,1,1],2)

Übersicht:

Konstruktor

Poly (coeff=[], mod=0)

Klassenmethoden (statische Methoden)

MethodeBedeutung
gcd (a,b)Größter gemeinsamer Teiler von a und b
gcdExt (a,b)Erweiterter Euklidischer Algorithmus.
irreducibles (maxDegree, mod=2)Irreduzible Polynome

Operatoren

OperatorBedeutung
x + yAddition
x / y f // g à f.__floordiv__ (g), if f is of type Poly g.__rfloordiv__(f), otherwise
divmod(x,y) divmod(f, g) à f.__divmod__(g), if f is of type Poly g.__rdivmod__(f), otherwise Returns the pair (q,r) with: f == g * q + r and: r.degree() < g.degree() or r == 0
x == y with other polynomial or ring element
x // y
x[i] f[i] returns the i-th coefficient of the polynomial.
x % y a % b à a.__mod__ (b), if f is of type Poly b.__rmod__(a), otherwise
x * y a * b à a.__mul__(b), if a is of type Poly b.__rmul__(a), otherwise
x != y with other polynomial or ring element
-x
str(x)
x >> y
x - y a - b à a.__sub__(b), if a is of type Poly b.__rsub__(a), otherwise
x / y

Objektmethoden

MethodeBedeutung
copy ()unabhängige Kopie von p
degree ()degree of the polynomial
expand (x="x")ausgeschriebenes Polynom für die Variable x
inverse (mod)Multiplikatives Inverses modulo Polynom m
isOne ()
isZero ()
normalized ()
operators ()Nur zur Dokumentation
pretty (width=0)Lesbare Darstellung des Polynoms
toDigits ()String aus Koeffizienten
value (x)Wert des Polynoms für Argument x

Konstruktor

Poly

Konstruktor

Aufruf: Poly(coeff=[], mod=0)


Klassenmethoden (statische Methoden)

gcd

gcd(a,b)

Aufruf: Poly.gcd(a,b)

Beschreibung:
Größter gemeinsamer Teiler von a und b
Berechnung mit dem Euklidischen Algorithmus


gcdExt

gcdExt(a,b)

Aufruf: Poly.gcdExt(a,b)

Beschreibung:
Erweiterter Euklidischer Algorithmus.
Gibt (d, x, y) zurück mit d == gcd(a,b) und x*a + y*b == d


irreducibles

Poly.irreducibles(maxDegree, mod=2)

Aufruf: Poly.irreducibles(maxDegree, mod=2)

Beschreibung:
Irreduzible Polynome
Rückgabewert: Liste der irreduziblen Polynome über Z[mod] bis zum Grad maxDegree


Operatoren

x + y

a.__add__(b)

Aufruf: x + y

Beschreibung:
Addition
Also operator notation: a + b
Instead of a = a + b you can write a += b.


x / y

Polynomial division with remainder (operators // und //=):

Aufruf: x / y

Beschreibung:
f // g à f.__floordiv__ (g), if f is of type Poly g.__rfloordiv__(f), otherwise


divmod(x,y)

Polynomial division with remainder. (global function divmod)

Aufruf: divmod(x,y)

Beschreibung:
divmod(f, g) à f.__divmod__(g), if f is of type Poly g.__rdivmod__(f), otherwise Returns the pair (q,r) with: f == g * q + r and: r.degree() < g.degree() or r == 0


x == y

Test for equality (operator ==)

Aufruf: x == y

Beschreibung:
with other polynomial or ring element


x // y

Aufruf: x // y


x[i]

Definition of the index operator []

Aufruf: x[i]

Beschreibung:
f[i] returns the i-th coefficient of the polynomial.


x % y

Modulo operator for polynomials (operators % und %=):

Aufruf: x % y

Beschreibung:
a % b à a.__mod__ (b), if f is of type Poly b.__rmod__(a), otherwise


x * y

Multiplication (operators * and *=):

Aufruf: x * y

Beschreibung:
a * b à a.__mul__(b), if a is of type Poly b.__rmul__(a), otherwise


x != y

Test for unequality (operator !=)

Aufruf: x != y

Beschreibung:
with other polynomial or ring element


-x

unärer Operator -

Aufruf: -x

Beschreibung:


str(x)

Object representation as string

Aufruf: str(x)

Beschreibung:


x >> y

f >> n -- Multiplication of Polynomial by x**n

Aufruf: x >> y

Beschreibung:


x - y

Subtraction (operators - and -=):

Aufruf: x - y

Beschreibung:
a - b à a.__sub__(b), if a is of type Poly b.__rsub__(a), otherwise


x / y

Aufruf: x / y


Objektmethoden

copy

p.copy()

Aufruf: self.copy()

Beschreibung:
unabhängige Kopie von p


degree

p.degree()

Aufruf: self.degree()

Beschreibung:
degree of the polynomial


expand

p.expand(x="x")

Aufruf: f.expand(x="x")

Beschreibung:
ausgeschriebenes Polynom für die Variable x


inverse

p.inverse(m)

Aufruf: self.inverse(mod)

Beschreibung:
Multiplikatives Inverses modulo Polynom m
Das Polynom mod muss teilerfremd zu p sein!


isOne

Aufruf: self.isOne()


isZero

Aufruf: self.isZero()


normalized

Dividiert das Polynom durch den höchsten Koeffizienten

Aufruf: self.normalized()


operators

Poly.operators()

Aufruf: self.operators()

Beschreibung:
Nur zur Dokumentation
Die Klasse Poly erlaubt folgende Operatoren:

Op.FunktionBeispiele
+Additiona + b; a += b
-Subtraktiona - b; a -= b
*Multiplikationa * b; a *= b
//Polynomdivision (mit Rest)a // b; a //= b
divmodDivision und Modulo simultand,m = divmod(a,b)
-unäres Minus-a
Diese Methode dient nur zur Dokumentation. Sie hat keine Wirkung.


pretty

p.pretty(width=0)

Aufruf: f.pretty(width=0)

Beschreibung:
Lesbare Darstellung des Polynoms


toDigits

p.toDigits()

Aufruf: f.toDigits()

Beschreibung:
String aus Koeffizienten
Kurzform, nur für einstellige Mod-Koeffizienten:
Verkettung der Koeffizienten-Ziffern (ohne mod-Angabe).
Höchster Koeffizient links!
Beispiel
p=Poly([1,0,1,1],2)
p.toDigits()
Ergebnis: "1101"


value

p.value(x)

Aufruf: self.value(x)

Beschreibung:
Wert des Polynoms für Argument x