field

Field

Field

Mathematically a Field is a Commutative Ring all whose non-zero elements have multiplicative inverses.

By convention one != zero, otherwise the algebra consists of just one unique element.

Important

Contract: Field initializer parameters must have

  • add closed, commutative and associative on reps

  • mult closed, commutative and associative on reps

  • one an identity on reps, rep*one == rep == one*rep

  • zero an identity on reps, rep+zero == rep == zero+rep

  • inv is the mult inverse function on all non-zero reps

  • negate function to negate all proper rep values

  • invert function to invert all proper rep values

  • zero != one (by convention)

class boring_math.abstract_algebra.algebras.field.Field

Bases: CommutativeRing, Generic

__init__(mult: Callable[[H, H], H], add: Callable[[H, H], H], one: H, zero: H, negate: Callable[[H], H], invert: Callable[[H], H], narrow: Callable[[H], H] | None = None)

init

param mult:

Closed associative function reps.

param add:

Closed commutative and associative function reps.

param one:

Representation for multiplicative identity.

param zero:

Representation for additive identity.

param negate:

Function mapping element representation to the representation of corresponding negated element.

param invert:

Function mapping non-zero element representations to their multiplicative inverses.

param narrow:

Narrow the rep type, many to one function, like choosing an element from a coset of a group,

class boring_math.abstract_algebra.algebras.field.FieldElement

Bases: CommutativeRingElement, Generic

__init__(rep: H, algebra: Field[H]) → None

init

param rep:

Coset element to be narrowed.

param algebra:

Abelian group to which element belongs.

__str__() → str

user string

Construct the string ‘FieldElement<rep_str>’ where rep_str = str(rep).

returns:

A string meaningful to an end user.

__pow__(n: int) → Self

pow

Raise the element to the integer power of n.

param n:

The integer power to raise the element to.

returns:

The element (or its inverse) raised to the power of n.

raises ValueError:

If algebra is not multiplicative.

raises ValueError:

If algebra does not have a multiplicative identity element.

raises ValueError:

If algebra does not have multiplicative inverses.

__truediv__(right: Self) → Self

Divide self by right.