Package org.apfloat.internal
Class IntModMath
java.lang.Object
org.apfloat.internal.IntElementaryModMath
org.apfloat.internal.IntModMath
- Direct Known Subclasses:
IntFactor3NTTStepStrategy,IntNTTConvolutionStepStrategy,IntTableFNT,IntWTables
Modulo arithmetic functions for
int data.- Version:
- 1.0
- Author:
- Mikko Tommila
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal int[]createWTable(int w, int n) Create a table of powers of n:th root of unity.intgetForwardNthRoot(int primitiveRoot, long n) Get forward n:th root of unity.intgetInverseNthRoot(int primitiveRoot, long n) Get inverse n:th root of unity.final intmodDivide(int a, int b) Modular division.final intmodInverse(int a) Modular inverse, that is1 / a.final intmodPow(int a, int n) Modular power.final intnegate(int a) Modular negation.Methods inherited from class org.apfloat.internal.IntElementaryModMath
getModulus, modAdd, modMultiply, modSubtract, setModulus
-
Constructor Details
-
IntModMath
public IntModMath()Default constructor.
-
-
Method Details
-
createWTable
public final int[] createWTable(int 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 int getForwardNthRoot(int primitiveRoot, long n) Get forward n:th root of unity. This isw.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 int getInverseNthRoot(int primitiveRoot, long n) Get inverse n:th root of unity. This isw-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 int modInverse(int a) Modular inverse, that is1 / a. Assumes that the modulus is prime.- Parameters:
a- The operand.- Returns:
a-1 mod m.
-
modDivide
public final int modDivide(int a, int 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 int negate(int a) Modular negation.- Parameters:
a- The argument.- Returns:
-a mod m.
-
modPow
public final int modPow(int a, int n) Modular power. Assumes that the modulus is prime.- Parameters:
a- The base.n- The exponent.- Returns:
an mod m.
-