| Modifier and Type | Field and Description |
|---|---|
| private static final double[] | FACT
Factorial table, for Taylor series expansions. |
| private static final long | HEX_40000000
0x40000000 - used to split a double into two parts, both with the low order bits cleared. |
| private static final double[][] | LN_SPLIT_COEF
Coefficients for slowLog. |
| private static final String | TABLE_END_DECL
Table end declaration. |
| private static final String | TABLE_START_DECL
Table start declaration. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private static void | buildSinCosTables(double[]
table of the most significant part of the sines SINE_TABLE_A, double[] table of the least significant part of the sines SINE_TABLE_B, double[] table of the most significant part of the cosines COSINE_TABLE_A, double[] table of the most significant part of the cosines COSINE_TABLE_B, int length of the tables SINE_TABLE_LEN, double[] table of the most significant part of the tangents TANGENT_TABLE_A, double[] table of the most significant part of the tangents TANGENT_TABLE_B)Build the sine and cosine tables. |
| private static void | |
| pack-priv static double | Returns: exp(p) in standard precision (equal to result[0] + result[1])integer whose exponential is requested p, final double[] placeholder where to put the result in extended precision result)Compute exp(p) for a integer p in extended precision. |
| pack-priv static String | |
| pack-priv static void | printarray(PrintStream
text output stream where output should be printed out, String array name name, int expected length of the array expectedLen, double[][] array data array2d)Print an array. |
| pack-priv static void | printarray(PrintStream
text output stream where output should be printed out, String array name name, int expected length of the array expectedLen, double[] array data array)Print an array. |
| private static void | quadMult(final double[]
first term of the multiplication a, final double[] second term of the multiplication b, final double[] placeholder where to put the result result)Compute (a[0] + a[1]) * (b[0] + b[1]) in extended precision. |
| private static void | |
| pack-priv static double | Returns: cos(x)number from which cosine is requested x, final double[] placeholder where to put the result in extended precision
(may be null) result)For x between 0 and pi/4 compute cosine using Talor series cos(x) = 1 - x^2/2! |
| pack-priv static double | Returns: exp(x)argument of exponential x, final double[] placeholder where to place exp(x) split in two terms
for extra precision (i.e. exp(x) = result[0] + result[1] result)For x between 0 and 1, returns exp(x), uses extended precision |
| pack-priv static double[] | |
| pack-priv static double | Returns: sin(x)number from which sine is requested x, final double[] placeholder where to put the result in extended precision
(may be null) result)For x between 0 and pi/4 compute sine using Taylor expansion: sin(x) = x - x^3/3! |
| private static void | split(final double
number to split d, final double[] placeholder where to place the result 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(final double[]
first term of addition a, final double[] second term of addition b, final double[] placeholder where to put the result ans)Add two numbers in split form. |
| private static void | splitMult(double[]
first term of multiplication a, double[] second term of multiplication b, double[] placeholder where to put the result ans)Multiply two numbers in split form. |
| pack-priv static void | splitReciprocal(final double[]
initial number, in split form in, final double[] placeholder where to put the result result)Compute the reciprocal of in. Use the following algorithm. |
| FACT | back to summary |
|---|---|
| private static final double[] FACT Factorial table, for Taylor series expansions. 0!, 1!, 2!, ... 19! | |
| HEX_40000000 | back to summary |
|---|---|
| private static final long HEX_40000000 0x40000000 - used to split a double into two parts, both with the low order bits cleared. Equivalent to 2^30. | |
| LN_SPLIT_COEF | back to summary |
|---|---|
| private static final double[][] LN_SPLIT_COEF Coefficients for slowLog. | |
| TABLE_END_DECL | back to summary |
|---|---|
| private static final String TABLE_END_DECL Table end declaration. | |
| TABLE_START_DECL | back to summary |
|---|---|
| private static final String TABLE_START_DECL Table start declaration. | |
| FastMathCalc | back to summary |
|---|---|
| private FastMathCalc() Private Constructor. | |
| buildSinCosTables | back to summary |
|---|---|
| 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.
| |
| checkLen | back to summary |
|---|---|
| private static void checkLen(int expectedLen, int actual) throws DimensionMismatchException Check two lengths are equal.
| |
| expint | back to summary |
|---|---|
| pack-priv static double expint(int p, final double[] result) Compute exp(p) for a integer p in extended precision.
| |
| format | back to summary |
|---|---|
| pack-priv static String format(double d) Format a double.
| |
| printarray | back to summary |
|---|---|
| pack-priv static void printarray(PrintStream out, String name, int expectedLen, double[][] array2d) Print an array.
| |
| printarray | back to summary |
|---|---|
| pack-priv static void printarray(PrintStream out, String name, int expectedLen, double[] array) Print an array.
| |
| quadMult | back to summary |
|---|---|
| private static void quadMult(final double[] a, final double[] b, final double[] result) Compute (a[0] + a[1]) * (b[0] + b[1]) in extended precision.
| |
| resplit | back to summary |
|---|---|
| private static void resplit(final double[] a) Recompute a split.
| |
| slowCos | back to summary |
|---|---|
| pack-priv static double slowCos(final double x, final double[] result) For x between 0 and pi/4 compute cosine using Talor series cos(x) = 1 - x^2/2! + x^4/4! ...
| |
| slowexp | back to summary |
|---|---|
| pack-priv static double slowexp(final double x, final double[] result) For x between 0 and 1, returns exp(x), uses extended precision
| |
| slowLog | back to summary |
|---|---|
| pack-priv static double[] slowLog(double xi) xi in the range of [1, 2]. 3 5 7 x+1 / x x x \ ln ----- = 2 * | x + ---- + ---- + ---- + ... | 1-x \ 3 5 7 / So, compute a Remez approximation of the following function ln ((sqrt(x)+1)/(1-sqrt(x))) / x This will be an even function with only positive coefficents. x is in the range [0 - 1/3]. Transform xi for input to the above function by setting x = (xi-1)/(xi+1). Input to the polynomial is x^2, then the result is multiplied by x.
| |
| slowSin | back to summary |
|---|---|
| pack-priv static double slowSin(final double x, final 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! ...
| |
| split | back to summary |
|---|---|
| private static void split(final double d, final 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.
| |
| splitAdd | back to summary |
|---|---|
| private static void splitAdd(final double[] a, final double[] b, final double[] ans) Add two numbers in split form.
| |
| splitMult | back to summary |
|---|---|
| private static void splitMult(double[] a, double[] b, double[] ans) Multiply two numbers in split form.
| |
| splitReciprocal | back to summary |
|---|---|
| pack-priv static void splitReciprocal(final double[] in, final double[] result) Compute the reciprocal of in. Use the following algorithm. in = c + d. want to find x + y such that x+y = 1/(c+d) and x is much larger than y and x has several zero bits on the right. Set b = 1/(2^22), a = 1 - b. Thus (a+b) = 1. Use following identity to compute (a+b)/(c+d) (a+b)/(c+d) = a/c + (bc - ad) / (c^2 + cd) set x = a/c and y = (bc - ad) / (c^2 + cd) This will be close to the right answer, but there will be some rounding in the calculation of X. So by carefully computing 1 - (c+d)(x+y) we can compute an error and add that back in. This is done carefully so that terms of similar size are subtracted first.
| |