public class MathUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
MathUtils.BasicStats
Wrapper around weighted paralell basic stats computation (mean, variance)
|
static class |
MathUtils.ComputeAbsDiff |
static class |
MathUtils.DCT |
static class |
MathUtils.Norm |
static class |
MathUtils.SquareError |
Modifier and Type | Field and Description |
---|---|
static long[] |
PRIMES |
Constructor and Description |
---|
MathUtils() |
Modifier and Type | Method and Description |
---|---|
static double |
approxExp(double x)
Fast approximate exp
|
static double |
approxInvSqrt(double x)
Fast approximate 1./sqrt
|
static float |
approxInvSqrt(float x)
Fast approximate 1./sqrt
|
static double |
approxLog(double x)
Fast approximate log for values greater than 1, otherwise exact
|
static double |
approxSqrt(double x)
Fast approximate sqrt
|
static float |
approxSqrt(float x)
Fast approximate sqrt
|
static float |
approxSumSquares(float[] a,
int from,
int to)
Approximate sumSquares
|
static boolean |
compare(double a,
double b,
double abseps,
double releps)
Compare 2 doubles within a tolerance
|
static int |
compare(long x,
long y)
Compare signed longs
|
static int |
compareUnsigned(long a,
long b)
Copmarision of unsigned longs.
|
static int |
compareUnsigned(long hiA,
long loA,
long hiB,
long loB)
Comparision of 128bit unsigned values represented by 2 longs
|
static double |
computeWeightedQuantile(Vec weight,
Vec values,
double alpha) |
static double[] |
div(double[] nums,
double n) |
static float[] |
div(float[] nums,
float n) |
static boolean |
equalsWithinOneSmallUlp(double a,
double b) |
static boolean |
equalsWithinOneSmallUlp(float a,
float b)
Compare two numbers to see if they are within one ulp of the smaller decade.
|
static boolean |
equalsWithinRecSumErr(double actual,
double expected,
int n,
double absum) |
static double |
innerProduct(double[] x,
double[] y) |
static double |
l1norm(double[] x) |
static double |
l2norm(double[] x) |
static double |
l2norm2(double[] x) |
static int |
log2(int n)
Fast calculation of log base 2 for integers.
|
static int |
log2(long n) |
static double |
logFactorial(long y) |
static double[] |
min_max_mean_stddev(long[] counts) |
static double |
roundToNDigits(double d,
int n) |
static double |
sign(double d) |
static double |
sum(double[] from) |
static float |
sum(float[] from) |
static float |
sumSquares(float[] a) |
static float |
sumSquares(float[] a,
int from,
int to) |
static double[] |
wadd(double[] x,
double[] y,
double w) |
static double |
weightedSigma(long nobs,
double wsum,
double xSum,
double xxSum) |
static double |
y_log_y(double y,
double mu) |
public static double weightedSigma(long nobs, double wsum, double xSum, double xxSum)
public static double logFactorial(long y)
public static double computeWeightedQuantile(Vec weight, Vec values, double alpha)
public static double approxSqrt(double x)
public static float approxSqrt(float x)
public static double approxInvSqrt(double x)
public static float approxInvSqrt(float x)
public static double approxExp(double x)
public static double approxLog(double x)
public static int log2(int n)
public static int log2(long n)
public static float[] div(float[] nums, float n)
public static double[] div(double[] nums, double n)
public static float sum(float[] from)
public static double sum(double[] from)
public static float sumSquares(float[] a)
public static float approxSumSquares(float[] a, int from, int to)
a
- Array with numbersfrom
- starting index (inclusive)to
- ending index (exclusive)public static float sumSquares(float[] a, int from, int to)
public static boolean equalsWithinOneSmallUlp(float a, float b)
a
- First numberb
- Second numberpublic static boolean equalsWithinOneSmallUlp(double a, double b)
public static boolean equalsWithinRecSumErr(double actual, double expected, int n, double absum)
public static boolean compare(double a, double b, double abseps, double releps)
a
- doubleb
- doubleabseps
- - Absolute allowed tolerancereleps
- - Relative allowed tolerancepublic static double innerProduct(double[] x, double[] y)
public static double l2norm2(double[] x)
public static double l1norm(double[] x)
public static double l2norm(double[] x)
public static double[] wadd(double[] x, double[] y, double w)
public static double roundToNDigits(double d, int n)
public static double[] min_max_mean_stddev(long[] counts)
public static double sign(double d)
public static double y_log_y(double y, double mu)
public static int compare(long x, long y)
public static int compareUnsigned(long a, long b)
public static int compareUnsigned(long hiA, long loA, long hiB, long loB)