• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MaxIterationsExceededException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.math.MaxIterationsExceededException的典型用法代码示例。如果您正苦于以下问题:Java MaxIterationsExceededException类的具体用法?Java MaxIterationsExceededException怎么用?Java MaxIterationsExceededException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MaxIterationsExceededException类属于org.apache.commons.math包,在下文中一共展示了MaxIterationsExceededException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a real root in the given interval with initial value.
 * <p>
 * Requires bracketing condition.</p>
 * 
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @param initial the start value to use
 * @return the point at which the function value is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * or the solver detects convergence problems otherwise
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double solve(double min, double max, double initial) throws
    MaxIterationsExceededException, FunctionEvaluationException {

    // check for zeros before verifying bracketing
    if (f.value(min) == 0.0) { return min; }
    if (f.value(max) == 0.0) { return max; }
    if (f.value(initial) == 0.0) { return initial; }

    verifyBracketing(min, max, f);
    verifySequence(min, initial, max);
    if (isBracketing(min, initial, f)) {
        return solve(min, initial);
    } else {
        return solve(initial, max);
    }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:32,代码来源:MullerSolver.java


示例2: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a zero in the given interval.
 * <p>
 * Requires that the values of the function at the endpoints have opposite
 * signs. An <code>IllegalArgumentException</code> is thrown if this is not
 * the case.</p>
 * 
 * @param min the lower bound for the interval.
 * @param max the upper bound for the interval.
 * @return the value where the function is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function 
 * @throws IllegalArgumentException if min is not less than max or the
 * signs of the values of the function at the endpoints are not opposites
 */
public double solve(double min, double max) throws MaxIterationsExceededException, 
    FunctionEvaluationException {
    
    clearResult();
    verifyInterval(min, max);
    
    double yMin = f.value(min);
    double yMax = f.value(max);
    
    // Verify bracketing
    if (yMin * yMax >= 0) {
        throw new IllegalArgumentException
        ("Function values at endpoints do not have different signs." +
                "  Endpoints: [" + min + "," + max + "]" + 
                "  Values: [" + yMin + "," + yMax + "]");       
    }

    // solve using only the first endpoint as initial guess
    return solve(min, yMin, max, yMax, min, yMin);

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:38,代码来源:BrentSolver.java


示例3: integrate

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Integrate the function in the given interval.
 * 
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @return the value of integral
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * or the integrator detects convergence problems otherwise
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double integrate(double min, double max) throws MaxIterationsExceededException,
    FunctionEvaluationException, IllegalArgumentException {
    
    int i = 1;
    double t, oldt;
    
    clearResult();
    verifyInterval(min, max);
    verifyIterationCount();

    oldt = stage(min, max, 0);
    while (i <= maximalIterationCount) {
        t = stage(min, max, i);
        if (i >= minimalIterationCount) {
            if (Math.abs(t - oldt) <= Math.abs(relativeAccuracy * oldt)) {
                setResult(t, i);
                return result;
            }
        }
        oldt = t;
        i++;
    }
    throw new MaxIterationsExceededException(maximalIterationCount);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:37,代码来源:TrapezoidIntegrator.java


示例4: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a root in the given interval with initial value.
 * <p>
 * Requires bracketing condition.</p>
 * 
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @param initial the start value to use
 * @return the point at which the function value is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double solve(double min, double max, double initial) throws
    MaxIterationsExceededException, FunctionEvaluationException {

    // check for zeros before verifying bracketing
    if (f.value(min) == 0.0) { return min; }
    if (f.value(max) == 0.0) { return max; }
    if (f.value(initial) == 0.0) { return initial; }

    verifyBracketing(min, max, f);
    verifySequence(min, initial, max);
    if (isBracketing(min, initial, f)) {
        return solve(min, initial);
    } else {
        return solve(initial, max);
    }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:31,代码来源:RiddersSolver.java


示例5: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a zero near the value <code>startValue</code>.
 * 
 * @param min the lower bound for the interval (ignored).
 * @param max the upper bound for the interval (ignored).
 * @param startValue the start value to use.
 * @return the value where the function is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded 
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function or derivative
 * @throws IllegalArgumentException if startValue is not between min and max
 */
public double solve(double min, double max, double startValue)
    throws MaxIterationsExceededException, FunctionEvaluationException {
    
    clearResult();
    verifySequence(min, startValue, max);

    double x0 = startValue;
    double x1;
    
    int i = 0;
    while (i < maximalIterationCount) {
        x1 = x0 - (f.value(x0) / derivative.value(x0));
        if (Math.abs(x1 - x0) <= absoluteAccuracy) {
            
            setResult(x1, i);
            return x1;
        }
        
        x0 = x1;
        ++i;
    }
    
    throw new MaxIterationsExceededException(maximalIterationCount);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:37,代码来源:NewtonSolver.java


示例6: calculateThreshold

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
@SuppressWarnings("deprecation")
protected static double calculateThreshold(int[][] samples, int nClusters) throws MaxIterationsExceededException,
		FunctionEvaluationException
{
	int maxDistance = 0;
	for (int i = 0; i < samples.length; i++) {
		for (int j = i + 1; j < samples.length; j++) {
			distances[i][j] = distanceEuclidianSquared(samples[i], samples[j]);
			distances[j][i] = distances[i][j];
			if (distances[i][j] > maxDistance)
				maxDistance = distances[i][j];
		}
	}
	System.out.println("Distance matrix calculated");
	final BisectionSolver b = new BisectionSolver();
	b.setAbsoluteAccuracy(100.0);
	return b.solve(100, new ClusterMinimisationFunction(samples, distances, nClusters), 0, maxDistance);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:19,代码来源:IntRAC.java


示例7: integrate

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
    * {@inheritDoc}
    */
   @Override
public double integrate(final UnivariateRealFunction f,
                           final double min, final double max)
           throws MaxIterationsExceededException, FunctionEvaluationException, IllegalArgumentException {

       clearResult();
       verifyInterval(min, max);
       verifyIterationCount();

       double oldt = stage(f, min, max, 0);
       for (int i = 1; i <= maximalIterationCount; ++i) {
           final double t = stage(f, min, max, i);
           if (i >= minimalIterationCount) {
               final double delta = Math.abs(t - oldt);
               final double rLimit =
                       relativeAccuracy * (Math.abs(oldt) + Math.abs(t)) * 0.5;
               if ((delta <= rLimit) || (delta <= absoluteAccuracy)) {
                   setResult(t, i);
                   return result;
               }
           }
           oldt = t;
       }
       throw new MaxIterationsExceededException(maximalIterationCount);
   }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:29,代码来源:TrapezoidIntegrator.java


示例8: integrate

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/** {@inheritDoc} */
public double integrate(final UnivariateRealFunction f,
                        final double min, final double max)
    throws MaxIterationsExceededException, FunctionEvaluationException, IllegalArgumentException {

    clearResult();
    verifyInterval(min, max);
    verifyIterationCount();

    double oldt = stage(f, min, max, 0);
    for (int i = 1; i <= maximalIterationCount; ++i) {
        final double t = stage(f, min, max, i);
        if (i >= minimalIterationCount) {
            final double delta = Math.abs(t - oldt);
            final double rLimit =
                relativeAccuracy * (Math.abs(oldt) + Math.abs(t)) * 0.5;
            if ((delta <= rLimit) || (delta <= absoluteAccuracy)) {
                setResult(t, i);
                return result;
            }
        }
        oldt = t;
    }
    throw new MaxIterationsExceededException(maximalIterationCount);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:TrapezoidIntegrator.java


示例9: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a root in the given interval with initial value.
 * <p>
 * Requires bracketing condition.</p>
 * 
 * @param f the function to solve
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @param initial the start value to use
 * @return the point at which the function value is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double solve(final UnivariateRealFunction f,
                    final double min, final double max, final double initial)
    throws MaxIterationsExceededException, FunctionEvaluationException {

    // check for zeros before verifying bracketing
    if (f.value(min) == 0.0) { return min; }
    if (f.value(max) == 0.0) { return max; }
    if (f.value(initial) == 0.0) { return initial; }

    verifyBracketing(min, max, f);
    verifySequence(min, initial, max);
    if (isBracketing(min, initial, f)) {
        return solve(f, min, initial);
    } else {
        return solve(f, initial, max);
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:33,代码来源:RiddersSolver.java


示例10: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
    * Find a real root in the given interval with initial value.
    * <p>
    * Requires bracketing condition.</p>
    *
    * @param f       the function to solve
    * @param min     the lower bound for the interval
    * @param max     the upper bound for the interval
    * @param initial the start value to use
    * @return the point at which the function value is zero
    * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
    *                                        or the solver detects convergence problems otherwise
    * @throws FunctionEvaluationException    if an error occurs evaluating the
    *                                        function
    * @throws IllegalArgumentException       if any parameters are invalid
    */
   @Override
public double solve(final UnivariateRealFunction f,
                       final double min, final double max, final double initial)
           throws MaxIterationsExceededException, FunctionEvaluationException {

       // check for zeros before verifying bracketing
       if (f.value(min) == 0.0) {
           return min;
       }
       if (f.value(max) == 0.0) {
           return max;
       }
       if (f.value(initial) == 0.0) {
           return initial;
       }

       verifyBracketing(min, max, f);
       verifySequence(min, initial, max);
       if (isBracketing(min, initial, f)) {
           return solve(f, min, initial);
       } else {
           return solve(f, initial, max);
       }
   }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:41,代码来源:MullerSolver.java


示例11: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a root in the given interval with initial value.
 * <p>
 * Requires bracketing condition.</p>
 *
 * @param f the function to solve
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @param initial the start value to use
 * @return the point at which the function value is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double solve(final UnivariateRealFunction f,
                    final double min, final double max, final double initial)
    throws MaxIterationsExceededException, FunctionEvaluationException {

    // check for zeros before verifying bracketing
    if (f.value(min) == 0.0) { return min; }
    if (f.value(max) == 0.0) { return max; }
    if (f.value(initial) == 0.0) { return initial; }

    verifyBracketing(min, max, f);
    verifySequence(min, initial, max);
    if (isBracketing(min, initial, f)) {
        return solve(f, min, initial);
    } else {
        return solve(f, initial, max);
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:33,代码来源:RiddersSolver.java


示例12: testQuinticMax

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
@Test
public void testQuinticMax() throws MathException {
    // The quintic function has zeros at 0, +-0.5 and +-1.
    // The function has extrema (first derivative is zero) at 0.27195613 and 0.82221643,
    UnivariateRealFunction f = new QuinticFunction();
    UnivariateRealOptimizer minimizer = new BrentOptimizer();
    assertEquals(0.27195613, minimizer.optimize(f, GoalType.MAXIMIZE, 0.2, 0.3), 1.0e-8);
    minimizer.setMaximalIterationCount(30);
    try {
        minimizer.optimize(f, GoalType.MAXIMIZE, 0.2, 0.3);
        fail("an exception should have been thrown");
    } catch (MaxIterationsExceededException miee) {
        // expected
    } catch (Exception e) {
        fail("wrong exception caught");
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:BrentMinimizerTest.java


示例13: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a real root in the given interval with initial value.
 * <p>
 * Requires bracketing condition.</p>
 *
 * @param f the function to solve
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @param initial the start value to use
 * @return the point at which the function value is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * or the solver detects convergence problems otherwise
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double solve(final UnivariateRealFunction f,
                    final double min, final double max, final double initial)
    throws MaxIterationsExceededException, FunctionEvaluationException {

    // check for zeros before verifying bracketing
    if (f.value(min) == 0.0) { return min; }
    if (f.value(max) == 0.0) { return max; }
    if (f.value(initial) == 0.0) { return initial; }

    verifyBracketing(min, max, f);
    verifySequence(min, initial, max);
    if (isBracketing(min, initial, f)) {
        return solve(f, min, initial);
    } else {
        return solve(f, initial, max);
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:34,代码来源:MullerSolver.java


示例14: cumulativeProbability

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * For this disbution, X, this method returns P(X &lt; <code>x</code>).
 * @param x the value at which the CDF is evaluated.
 * @return CDF evaluted at <code>x</code>. 
 * @throws MathException if the algorithm fails to converge; unless
 * x is more than 20 standard deviations from the mean, in which case the
 * convergence exception is caught and 0 or 1 is returned.
 */
public double cumulativeProbability(double x) throws MathException {
    try {
        return 0.5 * (1.0 + Erf.erf((x - mean) /
                (standardDeviation * Math.sqrt(2.0))));
    } catch (MaxIterationsExceededException ex) {
        if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38
            return 0.0d;
        } else if (x > (mean + 20 * standardDeviation)) {
            return 1.0d;
        } else {
            throw ex;
        }
    }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:23,代码来源:NormalDistributionImpl.java


示例15: regularizedGammaP

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Returns the regularized gamma function P(a, x).
 * 
 * The implementation of this method is based on:
 * <ul>
 * <li>
 * <a href="http://mathworld.wolfram.com/RegularizedGammaFunction.html">
 * Regularized Gamma Function</a>, equation (1).</li>
 * <li>
 * <a href="http://mathworld.wolfram.com/IncompleteGammaFunction.html">
 * Incomplete Gamma Function</a>, equation (4).</li>
 * <li>
 * <a href="http://mathworld.wolfram.com/ConfluentHypergeometricFunctionoftheFirstKind.html">
 * Confluent Hypergeometric Function of the First Kind</a>, equation (1).
 * </li>
 * </ul>
 * 
 * @param a the a parameter.
 * @param x the value.
 * @param epsilon When the absolute value of the nth item in the
 *                series is less than epsilon the approximation ceases
 *                to calculate further elements in the series.
 * @param maxIterations Maximum number of "iterations" to complete. 
 * @return the regularized gamma function P(a, x)
 * @throws MathException if the algorithm fails to converge.
 */
public static double regularizedGammaP(double a, 
                                       double x, 
                                       double epsilon, 
                                       int maxIterations) 
    throws MathException
{
    double ret;

    if (Double.isNaN(a) || Double.isNaN(x) || (a <= 0.0) || (x < 0.0)) {
        ret = Double.NaN;
    } else if (x == 0.0) {
        ret = 0.0;
    } else if (a >= 1.0 && x > a) {
        // use regularizedGammaQ because it should converge faster in this
        // case.
        ret = 1.0 - regularizedGammaQ(a, x, epsilon, maxIterations);
    } else {
        // calculate series
        double n = 0.0; // current element index
        double an = 1.0 / a; // n-th element in the series
        double sum = an; // partial sum
        while (Math.abs(an) > epsilon && n < maxIterations) {
            // compute next element in the series
            n = n + 1.0;
            an = an * (x / (a + n));

            // update partial sum
            sum = sum + an;
        }
        if (n >= maxIterations) {
            throw new MaxIterationsExceededException(maxIterations);
        } else {
            ret = Math.exp(-x + (a * Math.log(x)) - logGamma(a)) * sum;
        }
    }

    return ret;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:65,代码来源:Gamma.java


示例16: solve

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find a zero root in the given interval.
 * 
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @return the value where the function is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded.
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if min is not less than max
 */
public double solve(double min, double max) throws MaxIterationsExceededException,
    FunctionEvaluationException {
    
    clearResult();
    verifyInterval(min,max);
    double m;
    double fm;
    double fmin;
    
    int i = 0;
    while (i < maximalIterationCount) {
        m = UnivariateRealSolverUtils.midpoint(min, max);
       fmin = f.value(min);
       fm = f.value(m);

        if (fm * fmin > 0.0) {
            // max and m bracket the root.
            min = m;
        } else {
            // min and m bracket the root.
            max = m;
        }

        if (Math.abs(max - min) <= absoluteAccuracy) {
            m = UnivariateRealSolverUtils.midpoint(min, max);
            setResult(m, i);
            return m;
        }
        ++i;
    }
    
    throw new MaxIterationsExceededException(maximalIterationCount);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:45,代码来源:BisectionSolver.java


示例17: integrate

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Integrate the function in the given interval.
 * 
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @return the value of integral
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * or the integrator detects convergence problems otherwise
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double integrate(double min, double max) throws MaxIterationsExceededException,
    FunctionEvaluationException, IllegalArgumentException {
    
    int i = 1;
    double s, olds, t, oldt;
    
    clearResult();
    verifyInterval(min, max);
    verifyIterationCount();

    TrapezoidIntegrator qtrap = new TrapezoidIntegrator(this.f);
    if (minimalIterationCount == 1) {
        s = (4 * qtrap.stage(min, max, 1) - qtrap.stage(min, max, 0)) / 3.0;
        setResult(s, 1);
        return result;
    }
    // Simpson's rule requires at least two trapezoid stages.
    olds = 0;
    oldt = qtrap.stage(min, max, 0);
    while (i <= maximalIterationCount) {
        t = qtrap.stage(min, max, i);
        s = (4 * t - oldt) / 3.0;
        if (i >= minimalIterationCount) {
            if (Math.abs(s - olds) <= Math.abs(relativeAccuracy * olds)) {
                setResult(s, i);
                return result;
            }
        }
        olds = s;
        oldt = t;
        i++;
    }
    throw new MaxIterationsExceededException(maximalIterationCount);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:47,代码来源:SimpsonIntegrator.java


示例18: solveAll

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Find all complex roots for the polynomial with the given coefficients,
 * starting from the given initial value.
 * 
 * @param coefficients the polynomial coefficients array
 * @param initial the start value to use
 * @return the point at which the function value is zero
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * or the solver detects convergence problems otherwise
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function 
 * @throws IllegalArgumentException if any parameters are invalid
 */
public Complex[] solveAll(Complex coefficients[], Complex initial) throws
    MaxIterationsExceededException, FunctionEvaluationException {

    int n = coefficients.length - 1;
    int iterationCount = 0;
    if (n < 1) {
        throw new IllegalArgumentException
            ("Polynomial degree must be positive: degree=" + n);
    }
    Complex c[] = new Complex[n+1];    // coefficients for deflated polynomial
    for (int i = 0; i <= n; i++) {
        c[i] = coefficients[i];
    }

    // solve individual root successively
    Complex root[] = new Complex[n];
    for (int i = 0; i < n; i++) {
        Complex subarray[] = new Complex[n-i+1];
        System.arraycopy(c, 0, subarray, 0, subarray.length);
        root[i] = solve(subarray, initial);
        // polynomial deflation using synthetic division
        Complex newc = c[n-i];
        Complex oldc = null;
        for (int j = n-i-1; j >= 0; j--) {
            oldc = c[j];
            c[j] = newc;
            newc = oldc.add(newc.multiply(root[i]));
        }
        iterationCount += this.iterationCount;
    }

    resultComputed = true;
    this.iterationCount = iterationCount;
    return root;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:49,代码来源:LaguerreSolver.java


示例19: integrate

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/**
 * Integrate the function in the given interval.
 * 
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @return the value of integral
 * @throws MaxIterationsExceededException if the maximum iteration count is exceeded
 * or the integrator detects convergence problems otherwise
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 * @throws IllegalArgumentException if any parameters are invalid
 */
public double integrate(double min, double max) throws MaxIterationsExceededException,
    FunctionEvaluationException, IllegalArgumentException {
    
    int i = 1, j, m = maximalIterationCount + 1;
    // Array strcture here can be improved for better space
    // efficiency because only the lower triangle is used.
    double r, t[][] = new double[m][m], s, olds;

    clearResult();
    verifyInterval(min, max);
    verifyIterationCount();

    TrapezoidIntegrator qtrap = new TrapezoidIntegrator(this.f);
    t[0][0] = qtrap.stage(min, max, 0);
    olds = t[0][0];
    while (i <= maximalIterationCount) {
        t[i][0] = qtrap.stage(min, max, i);
        for (j = 1; j <= i; j++) {
            // Richardson extrapolation coefficient
            r = (1L << (2 * j)) -1;
            t[i][j] = t[i][j-1] + (t[i][j-1] - t[i-1][j-1]) / r;
        }
        s = t[i][i];
        if (i >= minimalIterationCount) {
            if (Math.abs(s - olds) <= Math.abs(relativeAccuracy * olds)) {
                setResult(s, i);
                return result;
            }
        }
        olds = s;
        i++;
    }
    throw new MaxIterationsExceededException(maximalIterationCount);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:47,代码来源:RombergIntegrator.java


示例20: integrate

import org.apache.commons.math.MaxIterationsExceededException; //导入依赖的package包/类
/** {@inheritDoc} */
public double integrate(final UnivariateRealFunction f,
        final double min, final double max)
    throws ConvergenceException,  FunctionEvaluationException, IllegalArgumentException {

    clearResult();
    verifyInterval(min, max);
    verifyIterationCount();

    // compute first estimate with a single step
    double oldt = stage(f, min, max, 1);

    int n = 2;
    for (int i = 0; i < maximalIterationCount; ++i) {

        // improve integral with a larger number of steps
        final double t = stage(f, min, max, n);

        // estimate error
        final double delta = Math.abs(t - oldt);
        final double limit =
            Math.max(absoluteAccuracy,
                     relativeAccuracy * (Math.abs(oldt) + Math.abs(t)) * 0.5);

        // check convergence
        if ((i + 1 >= minimalIterationCount) && (delta <= limit)) {
            setResult(t, i);
            return result;
        }

        // prepare next iteration
        double ratio = Math.min(4, Math.pow(delta / limit, 0.5 / abscissas.length));
        n = Math.max((int) (ratio * n), n + 1);
        oldt = t;

    }

    throw new MaxIterationsExceededException(maximalIterationCount);

}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:41,代码来源:LegendreGaussIntegrator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Manager类代码示例发布时间:2022-05-21
下一篇:
Java Element类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap