class FastMathCalc
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private static double[] |
FACT
Factorial table, for Taylor series expansions.
|
private static long |
HEX_40000000
0x40000000 - used to split a double into two parts, both with the low order bits cleared.
|
private static double[][] |
LN_SPLIT_COEF
Coefficients for slowLog.
|
private static java.lang.String |
TABLE_END_DECL
Table end declaration.
|
private static java.lang.String |
TABLE_START_DECL
Table start declaration.
|
| Modifier | Constructor and Description |
|---|---|
private |
FastMathCalc()
Private Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
private static void |
buildSinCosTables(double[] SINE_TABLE_A,
double[] SINE_TABLE_B,
double[] COSINE_TABLE_A,
double[] COSINE_TABLE_B,
int SINE_TABLE_LEN,
double[] TANGENT_TABLE_A,
double[] TANGENT_TABLE_B)
Build the sine and cosine tables.
|
private static void |
checkLen(int expectedLen,
int actual)
Check two lengths are equal.
|
(package private) static double |
expint(int p,
double[] result)
Compute exp(p) for a integer p in extended precision.
|
(package private) static java.lang.String |
format(double d)
Format a double.
|
(package private) static void |
printarray(java.io.PrintStream out,
java.lang.String name,
int expectedLen,
double[] array)
Print an array.
|
(package private) static void |
printarray(java.io.PrintStream out,
java.lang.String name,
int expectedLen,
double[][] array2d)
Print an array.
|
private static void |
quadMult(double[] a,
double[] b,
double[] result)
Compute (a[0] + a[1]) * (b[0] + b[1]) in extended precision.
|
private static void |
resplit(double[] a)
Recompute a split.
|
(package private) static double |
slowCos(double x,
double[] result)
For x between 0 and pi/4 compute cosine using Talor series
cos(x) = 1 - x^2/2! + x^4/4! ...
|
(package private) static double |
slowexp(double x,
double[] result)
For x between 0 and 1, returns exp(x), uses extended precision
|
(package private) static double[] |
slowLog(double xi)
xi in the range of [1, 2].
|
(package private) static double |
slowSin(double x,
double[] result)
For x between 0 and pi/4 compute sine using Taylor expansion:
sin(x) = x - x^3/3! + x^5/5! - x^7/7! ...
|
private static void |
split(double d,
double[] split)
Compute split[0], split[1] such that their sum is equal to d,
and split[0] has its 30 least significant bits as zero.
|
private static void |
splitAdd(double[] a,
double[] b,
double[] ans)
Add two numbers in split form.
|
private static void |
splitMult(double[] a,
double[] b,
double[] ans)
Multiply two numbers in split form.
|
(package private) static void |
splitReciprocal(double[] in,
double[] result)
Compute the reciprocal of in.
|
private static final long HEX_40000000
private static final double[] FACT
private static final double[][] LN_SPLIT_COEF
private static final java.lang.String TABLE_START_DECL
private static final java.lang.String TABLE_END_DECL
private static void buildSinCosTables(double[] SINE_TABLE_A,
double[] SINE_TABLE_B,
double[] COSINE_TABLE_A,
double[] COSINE_TABLE_B,
int SINE_TABLE_LEN,
double[] TANGENT_TABLE_A,
double[] TANGENT_TABLE_B)
SINE_TABLE_A - table of the most significant part of the sinesSINE_TABLE_B - table of the least significant part of the sinesCOSINE_TABLE_A - table of the most significant part of the cosinesCOSINE_TABLE_B - table of the most significant part of the cosinesSINE_TABLE_LEN - length of the tablesTANGENT_TABLE_A - table of the most significant part of the tangentsTANGENT_TABLE_B - table of the most significant part of the tangentsstatic double slowCos(double x,
double[] result)
x - number from which cosine is requestedresult - placeholder where to put the result in extended precision
(may be null)static double slowSin(double x,
double[] result)
x - number from which sine is requestedresult - placeholder where to put the result in extended precision
(may be null)static double slowexp(double x,
double[] result)
x - argument of exponentialresult - placeholder where to place exp(x) split in two terms
for extra precision (i.e. exp(x) = result[0] + result[1]private static void split(double d,
double[] split)
d - number to splitsplit - placeholder where to place the resultprivate static void resplit(double[] a)
a - input/out array containing the split, changed
on outputprivate static void splitMult(double[] a,
double[] b,
double[] ans)
a - first term of multiplicationb - second term of multiplicationans - placeholder where to put the resultprivate static void splitAdd(double[] a,
double[] b,
double[] ans)
a - first term of additionb - second term of additionans - placeholder where to put the resultstatic void splitReciprocal(double[] in,
double[] result)
in - initial number, in split formresult - placeholder where to put the resultprivate static void quadMult(double[] a,
double[] b,
double[] result)
a - first term of the multiplicationb - second term of the multiplicationresult - placeholder where to put the resultstatic double expint(int p,
double[] result)
p - integer whose exponential is requestedresult - placeholder where to put the result in extended precisionstatic double[] slowLog(double xi)
xi - number from which log is requestedstatic void printarray(java.io.PrintStream out,
java.lang.String name,
int expectedLen,
double[][] array2d)
out - text output stream where output should be printedname - array nameexpectedLen - expected length of the arrayarray2d - array datastatic void printarray(java.io.PrintStream out,
java.lang.String name,
int expectedLen,
double[] array)
out - text output stream where output should be printedname - array nameexpectedLen - expected length of the arrayarray - array datastatic java.lang.String format(double d)
d - double number to formatprivate static void checkLen(int expectedLen,
int actual)
throws DimensionMismatchException
expectedLen - expected lengthactual - actual lengthDimensionMismatchException - if the two lengths are not equalCopyright (c) 2003-2015 Apache Software Foundation