本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.NUMBER_TOO_SMALL属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.NUMBER_TOO_SMALL属性的具体用法?Java LocalizedFormats.NUMBER_TOO_SMALL怎么用?Java LocalizedFormats.NUMBER_TOO_SMALL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.NUMBER_TOO_SMALL属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MultivariateNormalMixtureExpectationMaximization
/**
* Creates an object to fit a multivariate normal mixture model to data.
*
* @param data Data to use in fitting procedure
* @throws NotStrictlyPositiveException if data has no rows
* @throws DimensionMismatchException if rows of data have different numbers
* of columns
* @throws NumberIsTooSmallException if the number of columns in the data is
* less than 2
*/
public MultivariateNormalMixtureExpectationMaximization(double[][] data)
throws NotStrictlyPositiveException,
DimensionMismatchException,
NumberIsTooSmallException {
if (data.length < 1) {
throw new NotStrictlyPositiveException(data.length);
}
this.data = new double[data.length][data[0].length];
for (int i = 0; i < data.length; i++) {
if (data[i].length != data[0].length) {
// Jagged arrays not allowed
throw new DimensionMismatchException(data[i].length,
data[0].length);
}
if (data[i].length < 2) {
throw new NumberIsTooSmallException(LocalizedFormats.NUMBER_TOO_SMALL,
data[i].length, 2, true);
}
this.data[i] = MathArrays.copyOf(data[i], data[i].length);
}
}
示例2: TriangularDistribution
/**
* Creates a triangular distribution.
*
* @param rng Random number generator.
* @param a Lower limit of this distribution (inclusive).
* @param b Upper limit of this distribution (inclusive).
* @param c Mode of this distribution.
* @throws NumberIsTooLargeException if {@code a >= b} or if {@code c > b}.
* @throws NumberIsTooSmallException if {@code c < a}.
* @since 3.1
*/
public TriangularDistribution(RandomGenerator rng,
double a,
double c,
double b)
throws NumberIsTooLargeException, NumberIsTooSmallException {
super(rng);
if (a >= b) {
throw new NumberIsTooLargeException(
LocalizedFormats.LOWER_BOUND_NOT_BELOW_UPPER_BOUND,
a, b, false);
}
if (c < a) {
throw new NumberIsTooSmallException(
LocalizedFormats.NUMBER_TOO_SMALL, c, a, true);
}
if (c > b) {
throw new NumberIsTooLargeException(
LocalizedFormats.NUMBER_TOO_LARGE, c, b, true);
}
this.a = a;
this.c = c;
this.b = b;
solverAbsoluteAccuracy = FastMath.max(FastMath.ulp(a), FastMath.ulp(b));
}
示例3: NumberIsTooSmallException
/**
* Construct the exception.
*
* @param wrong Value that is smaller than the minimum.
* @param min Minimum.
* @param boundIsAllowed Whether {@code min} is included in the allowed range.
*/
public NumberIsTooSmallException(Number wrong,
Number min,
boolean boundIsAllowed) {
this(boundIsAllowed ?
LocalizedFormats.NUMBER_TOO_SMALL :
LocalizedFormats.NUMBER_TOO_SMALL_BOUND_EXCLUDED,
wrong, min, boundIsAllowed);
}
示例4: nextPrime
/**
* Return the smallest prime greater than or equal to n.
*
* @param n a positive number.
* @return the smallest prime greater than or equal to n.
* @throws MathIllegalArgumentException if n < 0.
*/
public static int nextPrime(int n) {
if (n < 0) {
throw new MathIllegalArgumentException(LocalizedFormats.NUMBER_TOO_SMALL, n, 0);
}
if (n == 2) {
return 2;
}
n |= 1;//make sure n is odd
if (n == 1) {
return 2;
}
if (isPrime(n)) {
return n;
}
// prepare entry in the +2, +4 loop:
// n should not be a multiple of 3
final int rem = n % 3;
if (0 == rem) { // if n % 3 == 0
n += 2; // n % 3 == 2
} else if (1 == rem) { // if n % 3 == 1
// if (isPrime(n)) return n;
n += 4; // n % 3 == 2
}
while (true) { // this loop skips all multiple of 3
if (isPrime(n)) {
return n;
}
n += 2; // n % 3 == 1
if (isPrime(n)) {
return n;
}
n += 4; // n % 3 == 2
}
}
示例5: primeFactors
/**
* Prime factors decomposition
*
* @param n number to factorize: must be ≥ 2
* @return list of prime factors of n
* @throws MathIllegalArgumentException if n < 2.
*/
public static List<Integer> primeFactors(int n) {
if (n < 2) {
throw new MathIllegalArgumentException(LocalizedFormats.NUMBER_TOO_SMALL, n, 2);
}
// slower than trial div unless we do an awful lot of computation
// (then it finally gets JIT-compiled efficiently
// List<Integer> out = PollardRho.primeFactors(n);
return SmallPrimes.trialDivision(n);
}