ring¶
Ring
Mathematically a Ring is an abelian group under addition and a
Monoid under multiplication. The additive and multiplicative
identities are denoted one and zero respectfully.
By convention one != zero, otherwise the algebra consists
of just one unique element.
Important
Contract: Ring initializer parameters must have
add closed, commutative and associative on reps
mult closed and associative on reps
one an identity on reps,
rep*one == rep == one*repzero an identity on reps,
rep+zero == rep == zero+repnegate maps
rep -> -rep,rep + negate(rep) == zerozero
!=one
- class boring_math.abstract_algebra.algebras.ring.Ring(add: ~collections.abc.Callable[[H, H], H], mult: ~collections.abc.Callable[[H, H], H], one: H, zero: H, negate: ~collections.abc.Callable[[H], H], process: ~collections.abc.Callable[[H], H] = <function Ring.<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.
- __init__(add: ~collections.abc.Callable[[H, H], H], mult: ~collections.abc.Callable[[H, H], H], one: H, zero: H, negate: ~collections.abc.Callable[[H], H], process: ~collections.abc.Callable[[H], H] = <function Ring.<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.
- __call__(rep: H) RingElement¶
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.ring.RingElement(rep: H, algebra: Ring[H])¶
-
- __str__() str¶
Return str(self).
- __mul__(other: object) Self¶
Multiplication
*operator.Multiplying element by an integer
n>=0is repeated addition.Algebra mult if
otheris a member of the same concrete algebra.Otherwise return
NotImplemented(for a right action)
- Parameters:
other – Add element to itself
n >= 0times.- Returns:
The sum of the element n times.
- Raises:
ValueError – if given an element instead of an
int.ValueError – If add method was not defined on the algebra.
- __rmul__(other: object) Self¶
When left side of multiplication does not know how to multiply right side.
Multiplying element by an integer
n>=0is repeated addition.If
othernot member of same concrete algebra or left mult would of worked.Otherwise return
NotImplemented(for a left action)
- __pow__(n: int) Self¶
Raise element to power to the
intpower ofn>=0.- Parameters:
n – The
intpower to raise the element to.- Returns:
The element raised to a non-negative
intpower.- Raises:
ValueError – If algebra is not multiplicative.
ValueError – If algebra does not have a multiplicative identity element.
ValueError – If
n < 0.