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(mult: ~collections.abc.Callable[[H, H], H], add: ~collections.abc.Callable[[H, H], H], one: H, zero: H, negate: ~collections.abc.Callable[[H], H], invert: ~collections.abc.Callable[[H], H], process: ~collections.abc.Callable[[H], H] = <function Field.<lambda>>)
Parameters:
  • add – Closed commutative and associative function reps.

  • mult – Closed 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.

__init__(mult: ~collections.abc.Callable[[H, H], H], add: ~collections.abc.Callable[[H, H], H], one: H, zero: H, negate: ~collections.abc.Callable[[H], H], invert: ~collections.abc.Callable[[H], H], process: ~collections.abc.Callable[[H], H] = <function Field.<lambda>>)
Parameters:
  • add – Closed commutative and associative function reps.

  • mult – Closed 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.

__call__(rep: H) FieldElement

Add the unique element to the ring with a given rep.

Parameters:

rep – Representation to add if not already present.

Returns:

The unique element with that representation.

class boring_math.abstract_algebra.algebras.field.FieldElement(rep: H, algebra: Field[H])
__init__(rep: H, algebra: Field[H]) None
__str__() str

Return str(self).

__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 is not mult invertible.