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)
Parameters:
  • mult – Closed associative function reps.

  • add – Closed commutative and associative function reps.

  • one – Representation for multiplicative identity.

  • zero – Representation for additive identity.

  • negate – Function mapping element representation to the representation of corresponding negated element.

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

  • 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
__str__() → str
Returns:

str(self) = FieldElement<rep>

__pow__(n: int) → Self

Raise the element to the int power of n.

Parameters:

n – The int power to raise the element to.

Returns:

The element (or its inverse) raised to an int power.

Raises:
  • ValueError – If algebra is not multiplicative.

  • ValueError – If algebra does not have a multiplicative identity element.

  • ValueError – If algebra does not have multiplicative inverses.

__truediv__(right: Self) → Self

Divide self by right.