# Class ModuloPolynomialField<R extends Field<R>>

java.lang.Object
org.apfloat.jscience.ModuloPolynomialField<R>

Type Parameters:
  `R` - The type of the polynomial coefficients.

All Implemented Interfaces:
  `Serializable, Immutable, Realtime, ValueType, Field<ModuloPolynomialField<R>>, GroupAdditive<ModuloPolynomialField<R>>, GroupMultiplicative<ModuloPolynomialField<R>>, Ring<ModuloPolynomialField<R>>, Structure<ModuloPolynomialField<R>>`

public class ModuloPolynomialField<R extends Field<R>> extends Object implements Field<ModuloPolynomialField<R>>, Serializable, Realtime
This class represents a polynomial modulo a modulus. The modulus must be set with `setModulus(Polynomial)`; otherwise the modulo reduction is not done.

For the polynomials to actually form a field, the modulus must be irreducible over the coefficient field. Otherwise it's just a `Ring` and the multiplicative `inverse()` method may fail.

Since:
  1.15.0
Version:
  1.15.0
Author:
  Mikko Tommila
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ModuloPolynomialField(Polynomial<R> polynomial)`
  Create a new modulo polynomial.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `copy()`
  `boolean`
  `equals(Object obj)`
  `static <R extends Field<R>>
  Polynomial<R>`
  `getModulus()`
  Returns the modulus or `null` if modulo reduction is not done.
  `int`
  `hashCode()`
  `ModuloPolynomialField<R>`
  `inverse()`
  `ModuloPolynomialField<R>`
  `minus(ModuloPolynomialField<R> that)`
  Returns the difference of two polynomials.
  `ModuloPolynomialField<R>`
  `opposite()`
  `ModuloPolynomialField<R>`
  `plus(ModuloPolynomialField<R> that)`
  `static <R extends Field<R>>
  Polynomial<R>`
  `reduce(Polynomial<R> polynomial)`
  Reduce the polynomial with the current modulus.
  `static <R extends Field<R>>
  void`
  `setModulus(Polynomial<R> modulus)`
  Sets the modulus.
  `ModuloPolynomialField<R>`
  `times(ModuloPolynomialField<R> that)`
  `String`
  `toString()`
  `Text`
  `toText()`
  `Polynomial<R>`
  `value()`
  Returns the underlying polynomial.

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### ModuloPolynomialField

    public ModuloPolynomialField(Polynomial<R> polynomial)
    Create a new modulo polynomial.
    Parameters:
      `polynomial` - The polynomial. Will be reduced by the modulus, if any.

- ## Method Details

  - ### getModulus

    public static <R extends Field<R>> Polynomial<R> getModulus()
    Returns the modulus or `null` if modulo reduction is not done. The modulus can be set in a thread-specific way using `LocalContext`.
    Type Parameters:
      `R` - The type of the polynomial coefficients.
    Returns:
      The local modulus or `null` if modulo reduction is not done.
    See Also:
      - `setModulus(Polynomial)`

  - ### setModulus

    public static <R extends Field<R>> void setModulus(Polynomial<R> modulus)
    Sets the modulus. The modulus can be set in a thread-specific way using `LocalContext`.
    Type Parameters:
      `R` - The type of the polynomial coefficients.
    Parameters:
      `modulus` - The modulus or `null` if modulo reduction is not done.

  - ### reduce

    public static <R extends Field<R>> Polynomial<R> reduce(Polynomial<R> polynomial)
    Reduce the polynomial with the current modulus.
    Type Parameters:
      `R` - The type of the polynomial coefficients.
    Parameters:
      `polynomial` - The polynomial.
    Returns:
      The polynomial mod the current modulus.

  - ### plus

    public ModuloPolynomialField<R> plus(ModuloPolynomialField<R> that)
    Specified by:
      `plus` in interface `GroupAdditive<R extends Field<R>>`

  - ### minus

    public ModuloPolynomialField<R> minus(ModuloPolynomialField<R> that)
    Returns the difference of two polynomials.
    Parameters:
      `that` - The polynomial being subtracted.
    Returns:
      `this - that`

  - ### opposite

    public ModuloPolynomialField<R> opposite()
    Specified by:
      `opposite` in interface `GroupAdditive<R extends Field<R>>`

  - ### times

    public ModuloPolynomialField<R> times(ModuloPolynomialField<R> that)
    Specified by:
      `times` in interface `GroupMultiplicative<R extends Field<R>>`
    Specified by:
      `times` in interface `Ring<R extends Field<R>>`

  - ### inverse

    public ModuloPolynomialField<R> inverse()
    Specified by:
      `inverse` in interface `GroupMultiplicative<R extends Field<R>>`

  - ### value

    public Polynomial<R> value()
    Returns the underlying polynomial.
    Returns:
      The polynomial.

  - ### copy

    public Object copy()
    Specified by:
      `copy` in interface `ValueType`

  - ### toText

    public Text toText()
    Specified by:
      `toText` in interface `Realtime`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`