public class MathUtils
extends java.lang.Object
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 |
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 float |
sumSquares(float[] a) |
static float |
sumSquares(float[] a,
int from,
int to) |
static double[] |
wadd(double[] x,
double[] y,
double w) |
public static final double approxSqrt(double x)
x
- public static final float approxSqrt(float x)
x
- public static final double approxInvSqrt(double x)
x
- public static final float approxInvSqrt(float x)
x
- public static final double approxExp(double x)
x
- public static final double approxLog(double x)
x
- public static final int log2(int n)
n
- 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 final double innerProduct(double[] x, double[] y)
public static final double l2norm2(double[] x)
public static final double l1norm(double[] x)
public static final double l2norm(double[] x)
public static final double[] wadd(double[] x, double[] y, double w)