Main Overview

Class Mod

Class Mod
Elements of the residue class rings Z[m]
Mod(n, m) returns element n des of the residue class ring Z[m]
Arithmetic operators may be applied to the objects.
Some operations are defined only, if Z[m] is a field (<==> m is prime number)
See also Mod

Overview:

Constructor

Mod (n, m)

Operators

OperatorMeaning
abs(x)
x + yAddition
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

Object Methods

MethodMeaning
copy ()independent copy ("clone") of A
inverse ()Multiplicative inverse
operators ()For documentation only

Constructor

Mod

Constructor

Usage: Mod(n, m)


Operators

abs(x)

Absolute value

Usage: abs(x)

Description:


x + y

a.__add__(b)

Usage: x + y

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


Usage:


x / y

Usage: x / y


x == y

Test for equality (operator ==)

Usage: x == y

Description:
with other Mod object or 0


int(x)

Usage: int(x)


x * y

Multiplication:

Usage: x * y

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


x != y

Test for unequality (Operator !=)

Usage: x != y

Description:
with other Mod object or 0


-x

Unary Operator -

Usage: -x

Description:
-a à a.__neg__()


str(x)

Object representation as string

Usage: str(x)

Description:


x - y

Subtraction:

Usage: x - y

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


x / y

exact division:

Usage: x / y

Description:
a / b à a.__div__(b), if a is of type Mod b.__rdiv__(a), otherwise


Object Methods

copy

A.copy()

Usage: self.copy()

Description:
independent copy ("clone") of A


inverse

p.inverse()

Usage: self.inverse()

Description:
Multiplicative inverse
defined in fields only. Therefore modulus must be prime number!


operators

Mod.operators()

Usage: self.operators()

Description:
For documentation only
The following operators are defined in the class Mod:

Op.FunctionExamples
+Additiona + b; a += b
-Subtractiona - b; a -= b
*Multiplicationa * b; a *= b
/Divisiona / b; a /= b
%Modulo (in fields only , i.e. modulus is prime)a & b; a &= b
-Unary minus-a
This method is for documentation only. It has no effect.