# Class ModuloApintField

java.lang.Object
java.lang.Number
org.jscience.mathematics.number.Number<ModuloApintField>
org.apfloat.jscience.AbstractField<ModuloApintField, Apint>
org.apfloat.jscience.ModuloApintField

All Implemented Interfaces:
  `Serializable, Comparable<ModuloApintField>, Immutable, Realtime, ValueType, XMLSerializable, Field<ModuloApintField>, GroupAdditive<ModuloApintField>, GroupMultiplicative<ModuloApintField>, Ring<ModuloApintField>, Structure<ModuloApintField>`

public class ModuloApintField extends AbstractField<ModuloApintField, Apint>
This class represents an arbitrary precision modulo integer. The modulus must be set with `setModulus(Apint)`; otherwise the modulo reduction is not done.

For the modulo integers to actually for a field, the modulus must be prime. Otherwise it's just a `Ring` and the `inverse()` method may fail.

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

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ModuloApintField(Apint value)`
  Constructs a new integer field object with the specified value.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ModuloApintField`
  `copy()`
  Returns a copy of this object.
  `static Apint`
  `getModulus()`
  Returns the modulus or `null` if modulo reduction is not done.
  `ModuloApintField`
  `inverse()`
  Returns the multiplicative inverse of this object.
  `ModuloApintField`
  `opposite()`
  Returns the additive inverse of this object.
  `ModuloApintField`
  `plus(ModuloApintField that)`
  Returns the sum of this object with the one specified.
  `ModuloApintField`
  `pow(Apint exp)`
  Modular power.
  `static Apint`
  `reduce(Apint value)`
  Reduce the value with the current modulus.
  `static void`
  `setModulus(Apint modulus)`
  Sets the modulus.
  `ModuloApintField`
  `times(ModuloApintField that)`
  Returns the product of this object with the one specified.

  ### Methods inherited from class AbstractField

  `compareTo, doubleValue, equals, hashCode, isLargerThan, longValue, toText, value`

  ### Methods inherited from class Number

  `byteValue, floatValue, intValue, isGreaterThan, isLessThan, minus, pow, shortValue, toString`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### ModuloApintField

    public ModuloApintField(Apint value)
    Constructs a new integer field object with the specified value.
    Parameters:
      `value` - The value.

- ## Method Details

  - ### getModulus

    public static Apint getModulus()
    Returns the modulus or `null` if modulo reduction is not done. The modulus can be set in a thread-specific way using `LocalContext`.
    Returns:
      The local modulus or `null` if modulo reduction is not done.
    See Also:
      - `setModulus(Apint)`

  - ### setModulus

    public static void setModulus(Apint modulus)
    Sets the modulus. The modulus can be set in a thread-specific way using `LocalContext`.
    Parameters:
      `modulus` - The modulus or `null` if modulo reduction is not done.
    Throws:
      `IllegalArgumentException` - If `modulus` is not positive.

  - ### reduce

    public static Apint reduce(Apint value)
    Reduce the value with the current modulus.
    Parameters:
      `value` - The value.
    Returns:
      The value mod the current modulus.

  - ### plus

    public ModuloApintField plus(ModuloApintField that)
    Description copied from class: `AbstractField`
    Returns the sum of this object with the one specified.
    Specified by:
      `plus` in interface `GroupAdditive<ModuloApintField>`
    Specified by:
      `plus` in class `AbstractField<ModuloApintField, Apint>`
    Parameters:
      `that` - The addend.
    Returns:
      `this + that`

  - ### opposite

    public ModuloApintField opposite()
    Description copied from class: `AbstractField`
    Returns the additive inverse of this object.
    Specified by:
      `opposite` in interface `GroupAdditive<ModuloApintField>`
    Specified by:
      `opposite` in class `AbstractField<ModuloApintField, Apint>`
    Returns:
      `-this`

  - ### times

    public ModuloApintField times(ModuloApintField that)
    Description copied from class: `AbstractField`
    Returns the product of this object with the one specified.
    Specified by:
      `times` in interface `GroupMultiplicative<ModuloApintField>`
    Specified by:
      `times` in interface `Ring<ModuloApintField>`
    Specified by:
      `times` in class `AbstractField<ModuloApintField, Apint>`
    Parameters:
      `that` - The multiplicand.
    Returns:
      `this * that`

  - ### inverse

    public ModuloApintField inverse() throws ArithmeticException
    Description copied from class: `AbstractField`
    Returns the multiplicative inverse of this object.
    Specified by:
      `inverse` in interface `GroupMultiplicative<ModuloApintField>`
    Specified by:
      `inverse` in class `AbstractField<ModuloApintField, Apint>`
    Returns:
      `1 / this`
    Throws:
      `ArithmeticException` - If the divisor is zero.

  - ### pow

    public ModuloApintField pow(Apint exp)
    Modular power.
    Parameters:
      `exp` - The exponent
    Returns:
      `thisexp`
    Since:
      1.15.0

  - ### copy

    public ModuloApintField copy()
    Description copied from class: `AbstractField`
    Returns a copy of this object.
    Specified by:
      `copy` in interface `ValueType`
    Specified by:
      `copy` in class `AbstractField<ModuloApintField, Apint>`
    Returns:
      A copy of this object.