Mod
Klasse Mod
Elemente der Restklassenringe Z[m]
Mod(n, m)
liefert Element n des Restklassenrings Z[m]
Die Objekte können mit arithmetischen Operatoren verknüpft werden.
Einige Operationen sind nur definiert,
wenn Z[m] ein Körper ist (<==> m ist Primzahl)
Siehe auch Mod
Übersicht:
Mod (n, m)
Operator | Bedeutung |
abs(x) | |
x + y | Addition |
x / y | |
x == y | with other Mod object or 0 |
int(x) | |
x * y | a * b à a.__mul__(b), if a is of type Mod b.__rmul__(a), otherwise |
x != y | with other Mod object or 0 |
-x | -a à a.__neg__() |
str(x) | |
x - y | a - b à a.__sub__(b), if a is of type Mod b.__rsub__(a), otherwise |
x / y | a / b à a.__div__(b), if a is of type Mod b.__rdiv__(a), otherwise |
Methode | Bedeutung |
copy () | unabhängige Kopie von A |
inverse () | Multiplikatives Inverses |
operators () | Nur zur Dokumentation |
Konstruktor
Aufruf: Mod(n, m)
Absolute value
Aufruf: abs(x)
Beschreibung:
a.__add__(b)
Aufruf: x + y
Beschreibung:
Addition
Also operator notation: a + b
Instead of a = a + b
you can write a += b
.
Aufruf:
Aufruf: x / y
Test for equality (operator ==)
Aufruf: x == y
Beschreibung:
with other Mod object or 0
Aufruf: int(x)
Multiplication:
Aufruf: x * y
Beschreibung:
a * b à a.__mul__(b), if a is of type Mod
b.__rmul__(a), otherwise
Test for unequality (Operator !=)
Aufruf: x != y
Beschreibung:
with other Mod object or 0
Unary Operator -
Aufruf: -x
Beschreibung:
-a à a.__neg__()
Object representation as string
Aufruf: str(x)
Beschreibung:
Subtraction:
Aufruf: x - y
Beschreibung:
a - b à a.__sub__(b), if a is of type Mod
b.__rsub__(a), otherwise
exact division:
Aufruf: x / y
Beschreibung:
a / b à a.__div__(b), if a is of type Mod
b.__rdiv__(a), otherwise
A.copy()
Aufruf: self.copy()
Beschreibung:
unabhängige Kopie von A
p.inverse()
Aufruf: self.inverse()
Beschreibung:
Multiplikatives Inverses
Nur in Körpern definiert. Deshalb muss der Modul Primzahl sein!
Mod.operators()
Aufruf: self.operators()
Beschreibung:
Nur zur Dokumentation
Die Klasse Mod erlaubt folgende Operatoren:
Op. | Funktion | Beispiele |
---|---|---|
+ | Addition | a + b; a += b |
- | Subtraktion | a - b; a -= b |
* | Multiplikation | a * b; a *= b |
/ | Division (nur in Körpern, d.h. Primzahlmodul) | a / b; a /= b |
% | Modulo (nur in Körpern, d.h. Primzahlmodul) | a & b; a &= b |
- | unäres Minus | -a |