|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.commons.math3.util.FastMathCalc
class FastMathCalc
Class used to compute the classical functions tables.
| Field Summary | |
|---|---|
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 String |
TABLE_END_DECL
Table end declaration. |
private static String |
TABLE_START_DECL
Table start declaration. |
| Constructor Summary | |
|---|---|
private |
FastMathCalc()
Private Constructor. |
| Method 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. |
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 String |
format(double d)
Format a double. |
(package private) static void |
printarray(PrintStream out,
String name,
int expectedLen,
double[] array)
Print an array. |
(package private) static void |
printarray(PrintStream out,
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final long HEX_40000000
private static final double[] FACT
private static final double[][] LN_SPLIT_COEF
private static final String TABLE_START_DECL
private static final String TABLE_END_DECL
| Constructor Detail |
|---|
private FastMathCalc()
| Method Detail |
|---|
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 tangents
static 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 output
private static void splitMult(double[] a,
double[] b,
double[] ans)
a - first term of multiplicationb - second term of multiplicationans - placeholder where to put the result
private static void splitAdd(double[] a,
double[] b,
double[] ans)
a - first term of additionb - second term of additionans - placeholder where to put the result
static void splitReciprocal(double[] in,
double[] result)
in - initial number, in split formresult - placeholder where to put the result
private 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 result
static double expint(int p,
double[] result)
p - integer whose exponential is requestedresult - placeholder where to put the result in extended precision
static double[] slowLog(double xi)
xi - number from which log is requested
static void printarray(PrintStream out,
String name,
int expectedLen,
double[][] array2d)
out - text output stream where output should be printedname - array nameexpectedLen - expected length of the arrayarray2d - array data
static void printarray(PrintStream out,
String name,
int expectedLen,
double[] array)
out - text output stream where output should be printedname - array nameexpectedLen - expected length of the arrayarray - array datastatic String format(double d)
d - double number to format
private static void checkLen(int expectedLen,
int actual)
throws DimensionMismatchException
expectedLen - expected lengthactual - actual length
DimensionMismatchException - if the two lengths are not equal
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||