Package org.apfloat.internal
Class LongModMath
- java.lang.Object
-
- org.apfloat.internal.LongElementaryModMath
-
- org.apfloat.internal.LongModMath
-
- Direct Known Subclasses:
LongFactor3NTTStepStrategy
,LongNTTConvolutionStepStrategy
,LongTableFNT
,LongWTables
public class LongModMath extends LongElementaryModMath
Modulo arithmetic functions forlong
data.- Version:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description LongModMath()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long[]
createWTable(long w, int n)
Create a table of powers of n:th root of unity.long
getForwardNthRoot(long primitiveRoot, long n)
Get forward n:th root of unity.long
getInverseNthRoot(long primitiveRoot, long n)
Get inverse n:th root of unity.long
modDivide(long a, long b)
Modular division.long
modInverse(long a)
Modular inverse, that is1 / a
.long
modPow(long a, long n)
Modular power.long
negate(long a)
Modular negation.-
Methods inherited from class org.apfloat.internal.LongElementaryModMath
getModulus, modAdd, modMultiply, modSubtract, setModulus
-
-
-
-
Method Detail
-
createWTable
public final long[] createWTable(long 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 long getForwardNthRoot(long 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 long getInverseNthRoot(long 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 long modInverse(long a)
Modular inverse, that is1 / a
. Assumes that the modulus is prime.- Parameters:
a
- The operand.- Returns:
a-1 mod m
.
-
modDivide
public final long modDivide(long a, long 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 long negate(long a)
Modular negation.- Parameters:
a
- The argument.- Returns:
-a mod m
.
-
modPow
public final long modPow(long a, long n)
Modular power. Assumes that the modulus is prime.- Parameters:
a
- The base.n
- The exponent.- Returns:
an mod m
.
-
-