当前位置: 首页>>代码示例>>Java>>正文


Java LocalizedFormats.NUMBER_TOO_SMALL属性代码示例

本文整理汇总了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);
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:33,代码来源:MultivariateNormalMixtureExpectationMaximization.java

示例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));
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:37,代码来源:TriangularDistribution.java

示例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);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:15,代码来源:NumberIsTooSmallException.java

示例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 &lt; 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
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:43,代码来源:Primes.java

示例5: primeFactors

/**
 * Prime factors decomposition
 *
 * @param n number to factorize: must be &ge; 2
 * @return list of prime factors of n
 * @throws MathIllegalArgumentException if n &lt; 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);

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:18,代码来源:Primes.java


注:本文中的org.apache.commons.math3.exception.util.LocalizedFormats.NUMBER_TOO_SMALL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。