jsat.math
Class FastMath
- java.lang.Object
-
- jsat.math.FastMath
-
public class FastMath extends java.lang.ObjectThis class contains fast implementations of many of the methods located inMathandSpecialMath. This speed comes at the cost of correctness, and in general the methods in this class attempt to have a relative error no worse than 10-3 for most inputs.
Implementation details - and therfore accuracy / speed - may change over time. 10-3 is not a hard guarantee, but a goal. The accuracy near asymptotes and extreme values will never be guaranteed. The handling of special values will never be guaranteed.
-
-
Constructor Summary
Constructors Constructor and Description FastMath()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static doubledigamma(double x)Computes the digamma function of the inputstatic doubleexp(double x)Exponentiates the given input valuestatic intfloor_log2(int x)Returns the value floor(log2(x)) for an integerstatic intfloor_log2(long x)Returns the value floor(log2(x)) for an integerstatic doublelog(double x)Computes the natural logarithm of the inputstatic doublelog2_2pd1(double x)Computes log2(x) using a Pade approximation.static doublelog2_c11(double x)Computes log2(x) using a cache of 211 values, consuming approximately 17 kilobytes of memory.
The results are generally accurate to an absolute and relative error of 10-4static doublelog2(double x)Computes log2(x)static doublepow(double a, double b)Computes ab.static doublepow2(double x)Computes 2x.
The results are generally accurate to an relative error of 10-4, but can be as accurate as 10-10static doublepow2(int x)Computes 2x exactly be exploiting the IEEE format
-
-
-
Method Detail
-
log
public static double log(double x)
Computes the natural logarithm of the input- Parameters:
x- the input- Returns:
- loge(x)
-
log2
public static double log2(double x)
Computes log2(x)- Parameters:
x- the input- Returns:
- the log base 2 of
x
-
log2_2pd1
public static double log2_2pd1(double x)
Computes log2(x) using a Pade approximation. It is slower thanlog2_c11(double)but dose not use any extra memory.
The results are generally accurate to an absolute and relative error of 10-4, but relative error can get as high as 10-10- Parameters:
x- the input- Returns:
- the log base 2 of
x
-
floor_log2
public static int floor_log2(int x)
Returns the value floor(log2(x)) for an integer- Parameters:
x- the integer to get the floored logarithm of- Returns:
- floor(log2(x))
-
floor_log2
public static int floor_log2(long x)
Returns the value floor(log2(x)) for an integer- Parameters:
x- the integer to get the floored logarithm of- Returns:
- floor(log2(x))
-
log2_c11
public static double log2_c11(double x)
Computes log2(x) using a cache of 211 values, consuming approximately 17 kilobytes of memory.
The results are generally accurate to an absolute and relative error of 10-4- Parameters:
x- the input- Returns:
- the log base 2 of
x
-
pow2
public static double pow2(int x)
Computes 2x exactly be exploiting the IEEE format- Parameters:
x- the integer power to raise 2 too- Returns:
- 2x
-
pow2
public static double pow2(double x)
Computes 2x.
The results are generally accurate to an relative error of 10-4, but can be as accurate as 10-10- Parameters:
x- the power to raise to- Returns:
-
pow
public static double pow(double a, double b)Computes ab.- Parameters:
a- the baseb- the power- Returns:
- ab
-
exp
public static double exp(double x)
Exponentiates the given input value- Parameters:
x- the input- Returns:
- ex
-
digamma
public static double digamma(double x)
Computes the digamma function of the input- Parameters:
x- the input value- Returns:
- ψ(x)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG