MATH-468
Forgot to commit that file! git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1055929 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dd199c3ef8
commit
81d30ccd16
|
@ -35,6 +35,7 @@ import org.apache.commons.math.exception.MathArithmeticException;
|
||||||
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
import org.apache.commons.math.exception.MathIllegalArgumentException;
|
||||||
import org.apache.commons.math.exception.MathRuntimeException;
|
import org.apache.commons.math.exception.MathRuntimeException;
|
||||||
import org.apache.commons.math.exception.NumberIsTooLargeException;
|
import org.apache.commons.math.exception.NumberIsTooLargeException;
|
||||||
|
import org.apache.commons.math.exception.NotFiniteNumberException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some useful additions to the built-in functions in {@link Math}.
|
* Some useful additions to the built-in functions in {@link Math}.
|
||||||
|
@ -1840,6 +1841,35 @@ public final class MathUtils {
|
||||||
checkOrder(val, OrderDirection.INCREASING, true);
|
checkOrder(val, OrderDirection.INCREASING, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that the argument is a real number.
|
||||||
|
*
|
||||||
|
* @param x Argument.
|
||||||
|
* @throws NotFiniteNumberException if {@code x} is not a
|
||||||
|
* finite real number.
|
||||||
|
*/
|
||||||
|
public static void checkFinite(final double x) {
|
||||||
|
if (Double.isInfinite(x) || Double.isNaN(x)) {
|
||||||
|
throw new NotFiniteNumberException(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that all the elements are real number.
|
||||||
|
*
|
||||||
|
* @param val Arguments.
|
||||||
|
* @throws NotFiniteNumberException if any values of the array is not a
|
||||||
|
* finite real number.
|
||||||
|
*/
|
||||||
|
public static void checkFinite(final double[] val) {
|
||||||
|
for (int i = 0; i < val.length; i++) {
|
||||||
|
final double x = val[i];
|
||||||
|
if (Double.isInfinite(x) || Double.isNaN(x)) {
|
||||||
|
throw new NotFiniteNumberException(LocalizedFormats.ARRAY_ELEMENT, x, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Cartesian norm (2-norm), handling both overflow and underflow.
|
* Returns the Cartesian norm (2-norm), handling both overflow and underflow.
|
||||||
* Translation of the minpack enorm subroutine.
|
* Translation of the minpack enorm subroutine.
|
||||||
|
|
Loading…
Reference in New Issue