# Class FloatModMath

java.lang.Object
org.apfloat.internal.FloatElementaryModMath
org.apfloat.internal.FloatModMath

Direct Known Subclasses:
  `FloatFactor3NTTStepStrategy, FloatNTTConvolutionStepStrategy, FloatTableFNT, FloatWTables`

public class FloatModMath extends FloatElementaryModMath
Modulo arithmetic functions for `float` data.

Version:
  1.0
Author:
  Mikko Tommila

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FloatModMath()`
  Default constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final float[]`
  `createWTable(float w, int n)`
  Create a table of powers of n:th root of unity.
  `float`
  `getForwardNthRoot(float primitiveRoot, long n)`
  Get forward n:th root of unity.
  `float`
  `getInverseNthRoot(float primitiveRoot, long n)`
  Get inverse n:th root of unity.
  `final float`
  `modDivide(float a, float b)`
  Modular division.
  `final float`
  `modInverse(float a)`
  Modular inverse, that is `1 / a`.
  `final float`
  `modPow(float a, float n)`
  Modular power.
  `final float`
  `negate(float a)`
  Modular negation.

  ### Methods inherited from class FloatElementaryModMath

  `getModulus, modAdd, modMultiply, modSubtract, setModulus`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### FloatModMath

    public FloatModMath()
    Default constructor.

- ## Method Details

  - ### createWTable

    public final float[] createWTable(float w, int n)
    Create a table of powers of n:th root of unity.
    Parameters:
      `w` - The n:th root of unity modulo the current modulus.
      `n` - The table length (= transform length).
    Returns:
      Table of `table[i]=wi mod m`, i = 0, ..., n-1.

  - ### getForwardNthRoot

    public float getForwardNthRoot(float primitiveRoot, long n)
    Get forward n:th root of unity. This is `w`.

    Assumes that the modulus is prime.

    Parameters:
      `primitiveRoot` - Primitive root of the modulus.
      `n` - The transform length.
    Returns:
      Forward n:th root of unity.

  - ### getInverseNthRoot

    public float getInverseNthRoot(float primitiveRoot, long n)
    Get inverse n:th root of unity. This is `w-1`.

    Assumes that the modulus is prime.

    Parameters:
      `primitiveRoot` - Primitive root of the modulus.
      `n` - The transform length.
    Returns:
      Inverse n:th root of unity.

  - ### modInverse

    public final float modInverse(float a)
    Modular inverse, that is `1 / a`. Assumes that the modulus is prime.
    Parameters:
      `a` - The operand.
    Returns:
      `a-1 mod m`.

  - ### modDivide

    public final float modDivide(float a, float b)
    Modular division. Assumes that the modulus is prime.
    Parameters:
      `a` - The dividend.
      `b` - The divisor.
    Returns:
      `a*b-1 mod m`.

  - ### negate

    public final float negate(float a)
    Modular negation.
    Parameters:
      `a` - The argument.
    Returns:
      `-a mod m`.

  - ### modPow

    public final float modPow(float a, float n)
    Modular power. Assumes that the modulus is prime.
    Parameters:
      `a` - The base.
      `n` - The exponent.
    Returns:
      `an mod m`.