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