|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.hedgehog.math.functions.Functions
public class Functions
Title: Functions - a collection of frequently used mathematical functions.
Description: Collection of frequently used mathematical functions.
Copyright: Copyright (c) Hedgehog Software 2007-2009.
Company: Hedgehog Software.
| Method Summary | |
|---|---|
static double |
abs(double n)
Returns the absolute value of a double object. |
static float |
abs(float n)
Returns the absolute value of a float object. |
static int |
abs(int n)
Returns the absolute value of an int object. |
static double |
acos(double x)
Returns the arc-cosine of the specified value, clamping the input argument to [-1,1] to avoid NaN issues when the input is slightly larger than 1 or slightly smaller than -1. |
static double |
acosh(double x)
Returns the arc hyperbolic cosine of the specified number; ie Math.log(x + Math.sqrt(x * x - 1.0)); |
static double |
acot(double x)
Returns the arc cotangent of x, which is equivalent to atan(1/x). |
static double |
asin(double x)
Returns the arc-sine of the specified value, clamping the input argument to [-1,1] to avoid NaN issues when the input is slightly larger than 1 or slightly smaller than -1. |
static double |
asinh(double x)
Returns the arc hyperbolic sine of the specified number; ie Math.log(x + Math.sqrt(x * x + 1.0)); |
static double |
atan(double x)
Returns the arc tangent of x. |
static double |
atan2(double y,
double x)
Returns the angle theta from the conversion of rectangular coordinates ( x, y) to polar
coordinates (r, theta). |
static double |
atanh(double x)
Returns the arc hyperbolic tangent of the specified number; ie Math.log((1.0 + x) / (1.0 - x)) / 2.0; |
static double |
average(double[] doubles)
Returns the average of the elements of an array of doubles. |
static double |
average(int[] ints)
Returns the average of the elements of an array of ints. |
static double |
bernoulliNumber(int n)
Returns the Bernoulli number. |
static double |
betaFunction(double x,
double y)
Returns the Beta function B(x,y)=Gamma(x)*Gamma(y)/Gamma(x+y) |
static double |
binomialCoefficient(int k,
int i)
Returns the binomial coefficient of (k i)=k!/(i!(k-i)!) |
static int |
bitCount1(long a)
Counts the number of 1 bits in a 32-bit long integer (variant 1). |
static long |
bitCount2(long a)
Counts the number of 1 bits in a 32-bit long integer (variant 2). |
static long |
bitCount3(long a)
Counts the number of 1 bits in a 32-bit long integer (variant 3). |
static double |
ceil(double x)
Returns the smallest value that is greater than or equal to the argument and is equal to a mathematical integer. |
static int |
ceil2(int x)
Returns the least power of 2 greater than or equal to x. |
static double |
clamp(double val,
double min,
double max)
Clamps the specified value to the specified [min:max] range. |
static int |
clamp(int val,
int min,
int max)
Clamps the specified value to the specified [min:max] range. |
static double |
complementErrorFunction(double x)
Returns the complement Error function erfc(x)=1-erf(x)=Q(1/2,x^2). |
static double |
complementIncompleteGammaFunction(double a,
double x)
Returns the complement incomplete Gamma function Q(a,x)=1-P(a,x). |
static double |
correlation(double[] v1,
double[] v2)
Computes the linear correlation between the two specified arrays. |
static double |
cos(double x,
boolean degrees)
Returns cos(x). |
static double |
cosech(double x)
Hyperbolic cosech() function. |
static double |
cosFast0(double x,
boolean degrees)
Optimised version of cos(x). |
static double |
cosFast1(double x,
boolean degrees)
Optimised version of cos(x). |
static double |
cosh(double x)
Hyperbolic cosh() function. |
static double |
cot(double x,
boolean degrees)
Returns the cotangent of the specified value; ie 1/tan(x). |
static double |
coth(double x)
Hyperbolic coth() function. |
static double |
covariance(double[] v1,
double[] v2)
Computes the covariance. |
static double |
cubeRoot(double x)
Returns the cube root of the specified number. |
static double |
degreesMinutesSecondsToDegrees(double degrees,
double minutes,
double seconds)
Converts {degrees,minutes,seconds} to degrees. |
static double |
degreesMinutesSecondsToMinutes(double degrees,
double minutes,
double seconds)
Converts {degrees,minutes,seconds} to minutes. |
static double |
degreesMinutesSecondsToSeconds(double degrees,
double minutes,
double seconds)
Converts {degrees,minutes,seconds} to seconds. |
static TripleDouble |
degreesToDegreesMinutesSeconds(double degrees)
Converts degrees to {degrees,minutes,seconds}. |
static double |
degreesToHours(double degrees)
Returns a number of degrees to hours by simply dividing by 15. |
static double |
degreesToRadians(double theta)
Converts degrees to radians. |
static double |
difference(double a,
double b,
int method)
Returns the difference between the specified numbers. |
static PairInteger |
div(int numer,
int denom)
Returns the quotient, q, and remainder, r, of the division (numer/denom). |
static java.util.Vector<HDouble> |
equallySpacedPointsInInterval(double a,
double b,
int n,
boolean includeEndPoints)
Returns a vector of n equally spaced points within the specified interval [a:b]. |
static double |
erf(double x)
Evaluates the error function, defined as: |
static double |
erfComplementary(double x)
Evaluates the complementary error function. |
static double |
errorFunction(double x)
Returns the Error function erf(x)=P(1/2,x^2). |
static double |
eulerNumber(int n)
Returns the Euler number; ie 1,0,-1,0,5,0,-61,... |
static double |
exp(double x)
Returns the exponential of x; ie e^x. |
double |
expNegativeFast0(double x)
Fast evaluation of exp(-x). |
double |
expNegativeFast1(double x)
Fast evaluation of exp(-x). |
double |
expNegativeFast2(double x)
Fast evaluation of exp(-x). |
double |
expNegativeFast3(double x)
Fast evaluation of exp(-x). |
static double |
fabs(double x)
Returns the absolute value of the floating-point value. |
static double |
factorial(int n)
Returns the factorial of n; ie n! n! = 1 for n<=1 and n! = n(n-1)! = n(n-1)(n-2)... |
static double |
factorialDouble(int n)
Returns the double factorial of n; ie n!!: n!! = 1 for n=0, 1 or -1. |
int |
fibonacci(int n)
Returns the Fibonacci number of the specified sequence number. |
static double |
floor(double x)
Returns the floor value of x. |
static int |
floor2(int x)
Returns the greatest power of 2 less than or equal to x. |
static double |
fowlerAngle(double dy,
double dx)
If you require a monotonic function of the angle, rather than needing the value of the angle itself then you can avoid the arcsine and arctangent computation by using Fowler angles. |
static double |
fractionalPart(double n)
Returns the positive fractional part of a number. |
static double |
gammaFunction(double z)
Returns Gamma(z) for z>0. |
static int |
gcd(int n,
int m)
Returns the greatest common divisor of 2 positive integers. |
static double |
gcf(double a,
double x)
Continued fraction evaluation of complement incomplete Gamma function Q(a,x) (used by IncompleteCompleteGammaFunction()). |
static double |
goldenRatio()
Returns the golden ratio (1.61803...) |
static double |
gser(double a,
double x)
Series evaluation of gamma function (used by IncompleteCompleteGammaFunction()). |
static int |
hash(double x)
Returns an integer hash code representing the specified double value. |
static double |
haverSine(double x)
Returns the haversine of x (i.e., havx=(1-cosx)/2). |
static int |
heavisideUnitStep(int t,
int c)
Heaviside unit step function. |
static double |
hoursToDegrees(double hours)
Converts hours to degrees; ie degrees=15*hours. |
static double |
hypot(double a,
double b)
Returns sqrt(a^2 + b^2) without under/overflow. |
static double |
incompleteGammaFunction(double a,
double x)
returns the incomplete Gamma function P(a,x). |
static double |
intermediate_abs(double a,
double b,
double c)
Returns the intermediate absolute value of the specified three double values. |
static double |
intermediate(double a,
double b,
double c)
Returns the intermediate of three double objects. |
static int |
intermediate(int a,
int b,
int c)
Returns the intermediate of three int objects. |
static double |
intervalRandom(double min,
double max,
int seed)
Generates a random number in the interval [min,max). |
static double |
invCosFast0(double x,
boolean degrees)
Optimised version of 1/cos(x). |
static double |
invCosFast1(double x,
boolean degrees)
Optimised version of 1/cos(x). |
static double |
invSinFast0(double x,
boolean degrees)
Optimised version of 1/sin(x). |
static double |
invSinFast1(double x,
boolean degrees)
Optimised version of 1/sin(x). |
static double |
invSqrt(double x)
Evaluates the inverse square root of x; ie 1/sqrt(x). |
static double |
invSqrtFast(double x)
Optimised version of 1/sqrt(x). |
static float |
invSqrtFast(float x)
Returns the fast approximation of the inverse square root of the specified value. |
static double |
invTanFast0(double x,
boolean degrees)
Optimised version of 1/tan(x). |
static double |
invTanFast1(double x,
boolean degrees)
Optimised version of 1/tan(x). |
static boolean |
isEven(int n)
Tests whether or not a number is even. |
static boolean |
isEven(long n)
Tests whether or not a number is even. |
static boolean |
isNAN(double n)
Tests whether or not the specified number if equal to NAN(1e38). |
static boolean |
isOdd(int n)
Tests whether or not a number (int) is odd. |
static boolean |
isOdd(long n)
Tests whether or not a number (long) is odd. |
static boolean |
isPowerOfTwo(int number)
Tests whether or not the specified number is a power of 2 (2,4,8,16...). |
static boolean |
isPrime(int n)
Tests whether or not a number (int) is a prime. |
static boolean |
isPrime(long n)
Tests whether or not a number (long) is a prime. |
static boolean |
isPythagoreanTriple(int x,
int y,
int z)
Returns logical-true if the int point(x,y,z) is a Pythagorean triple; ie z^2=x^2+y^2. |
static boolean |
isPythagoreanTriple(long x,
long y,
long z)
Returns logical-true if the long point(x,y,z) is a Pythagorean triple; ie z^2=x^2+y^2. |
static boolean |
isSameValue(double x,
double y,
double tolerance)
Tests whether or not x and y are the same, within the specified tolerance. |
static boolean |
isSorted(double a,
double b,
boolean increasingOrder)
Tests whether or not the specified double sequence is in order. |
static boolean |
isSorted(double a,
double b,
double c,
boolean increasingOrder)
Tests whether or not the specified double sequence is in order. |
static boolean |
isSorted(int a,
int b,
boolean increasingOrder)
Tests whether or not the specified sequence is in order. |
static boolean |
isSorted(int a,
int b,
int c,
boolean increasingOrder)
Tests whether or not the specified sequence is in order. |
static boolean |
isWholeNumber(double n,
double tolerance)
Tests whether or not the specified number is a whole number within the specified tolerance. |
static boolean |
isZero(double x,
double tolerance)
Tests whether or not a floating-point number is zero. |
static boolean |
isZero(int x)
Tests whether or not an int number is zero. |
static boolean |
isZero(long x)
Tests whether or not an long number is zero. |
static void |
leftToRightShift(java.lang.Object a,
java.lang.Object b,
java.lang.Object c,
java.lang.Object d)
Shifts objects (a,b,c,d) from left to right (i.e. |
static double |
linearInterpolation(java.util.Vector<HDouble> sample_points,
double u)
Linear interpolation in 1-dimension. |
static double |
linearInterpolation(java.util.Vector<HDouble> sample_points,
double u,
double v)
Linear interpolation in 2-dimensions. |
static double |
linearInterpolation(java.util.Vector<HDouble> sample_points,
double u,
double v,
double w)
Linear interpolation in 3-dimensions. |
static double |
log(double x)
Returns log(x); ie the natural logarithm (base e) of x. |
static double |
log10(double x)
Returns the base 10 logarithm of the specified number; ie log(x)/log(10). |
static double |
log2(double x)
Returns the log of the specified number to base 2; ie log(x)/log(2). |
static double |
logFactorial(int n)
Returns log(n!) = log (n * (n-1) * ... |
static double |
logGammaFunction(double z)
Returns ln[Gamma(z)] for z>0. |
static double |
max(double a,
double b)
Returns the maximum of two objects. |
static double |
max(double a,
double b,
double c)
Returns the maximum of three double objects. |
static int |
max(int a,
int b)
Returns the maximum of two objects. |
static int |
max(int a,
int b,
int c)
Returns the maximum of three int objects. |
static double |
maxAbs(double a,
double b)
Returns the maximum absolute value of (a,b). |
static double |
maxAbs(double a,
double b,
double c)
Returns the maximum absolute value of (a,b,c). |
static int |
maxIndex(double[] doubles)
Returns index of maximum element in a given array of doubles. |
static int |
maxIndex(int[] ints)
Returns index of maximum element in a given array of integers. |
static void |
maxSort(HDouble a,
HDouble b)
Sorts a and b so that a>=b. |
static double |
mean(double[] vector)
Computes the mean of the specified array of doubles. |
static double |
min(double a,
double b)
Returns the minimum of two objects. |
static double |
min(double a,
double b,
double c)
Returns the minimum of three double objects. |
static int |
min(int a,
int b)
Returns the minimum of two objects. |
static int |
min(int a,
int b,
int c)
Returns the minimum of three objects. |
static double |
minAbs(double a,
double b)
Returns the min absolute value of the specified 2 values. |
static double |
minAbs(double a,
double b,
double c)
Returns the min absolute value of the specified 3 values. |
static int |
minIndex(double[] doubles)
Returns index of minimum element in a given array of doubles. |
static int |
minIndex(int[] ints)
Returns index of minimum element in a given array of integers. |
static void |
minSort(HDouble a,
HDouble b)
Sorts a and b so that a<=b. |
static double |
mod(double x,
double n)
Returns the mod; ie x-nfloor(x/n). |
static int |
nearestEven(int n,
boolean increasing)
Returns the nearest even number to the specified integer in the specified direction. |
static int |
nearestOdd(int n,
boolean increasing)
Returns the nearest odd number to the specified integer in the specified direction. |
static int |
nearestPowerOfTwo(int number)
Returns the nearest power of 2 number to the specified number. |
static void |
normalise(double[] doubles)
Normalises the doubles in the specified array by their sum. |
static void |
normalise(double[] doubles,
double sum)
Normalises the doubles in the array using the given value. |
static double |
normaliseDegrees180(double degrees)
Masks an angle to the [0:180] range. |
static double |
normaliseDegrees360(double degrees)
Masks an angle to the [0:360] range. |
static double |
normaliseRadians2PI(double radians)
Makes an angle in radians to the [0:2pi] range. |
static double |
normaliseRadiansPI(double radians)
Masks an angle to the [0:PI] range. |
static int |
numberDigits(int number)
Returns the number of digits in the specified integer number. |
static boolean |
oppositeSign(double x,
double y)
Tests whether the arguments have opposite sign. |
static boolean |
oppositeSignOrBothZero(double x,
double y,
double tolerance)
Returns logical-true if x and y have the same sign. |
static boolean |
oppositeSignOrZero(double x,
double y,
double tolerance)
Returns logical-true if x and y have the same sign. |
static double[] |
pascalTriangle(int n)
Returns the Pascal triangle sequence for the specified integer. |
static double |
poisson(double nu,
int n)
Returns the poisson distribution (nu^n e^(-nu) / n!). |
static double |
polarAngle(double x,
double y,
boolean degrees)
Returns the polar angle subtended by the specified x and y values. |
static double |
polarRadius(double x,
double y)
Returns the polar radius; ie sqrt(x^2+y^2). |
static PairDouble |
polarToXY(double r,
double theta,
boolean degrees)
Converts the specified (r,theta) polar pair to (x,y) rectangular coordinates. |
static double |
pow(double base,
double exponent)
Returns base to exponent. |
static int |
pow2(int n)
Returns 2^n. |
static int |
pow2Exponent(int x)
Returns the value of m for which 2^m=x. |
static float |
powFast(float base,
float exponent)
Computes a fast but less accurate approximation to Math.pow(base,exponent). |
static java.util.ArrayList<HInteger> |
primeNumbers(int n)
Returns a vector of all prime numbers upto and including the specified number, n. |
static java.util.ArrayList<HLong> |
primeNumbers(long n)
Returns a vector of all prime numbers upto and including the specified number, n. |
static PairInteger |
quotientRemainder(int numer,
int denom)
Same as div() but a slightly more descriptive method name! |
static double |
radiansToDegrees(double theta)
Converts radians to degrees. |
static void |
rightToLeftShift(java.lang.Object a,
java.lang.Object b,
java.lang.Object c,
java.lang.Object d)
Shifts objects (a,b,c,d) from right to left (i.e. |
static boolean |
sameSign(double x,
double y)
Returns logical-true if x and y have the same sign. |
static boolean |
sameSign(int x,
int y)
Returns logical-true if x and y have the same sign. |
static boolean |
sameSignOrBothZero(double x,
double y,
double tolerance)
Returns logical-true if x and y have the same sign. |
static boolean |
sameSignOrZero(double x,
double y,
double tolerance)
Returns logical-true if x and y have the same sign. |
static double |
sec(double x,
boolean degrees)
Returns the secant of the specified value; ie 1/cos(x). |
static double |
sech(double x)
Hyperbolic sech() function. |
static int |
sign(double x)
Returns -1 if x<0, 0 if x=0 and 1 if x>0. |
static double |
sign(double a,
double b)
If b>0 returns |a|, else returns -|a|. |
static int |
sign(int x)
Returns -1 if x<0, 0 if x=0 and 1 if x>0. |
static double |
sin(double x,
boolean degrees)
Returns sin(x). |
static double |
sinFast0(double x,
boolean degrees)
Fast sin(x). |
static double |
sinFast1(double x,
boolean degrees)
Fast sin(x). |
static double |
sinh(double x)
Hyperbolic sinh() function. |
static PairDouble |
sort(double a,
double b)
Sorts the specified double values (a,b) in increasing order. |
static PairDouble |
sort(double a,
double b,
boolean sortIncreasing)
Sorts the specified floating-point values (a,b) in increasing order. |
static TripleDouble |
sort(double a,
double b,
double c)
Sorts the specified double values (a,b,c) in increasing order. |
static TripleDouble |
sort(double a,
double b,
double c,
boolean sortIncreasing)
Sorts the specified floating-point values (a,b,c) in increasing order. |
static PairInteger |
sort(int a,
int b)
Sorts the specified integer values (a,b) in increasing order. |
static PairInteger |
sort(int a,
int b,
boolean sortIncreasing)
Sorts the specified integer values (a,b) in increasing order. |
static TripleInteger |
sort(int a,
int b,
int c)
Sorts the specified integer values (a,b,c) in increasing order. |
static TripleInteger |
sort(int a,
int b,
int c,
boolean sortIncreasing)
Sorts the specified integer values (a,b,c) in increasing order. |
static double |
sqr(double x)
Returns the square of the specified number; ie x^2. |
static double |
sqrt(double x)
Returns the square root of the specified value. |
static float |
sqrtFast0(float x)
Fast evaluation of the square root of the specified number. |
static double |
standardDeviation(double[] vector)
Returns the standard deviation of the specified array and returns INFINITE if the the vector is either empty of has only one element. |
static double |
sum(double[] doubles)
Returns the sum of the elements of an array of doubles. |
static int |
sum(int[] ints)
Returns the sum of the elements of an array of integers. |
static double |
symmetricRandom(int seed)
Generates a random number in the interval [-1,1). |
static double |
tan(double x,
boolean degrees)
Returns tan(x). |
static double |
tanFast0(double x,
boolean degrees)
Optimised version of tan(x). |
static double |
tanFast1(double x,
boolean degrees)
Optimised version of tan(x). |
static double |
tanh(double x)
Hyperbolic tanh() function. |
static double |
unitRandom(int seed)
Generates a random number in the interval [0,1). |
static double |
variance(double[] vector)
Computes the variance of the specified array of doubles. |
static double |
wholePart(double n)
Returns the whole part of a number, stripping out the negative sign if present. |
static double |
wholePartAndSign(double n)
Returns the whole part of a number, keeping negative sign if present. |
static boolean |
withinAbsoluteDifference(double a,
double b,
double absoluteTolerance)
Tests whether or not arguments a and b are within the specified absolute tolerance. |
static boolean |
withinPercentageDifference(double a,
double b,
int percentageTolerance)
Tests whether or not arguments a and b are within the specified percentage tolerance. |
static PairDouble |
xyToPolar(double x,
double y,
boolean degrees)
Combines polarRadius() and polarAngle() by returning a |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static int abs(int n)
n - Integer to return the absolute value of.
public static double abs(double n)
n - Double to return the absolute value of.
public static float abs(float n)
n - Float to return the absolute value of.
public static double bernoulliNumber(int n)
throws java.lang.IllegalArgumentException
n - Particular number.
java.lang.IllegalArgumentException - Thrown if n<0 or n>32.
public static double eulerNumber(int n)
throws java.lang.IllegalArgumentException
n - Particular number.
java.lang.IllegalArgumentException - Thrown if n<0 or n>18.
public static double betaFunction(double x,
double y)
x - Value x.y - Value y.
public static double binomialCoefficient(int k,
int i)
k - Value k.i - Value i.
public static double errorFunction(double x)
x - Value x.
public static double complementErrorFunction(double x)
x - Value x.
public static double factorial(int n)
n - Number to evaluate factorial.
public static double factorialDouble(int n)
n - Number to evaluate factorial.
public int fibonacci(int n)
n - Sequence number.
public static double fractionalPart(double n)
n - Number to extract the fractional part.
public static double degreesToRadians(double theta)
theta - Angle in degrees.
public static double radiansToDegrees(double theta)
theta - Angle in radians.
public static double normaliseDegrees360(double degrees)
degrees - The number of degrees.
public static double normaliseRadians2PI(double radians)
radians - The number of radians.
public static double normaliseDegrees180(double degrees)
degrees - The number of degrees.
public static double normaliseRadiansPI(double radians)
radians - The number of radians.
public static java.util.ArrayList<HInteger> primeNumbers(int n)
n - Number up to which primes to be generated.
public static java.util.ArrayList<HLong> primeNumbers(long n)
n - Number up to which primes to be generated.
public static int heavisideUnitStep(int t,
int c)
t - Variable t.c - Cutoff value.
public static double hypot(double a,
double b)
a - Side length a.b - Side length b.
public static double goldenRatio()
public static int gcd(int n,
int m)
n - Number n.m - Number m.
public static PairInteger div(int numer,
int denom)
numer - The numerator.denom - The denominator.
public static PairInteger quotientRemainder(int numer,
int denom)
numer - The numerator.denom - The denominator.
public static int hash(double x)
x - The value to be hashed.
public static double haverSine(double x)
x - Value x, must be specified in radians.
public static int intermediate(int a,
int b,
int c)
a - Number a.b - Number b.c - Number c.
public static double intermediate(double a,
double b,
double c)
a - Number a.b - Number b.c - Number c.
public static double intermediate_abs(double a,
double b,
double c)
a - Value 1.b - Value 2.c - Value 3.
public static double incompleteGammaFunction(double a,
double x)
a - Number a.x - Number x.
public static double complementIncompleteGammaFunction(double a,
double x)
a - Number a.x - Number x.
public static double gammaFunction(double z)
z - Number x.
public static double gser(double a,
double x)
a - Number a.x - Number x.
public static double gcf(double a,
double x)
a - Number a.x - Number x.
public static boolean isEven(int n)
n - Number (int) to test.
public static boolean isEven(long n)
n - Number (long) to test.
public static boolean isOdd(int n)
n - Number to test.
public static boolean isOdd(long n)
n - Number to test.
public static boolean isPrime(int n)
n - Number to test.
public static boolean isPrime(long n)
n - Number to test.
public static boolean isPythagoreanTriple(int x,
int y,
int z)
x - Value x.y - Value y.z - Value z.
public static boolean isPythagoreanTriple(long x,
long y,
long z)
x - Value x.y - Value y.z - Value z.
public static boolean isSorted(int a,
int b,
int c,
boolean increasingOrder)
a - First value.b - Second value.c - Third value.increasingOrder - Specifies whether or not the specified triple is to be tested in increasing order (true) or decreasing order (false).
public static boolean isSorted(int a,
int b,
boolean increasingOrder)
a - First value.b - Second value.increasingOrder - Specifies whether or not the specified pair is to be tested in increasing order (true) or decreasing order (false).
public static boolean isSorted(double a,
double b,
double c,
boolean increasingOrder)
double sequence is in order.
a - First value.b - Second value.c - Third value.increasingOrder - Specifies whether or not the specified triple is to be tested in increasing order (true) or decreasing order (false).
public static boolean isSorted(double a,
double b,
boolean increasingOrder)
double sequence is in order.
a - First value.b - Second value.increasingOrder - Specifies whether or not the specified pair is to be tested in increasing order (true) or decreasing order (false).
public static boolean isPowerOfTwo(int number)
number - The number to test.
public static int nearestPowerOfTwo(int number)
number - The number.
public static boolean isZero(int x)
x - Number to test.
public static boolean isZero(long x)
x - Number to test.
public static boolean isZero(double x,
double tolerance)
x - Number to test.tolerance - Tolerance against which x is compared.
public static double logGammaFunction(double z)
throws java.lang.IllegalArgumentException
z - Number z.
java.lang.IllegalArgumentException - Thrown if z < 0.
public static double logFactorial(int n)
throws java.lang.IllegalArgumentException
n - Number.
java.lang.IllegalArgumentException - Thrown if n < 0.
public static double poisson(double nu,
int n)
nu - n -
public static void leftToRightShift(java.lang.Object a,
java.lang.Object b,
java.lang.Object c,
java.lang.Object d)
a - Number a.b - Number b.c - Number c.d - Number d.
public static int max(int a,
int b)
a - Number a.b - Number b.
public static double max(double a,
double b)
a - Number a.b - Number b.
public static int max(int a,
int b,
int c)
a - Number a.b - Number b.c - Number c.
public static double max(double a,
double b,
double c)
a - Number a.b - Number b.c - Number c.
public static int min(int a,
int b)
a - Number a.b - Number b.
public static double min(double a,
double b)
a - Number a.b - Number b.
public static int min(int a,
int b,
int c)
a - Number a.b - Number b.c - Number c.
public static double min(double a,
double b,
double c)
a - Number a.b - Number b.c - Number c.
public static void rightToLeftShift(java.lang.Object a,
java.lang.Object b,
java.lang.Object c,
java.lang.Object d)
a - Number a.b - number b.c - Number c.d - Number d.public static double log10(double x)
x - The number.
public static double log2(double x)
x - The number.
public static double[] pascalTriangle(int n)
n - Order of sequence.
public static double asinh(double x)
x - The number.
public static double acosh(double x)
x - The number.
public static double atanh(double x)
x - The number.
public static boolean sameSign(int x,
int y)
x - Number x.y - Number y.
public static boolean sameSign(double x,
double y)
x - Number x.y - Number y.
public static int sign(int x)
x - Number to test.
public static int sign(double x)
x - Number to test.
public static double acos(double x)
x - Value to evaluate.
public static double asin(double x)
x - Value to evaluate.
public static double atan(double x)
x - Value.
public static double atan2(double y,
double x)
x, y) to polar
coordinates (r, theta).
y - The ordinate coordinate.x - The abscissa coordinate.
public static double acot(double x)
x - Value.
public static double ceil(double x)
x - Value.
public static double clamp(double val,
double min,
double max)
val - Value to clamp.min - Minimum value.max - Maximum value.
public static int clamp(int val,
int min,
int max)
val - Value to clamp.min - Minimum value.max - Maximum value.
public static double exp(double x)
x - Value.
public double expNegativeFast0(double x)
x - Value of x. Must be >0.
public double expNegativeFast1(double x)
x - Value of x. Must be >0.
public double expNegativeFast2(double x)
x - Value of x. Must be >0.
public double expNegativeFast3(double x)
x - Value of x. Must be >0.
public static double fabs(double x)
x - Value.
public static double floor(double x)
x - Value.
public static int floor2(int x)
throws java.lang.IllegalArgumentException
x - Value.
java.lang.IllegalArgumentException - Thrown if x is negative.
public static int ceil2(int x)
throws java.lang.IllegalArgumentException
x - Value.
java.lang.IllegalArgumentException - Thrown if x is negative.
public static double mod(double x,
double n)
throws java.lang.IllegalArgumentException
x - Numerator.n - Denominator.
java.lang.IllegalArgumentException - Thrown if n is equal to 0, within tolerance hedgehog.utility.Tolerances.ZERO.
public static double invSqrt(double x)
throws java.lang.IllegalArgumentException
x - Value.
java.lang.IllegalArgumentException - Thrown if x<=0.0.public static double log(double x)
x - Value.
public static int pow2(int n)
n - Exponent.
public static int pow2Exponent(int x)
throws java.lang.IllegalArgumentException
x - Value. Must be a power of 2.
java.lang.IllegalArgumentException - Thrown if x is not a power of 2.
public static double pow(double base,
double exponent)
base - Base value.exponent - Exponent value.
public static final float powFast(float base,
float exponent)
Math.pow(base,exponent).
base - A positive number.exponent - Power.
public static double sqr(double x)
x - Number to calculate the square of.
public static double sqrt(double x)
x - Number to calculate the square root of.
public static double cubeRoot(double x)
x - Number to calculate the cube root of.
public static float sqrtFast0(float x)
x - Number to evaluate.
public static double sin(double x,
boolean degrees)
x - Number x.degrees - Specifies whether or not x is in degrees or radians.
public static double cos(double x,
boolean degrees)
x - Number x.degrees - Specifies whether or not x is in degrees or radians.
public static double tan(double x,
boolean degrees)
x - Number x.degrees - Specifies whether or not x is in degrees or radians.
public static double cosh(double x)
x - Variable x.
public static double sinh(double x)
x - Variable x.
public static double tanh(double x)
x - Variable x.
public static double cosech(double x)
x - Variable x.
public static double sech(double x)
x - Variable x.
public static double coth(double x)
x - Variable x.
public static double cot(double x,
boolean degrees)
throws DivisionByZeroException
x - Variable x.degrees - Specifies whether or not the returned angle is in degrees or radians.
DivisionByZeroException - Thrown if in computing cot(x), tan(x) is zero.
public static double sec(double x,
boolean degrees)
throws DivisionByZeroException
x - Variable x.degrees - Specifies whether or not the returned angle is in degrees or radians.
DivisionByZeroException - Thrown if in computing sec(x), cos(x) is zero.
public static double sinFast0(double x,
boolean degrees)
x - Number.degrees - Specifies whether or not the returned value is in degrees or radians.
public static double sinFast1(double x,
boolean degrees)
x - Number to evaluate.degrees - Specifies whether or not the returned value is in degrees or radians.
public static double cosFast0(double x,
boolean degrees)
x - Number to evaluate.degrees - Specifies whether or not the returned value is in degrees or radians.
public static double cosFast1(double x,
boolean degrees)
x - Number to evaluate.degrees - Specifies whether or not the returned value is in degrees or radians.
public static double tanFast0(double x,
boolean degrees)
x - Number to evaluate.degrees - Specifies whether or not the returned value is in degrees or radians.
public static double tanFast1(double x,
boolean degrees)
x - Number to evaluate.degrees - Specifies whether or not the returned value is in degrees or radians.
public static double invSinFast0(double x,
boolean degrees)
x - Number to evaluate.degrees - Specifies whether or not the returned value is in degrees or radians.
public static double invSinFast1(double x,
boolean degrees)
x - Number to evaluate.degrees - Specifies whether or not the returned value is in degrees or radians.
public static double invCosFast0(double x,
boolean degrees)
x - Number to evaluate.degrees - Specifies whether or not the returned value is in degrees or radians.
public static double invCosFast1(double x,
boolean degrees)
x - Number to evaluate.degrees - Specifies whether or not the returned value is in degrees or radians.
public static double invTanFast0(double x,
boolean degrees)
x - Variable x.degrees - Specifies whether or not the returned value is in degrees or radians.
public static double invTanFast1(double x,
boolean degrees)
x - Variable x.degrees - Specifies whether or not the returned value is in degrees or radians.
public static final float invSqrtFast(float x)
x - Value that inverse square root required.
public static final double invSqrtFast(double x)
x - Value.
public static double difference(double a,
double b,
int method)
throws java.lang.IllegalArgumentException
a - Number 1.b - Number 2.method - Indicates the type of difference value returned:
0: a-b
1: |a-b|
2: (a-b)/a
3: (a-b)/b
4: |(a-b)/a|
5: |(a-b)/b|
6: |(a-b)/a|x100%
7: |(a-b)/b|*100%
java.lang.IllegalArgumentException - Thrown if the specified method is invalid or if for a particular method a potential division by zero would occur.
public static boolean withinAbsoluteDifference(double a,
double b,
double absoluteTolerance)
a - Number 1.b - Number 2.absoluteTolerance - Absolute tolerance.
public static boolean withinPercentageDifference(double a,
double b,
int percentageTolerance)
throws java.lang.IllegalArgumentException
a - Number 1.b - Number 2.percentageTolerance - Percentage tolerance.
java.lang.IllegalArgumentException - Thrown is percentageTolerance is out of range [0:100].
public static double fowlerAngle(double dy,
double dx)
(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0) correspond to ( 0, 45, 90, 135, 180, 225, 270, 315, 360) degrees, measured anticlockwise from the positive x-axisFor example fowlerAngle(2,4) = 0.5 and fowlerAngle(3,-4) = 3.25.
dy - Difference in y-direction.dx - Difference in x-direction.
polarAngle(double, double, boolean)
public static double polarAngle(double x,
double y,
boolean degrees)
x - Distance along the x-axis.y - Distance along the y-axis.degrees - Specifies whether or not the returned angle is in degrees, else radians.
polarRadius(double, double),
fowlerAngle(double, double)
public static double polarRadius(double x,
double y)
x - Distance along the x-axis.y - Distance along the y-axis.
polarAngle(double, double, boolean)
public static PairDouble xyToPolar(double x,
double y,
boolean degrees)
x - Distance along the x-axis.y - Distance along the y-axis.degrees - Specifies whether or not the returned angle is in degrees, else radians.
polarAngle(double, double, boolean),
polarRadius(double, double),
polarToXY(double, double, boolean)
public static PairDouble polarToXY(double r,
double theta,
boolean degrees)
r - Radial distance.theta - Angle subtended from x-axis. The angle can be positive or negative and multiples of 360 degrees
as rev() is used to mask the angle to the [0:360] range.degrees - Specifies whether or not the specified nagle is in degrees or radians.
xyToPolar(double, double, boolean)
public static boolean isSameValue(double x,
double y,
double tolerance)
x - Value.y - Other value.tolerance - Required tolerance.
public static java.util.Vector<HDouble> equallySpacedPointsInInterval(double a,
double b,
int n,
boolean includeEndPoints)
throws java.lang.IllegalArgumentException
a - Minimum of interval.b - Maximum of interval.n - Number of intermediate points.includeEndPoints - If true then points a and b are included in the returned vector, else not.
java.lang.IllegalArgumentException - Thrown if n<=0 or a>=b.
public static double maxAbs(double a,
double b)
a - Value 1.b - Value 2.
public static double maxAbs(double a,
double b,
double c)
a - Value 1.b - Value 2.c - Value 3.
public static void maxSort(HDouble a,
HDouble b)
a - Set upon return to the sorted value such that a>=b.b - Set upon return to the sorted value such that a>=b.
public static double minAbs(double a,
double b)
a - Value 1.b - Value 2.
public static double minAbs(double a,
double b,
double c)
a - Value 1.b - Value 2.c - Value 3.
public static void minSort(HDouble a,
HDouble b)
a - Set upon return to the sorted value such that a<=b.b - Set upon return to the sorted value such that a<=b.public static int maxIndex(double[] doubles)
doubles - The array of doubles
public static int maxIndex(int[] ints)
ints - The array of integers
public static int minIndex(int[] ints)
ints - The array of integers.
public static int minIndex(double[] doubles)
doubles - The array of doubles.
public static boolean oppositeSign(double x,
double y)
x - Value 1.y - Value 2.
public static boolean oppositeSignOrZero(double x,
double y,
double tolerance)
x - Value 1.y - Value 2.tolerance - Required tolerance.
public static boolean oppositeSignOrBothZero(double x,
double y,
double tolerance)
x - Value 1.y - Value 2.tolerance - Required tolerance.
public static boolean sameSignOrZero(double x,
double y,
double tolerance)
x - Value 1.y - Value 2.tolerance - Required tolerance.
public static boolean sameSignOrBothZero(double x,
double y,
double tolerance)
x - Value 1.y - Value 2.tolerance - Required tolerance.
public static double sign(double a,
double b)
a - Value one.b - Value two.
public static double degreesToHours(double degrees)
degrees - The number of degrees.
public static TripleDouble degreesToDegreesMinutesSeconds(double degrees)
degrees - The number of degrees.
public static double degreesMinutesSecondsToDegrees(double degrees,
double minutes,
double seconds)
degrees - The number of degrees.minutes - The number of minutes.seconds - The number of seconds.
public static double degreesMinutesSecondsToMinutes(double degrees,
double minutes,
double seconds)
degrees - The number of degrees.minutes - The number of minutes.seconds - The number of seconds.
public static double degreesMinutesSecondsToSeconds(double degrees,
double minutes,
double seconds)
degrees - The number of degrees.minutes - The number of minutes.seconds - The number of seconds.
public static double hoursToDegrees(double hours)
hours - The number of hours.
public static boolean isWholeNumber(double n,
double tolerance)
n - Number to test.tolerance - Required tolerance.
public static int nearestEven(int n,
boolean increasing)
n - Number to findest nearest even.increasing - Specifies whether or not the greater or lesser number is required.
public static int nearestOdd(int n,
boolean increasing)
n - Number to findest nearest odd.increasing - Specifies whether or not the greater or lesser number is required.
public static void normalise(double[] doubles)
doubles - the array of double
java.lang.IllegalArgumentException - if sum is Zero or NaN.
public static void normalise(double[] doubles,
double sum)
doubles - the array of doublesum - the value by which the doubles are to be normalized
java.lang.IllegalArgumentException - if sum is zero or NaNpublic static int numberDigits(int number)
number - Integer number.
public static boolean isNAN(double n)
n - Number to test.
public static double linearInterpolation(java.util.Vector<HDouble> sample_points,
double u)
throws java.lang.IllegalArgumentException
sample_points - The two sample points (i0,i1) and u(0<=u<=1) is the fractional distance from point 1 to point 2.u - u(0<=u<=1) is the fractional distances along the parametric axis.
java.lang.IllegalArgumentException - Thrown if sample_points does not have 2 elements or if u is out of range.
public static double linearInterpolation(java.util.Vector<HDouble> sample_points,
double u,
double v)
throws java.lang.IllegalArgumentException
sample_points - The four sample points (i00,i10,i11,i01).u - u(0<=u<=1) is the fractional distances along the parametric axis.v - v(0<=u<=1) is the fractional distances along the parametric axis.
java.lang.IllegalArgumentException
public static double linearInterpolation(java.util.Vector<HDouble> sample_points,
double u,
double v,
double w)
throws java.lang.IllegalArgumentException
sample_points - The eight sample points (i000,i100,i110,i010,i001,i101,i111,i011).u - u(0<=u<=1) is the fractional distances along the parametric axis.v - v(0<=u<=1) is the fractional distances along the parametric axis.w - w(0<=u<=1) is the fractional distances along the parametric axis.
java.lang.IllegalArgumentExceptionpublic static double wholePart(double n)
n - Number.
public static double wholePartAndSign(double n)
n - Number.
public static int bitCount1(long a)
a - Number to test.
public static long bitCount2(long a)
a - Number to test.
public static long bitCount3(long a)
a - Number to test.
public static double unitRandom(int seed)
seed - Random number generator seed.
public static double symmetricRandom(int seed)
seed - Random number generator see.
public static double intervalRandom(double min,
double max,
int seed)
min - Minimum number.max - maximum number.seed - Random number generator seed.
public static TripleInteger sort(int a,
int b,
int c)
a - Value a.b - Value b.c - Value c.
public static TripleDouble sort(double a,
double b,
double c)
a - Value a.b - Value b.c - Value c.
public static PairInteger sort(int a,
int b)
a - Value a.b - Value b.
public static PairDouble sort(double a,
double b)
double values (a,b) in increasing order.
a - Value a.b - Value b.
public static PairInteger sort(int a,
int b,
boolean sortIncreasing)
a - Value a.b - Value b.sortIncreasing - Specifies whether or not the specified pair are sorted in increasing (true) order or decreasing (false) order.
public static PairDouble sort(double a,
double b,
boolean sortIncreasing)
a - Value a.b - Value b.sortIncreasing - Specifies whether or not the specified pair are sorted in increasing (true) order or decreasing (false) order.
public static TripleInteger sort(int a,
int b,
int c,
boolean sortIncreasing)
a - Value a.b - Value b.c - Value c.sortIncreasing - Specifies whether or not the specified triple are sorted in increasing (true) order or decreasing (false) order.
public static TripleDouble sort(double a,
double b,
double c,
boolean sortIncreasing)
a - Value a.b - Value b.c - Value c.sortIncreasing - Specifies whether or not the specified triple are sorted in increasing (true) order or decreasing (false) order.
public static double mean(double[] vector)
vector - Array of doubles.
public static double standardDeviation(double[] vector)
vector - 1D Java array of floating-point values.
public static double variance(double[] vector)
vector - Array of doubles.
public static double covariance(double[] v1,
double[] v2)
throws java.lang.IllegalArgumentException
v1 - Array 1 of doubles.v2 - Array 2 of doubles.
java.lang.IllegalArgumentException - Thrown if v1 and v2 not of the same length.
public static double correlation(double[] v1,
double[] v2)
throws java.lang.IllegalArgumentException
v1 - Array 1 of doubles.v2 - Array 2 of doubles.
java.lang.IllegalArgumentException - Thrown if v1 and v2 not of the same length.public static double sum(double[] doubles)
doubles - The array of doubles.
public static int sum(int[] ints)
ints - the array of integers
public static double average(double[] doubles)
throws java.lang.IllegalArgumentException
doubles - The array of doubles.
java.lang.IllegalArgumentException - Thrown if doubles.length==0.
public static double average(int[] ints)
throws java.lang.IllegalArgumentException
ints - The array of ints.
java.lang.IllegalArgumentException - Thrown if ints.length==0.public static double erf(double x)
Evaluates the error function, defined as:
x
2 |\
erf(x) = --------- | exp(-t*t)dt
sqrt(pi) \|
0
erf() is frequently used to evaluate the Gauss/Normal distribution.
x - Value to erf().
errorFunction(double),
GaussDistributionpublic static double erfComplementary(double x)
x - Value to erfc(x).
complementErrorFunction(double)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||