public class MathUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
MathUtils.Norm |
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 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 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 double[] |
min_max_mean_stddev(long[] counts) |
static double |
roundToNDigits(double d,
int n) |
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) |
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 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 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)