Package org.apfloat.internal
Class DoubleCRTMath
- java.lang.Object
-
- org.apfloat.internal.DoubleBaseMath
-
- org.apfloat.internal.DoubleCRTMath
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
DoubleCarryCRTStepStrategy
public class DoubleCRTMath extends DoubleBaseMath
Basic arithmetic for calculating the Chinese Remainder Theorem. Works for thedouble
type.- Version:
- 1.6
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private long
base
private static long
BASE_MASK
private static double
INVERSE_2_64
private double
inverseBase
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description DoubleCRTMath(int radix)
Creates a carry-CRT math using the specified radix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
add(double[] src, double[] srcDst)
Adds three words.double
compare(double[] src1, double[] src2)
Compares three words.double
divide(double[] srcDst)
Divides three words by the base to produce two words.void
multiply(double[] src, double factor, double[] dst)
Multiplies two words by one word to produce a result of three words.void
subtract(double[] src, double[] srcDst)
Subtracts three words.-
Methods inherited from class org.apfloat.internal.DoubleBaseMath
baseAdd, baseDivide, baseMultiplyAdd, baseSubtract
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
BASE_MASK
private static final long BASE_MASK
- See Also:
- Constant Field Values
-
INVERSE_2_64
private static final double INVERSE_2_64
- See Also:
- Constant Field Values
-
base
private long base
-
inverseBase
private double inverseBase
-
-
Method Detail
-
multiply
public final void multiply(double[] src, double factor, double[] dst)
Multiplies two words by one word to produce a result of three words. Most significant word is stored first.- Parameters:
src
- Source array, first multiplicand.factor
- Second multiplicand.dst
- Destination array.
-
compare
public final double compare(double[] src1, double[] src2)
Compares three words. Most significant word is stored first.- Parameters:
src1
- First operand.src2
- Second operand.- Returns:
- Less than zero if
src1 < src2
, greater than zero ifsrc1 > src2
and zero ifsrc1 == src2
.
-
add
public final double add(double[] src, double[] srcDst)
Adds three words. Most significant word is stored first.- Parameters:
src
- First operand.srcDst
- Second operand, and destination of the operation.- Returns:
- Overflow carry bit.
-
subtract
public final void subtract(double[] src, double[] srcDst)
Subtracts three words. Most significant word is stored first.- Parameters:
src
- First operand.srcDst
- Second operand, and destination of the operation.
-
divide
public final double divide(double[] srcDst)
Divides three words by the base to produce two words. Most significant word is stored first.- Parameters:
srcDst
- Source and destination of the operation.- Returns:
- Remainder of the division.
-
-