|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectStatic
XMath
public final class XMath
Simple mathematical functions in addition to the ones provided in Math.
| utility/geotk-utility (download) | View source code for this class |
| Field Summary | |
|---|---|
static long |
SIGN_BIT_MASK
Deprecated. No replacement (this is considered internal mechanic). |
static double |
SQRT2
Deprecated. Moved to Apache SIS MathFunctions.SQRT_2. |
| Method Summary | |
|---|---|
static double |
adjacentForType(Class<? extends Number> type,
double value,
int amount)
Returns the number adjacent to the given value, as one of the nearest representable numbers of the given type. |
static double |
atanh(double x)
Deprecated. Moved to Apache SIS MathFunctions.atanh(double). |
static int[] |
commonDivisors(int... numbers)
Deprecated. Moved to Apache SIS MathFunctions.commonDivisors(int[]). |
static int[] |
divisors(int number)
Deprecated. Moved to Apache SIS MathFunctions.divisors(int). |
static boolean |
isNegative(double value)
Deprecated. Moved to Apache SIS MathFunctions.isNegative(double). |
static boolean |
isPositive(double value)
Deprecated. Moved to Apache SIS MathFunctions.isPositive(double). |
static boolean |
isSameSign(double v1,
double v2)
Deprecated. Moved to Apache SIS MathFunctions.isSameSign(double, double). |
static double |
magnitude(double... vector)
Deprecated. Moved to Apache SIS MathFunctions.magnitude(double[]). |
static double |
pow10(double x)
Deprecated. Moved to Apache SIS MathFunctions.pow10(double). |
static double |
pow10(int x)
Deprecated. Moved to Apache SIS MathFunctions.pow10(int). |
static int |
primeNumber(int index)
Deprecated. No public replacement. MathFunctions.nextPrimeNumber(int) is the closest replacement. |
static byte |
sgn(byte x)
Deprecated. Moved to Apache SIS MathFunctions.sgn(byte). |
static int |
sgn(double x)
Deprecated. Moved to Apache SIS MathFunctions.sgn(double). |
static int |
sgn(float x)
Deprecated. Moved to Apache SIS MathFunctions.sgn(float). |
static int |
sgn(int x)
Deprecated. Moved to Apache SIS MathFunctions.sgn(int). |
static int |
sgn(long x)
Deprecated. Moved to Apache SIS MathFunctions.sgn(long). |
static short |
sgn(short x)
Deprecated. Moved to Apache SIS MathFunctions.sgn(short). |
static float |
toNaN(int index)
Deprecated. Moved to Apache SIS MathFunctions.toNanFloat(int). |
static double |
xorSign(double value,
double sign)
Deprecated. Moved to Apache SIS MathFunctions.xorSign(double, double). |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
@Deprecated public static final double SQRT2
MathFunctions.SQRT_2.
@Deprecated public static final long SIGN_BIT_MASK
NaN values in a double.
For any value other than NaN, the following code evaluate to 0 if the given value
is positive:
Note that this idiom differentiates positive zero from negative zero. It should be used only when such difference matter.Double.doubleToRawLongBits(value) & SIGN_BIT_MASK;
isPositive(double),
isNegative(double),
Constant Field Values| Method Detail |
|---|
@Deprecated public static double magnitude(double... vector)
MathFunctions.magnitude(double[]).
sqrt(vector[0]² + vector[1]² + … + vector[length-1]²)
Implementation note
In the special case where only one element is different than zero, this method
returns directly the absolute value of that element
without computing sqrt(v²), in order to avoid rounding error. This special case
has been implemented because this method is often invoked for computing the length of
offset vectors,
typically aligned with the axes of a Cartesian coordinate system.
vector - The vector for which to compute the magnitude.
Math.hypot(double, double)@Deprecated public static double pow10(double x)
MathFunctions.pow10(double).
pow10((int) x) if x is an
integer, or to Math.pow(10, x)
otherwise.
x - The exponent.
pow10(int),
Math.pow(double, double)@Deprecated public static double pow10(int x)
MathFunctions.pow10(int).
Math.pow(10,x), sometime at the cost
of performance.
The Math.pow(10,x) method doesn't always return the closest IEEE floating point
representation. More accurate calculations are slower and usually not necessary, but the
base 10 is a special case since it is used for scaling axes or formatting human-readable
output, in which case the precision may matter.
x - The exponent.
@Deprecated public static double atanh(double x)
MathFunctions.atanh(double).
x - The value for which to compute the inverse hyperbolic tangent.
Math.tanh(double)@Deprecated public static boolean isPositive(double value)
MathFunctions.isPositive(double).
true if the given value is positive, excluding negative zero.
Special cases:
+0.0, returns true-0.0, returns falseNaN, returns false
As seen from the above cases, this method distinguishes positive zero from negative zero.
The handling of zero values is the difference between invoking isPositive(double)
and testing if (value >= 0).
value - The value to test.
true if the given value is positive, excluding negative zero.@Deprecated public static boolean isNegative(double value)
MathFunctions.isNegative(double).
true if the given value is negative, including negative zero.
Special cases:
+0.0, returns false-0.0, returns trueNaN, returns false
As seen from the above cases, this method distinguishes positive zero from negative zero.
The handling of zero values is the difference between invoking isNegative(double)
and testing if (value < 0).
value - The value to test.
true if the given value is negative, including negative zero.
@Deprecated
public static boolean isSameSign(double v1,
double v2)
MathFunctions.isSameSign(double, double).
true if the given values have the same sign, differentiating positive
and negative zeros. Special cases:
+0.0 and -0.0 are considered to have opposite signNaN, returns false
v1 - The first value.v2 - The second value, to compare the sign with the first value.
true if the given values are not NaN and have the same sign.Math.signum(double)@Deprecated public static int sgn(double x)
MathFunctions.sgn(double).
NaN and
+1 if x is positive.
x - The number from which to get the sign.
+1 if x is positive, -1 if negative, or 0 otherwise.Math.signum(double)@Deprecated public static int sgn(float x)
MathFunctions.sgn(float).
NaN and
+1 if x is positive.
x - The number from which to get the sign.
+1 if x is positive, -1 if negative, or 0 otherwise.Math.signum(float)@Deprecated public static int sgn(long x)
MathFunctions.sgn(long).
x - The number from which to get the sign.
+1 if x is positive, -1 if negative, or 0 otherwise.@Deprecated public static int sgn(int x)
MathFunctions.sgn(int).
x - The number from which to get the sign.
+1 if x is positive, -1 if negative, or 0 otherwise.@Deprecated public static short sgn(short x)
MathFunctions.sgn(short).
x - The number from which to get the sign.
+1 if x is positive, -1 if negative, or 0 otherwise.@Deprecated public static byte sgn(byte x)
MathFunctions.sgn(byte).
x - The number from which to get the sign.
+1 if x is positive, -1 if negative, or 0 otherwise.
@Deprecated
public static double xorSign(double value,
double sign)
MathFunctions.xorSign(double, double).
Math.copySign(value, sign) except that the sign is combined with an exclusive
or operation instead than being copied.
This method computes the same result than the formula below (using only standard functions
from Math) except that zeros and Double.NaN values for the sign
argument are treated as a positive or negative numbers.
return magnitude * signum(sign);
value - The parameter providing the value that may need a sign change.sign - The parameter providing the sign to xor with the value.
sign parameter is negative.Math.copySign(double, double)
public static double adjacentForType(Class<? extends Number> type,
double value,
int amount)
throws IllegalArgumentException
amount is positive, or in the direction of negative infinity if
amount is negative. Then this operation is repeated as many time as the absolute value
of amount. More specifically:
If type is an integer type (Integer, Short, etc.),
then this method returns value + amount. If value had a fractional part,
then this part is truncated before the addition is performed.
If type is Double, then this method is equivalent to invoking
Math.nextUp(value) if amount
is positive, or -Math.nextUp(-value) if amount is negative, and to
repeat this operation abs(amount) times.
If type is Float, then this method is equivalent to invoking
Math.nextUp((float) value) if amount
is positive, or -Math.nextUp((float) -value) if amount is negative,
and to repeat this operation abs(amount) times.
type - The type. Should be the class of Double, Float,
Long, Integer, Short or Byte.value - The number for which to find an adjacent number.amount - -1 to return the previous representable number,
+1 to return the next representable number,
or a multiple of the above.
double.
IllegalArgumentException - if type is not one of supported types.
@Deprecated
public static float toNaN(int index)
throws IndexOutOfBoundsException
MathFunctions.toNanFloat(int).
NaN number for the specified index. Valid NaN numbers have
bit fields ranging from 0x7f800001 through 0x7fffffff or 0xff800001
through 0xffffffff. The standard Float.NaN has bit fields 0x7fc00000.
See Float.intBitsToFloat(int) for more details on NaN bit values.
Tip: if the caller needs to ensure that the index is never out of bounds, he can
set the parameter value to index % 0x200000.
index - The index, from -2097152 to 2097151 inclusive.
NaN values as a float.
IndexOutOfBoundsException - if the specified index is out of bounds.Float.intBitsToFloat(int)
@Deprecated
public static int primeNumber(int index)
throws IndexOutOfBoundsException
MathFunctions.nextPrimeNumber(int) is the closest replacement.
index - The prime number index, starting at index 0 for prime number 2.
IndexOutOfBoundsException - if the specified index is too large.BigInteger.isProbablePrime(int)@Deprecated public static int[] divisors(int number)
MathFunctions.divisors(int).
O (which returns an empty array), the first element in the returned array
is always 1 and the last element is always the absolute value of number.
number - The number for which to compute the divisors.
@Deprecated public static int[] commonDivisors(int... numbers)
MathFunctions.commonDivisors(int[]).
numbers - The numbers for which to compute the divisors.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||