Interface Semiring<E>

All Superinterfaces:
AbelianMonoid<E>, Magma<E>, Monoid<E>, Set<E>
All Known Subinterfaces:
Algebra<E,F>, BanachAlgebra<E,F>, CStarAlgebra<E,F>, DivisionRing<E>, Field<E>, GradedAlgebra<E,F>, KleeneAlgebra<E>, LieAlgebra<E,S>, Matrix<E>, Ring<E>
All Known Implementing Classes:
Boolean, BooleanAlgebra, Booleans, CliffordAlgebra, Complex, Complexes, DenseMatrix, DoubleField, GenericMatrix, Integer, Integers, MatrixLieAlgebra, MMapMatrix, NativeRealBig, NativeRealDoubleMatrix, NativeRealFloatMatrix, Natural, Naturals, Octonion, Octonions, PolynomialRing, Quaternion, Quaternions, Rational, Rationals, Real, RealBig, RealDouble, RealDoubleMatrix, RealFloat, Reals, SIMDRealDoubleMatrix, SIMDRealFloatMatrix, SparseMatrix, SquareMatrices, TiledMatrix

public interface Semiring<E> extends AbelianMonoid<E>
A semiring (or rig) is an algebraic structure similar to a ring, but without the requirement that each element must have an additive inverse.

A semiring (R, +, ×) consists of:

  • (R, +) is a commutative monoid with identity element 0.
  • (R, ×) is a monoid with identity element 1.
  • Multiplication distributes over addition.
  • Multiplication by 0 annihilates R: 0 × a = a × 0 = 0.

The term "rig" is a pun on "ring": a ring without "n" (negative).

Examples

  • (â„•, +, ×) - Natural numbers (including 0)
  • (Boolean Algebra, ∨, ∧) - Booleans with OR as addition, AND as multiplication
  • (Languages, ∪, ·) - Formal languages with union and concatenation
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Method Details

    • multiply

      E multiply(E a, E b)
      Returns the product of two elements.

      Multiplication must be associative and distribute over addition.

      Parameters:
      a - the first factor
      b - the second factor
      Returns:
      a × b
    • one

      E one()
      Returns the multiplicative identity (one element).

      Satisfies: 1 × a = a × 1 = a for all elements a.

      Returns:
      the multiplicative identity
    • isMultiplicationCommutative

      boolean isMultiplicationCommutative()
      Tests whether multiplication is commutative in this semiring.
      Returns:
      true if multiplication commutes
    • pow

      default E pow(E element, int n)
      Returns the nth power of an element.
      Parameters:
      element - the base
      n - the exponent (must be non-negative)
      Returns:
      element^n