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


Java FunctionEvaluationException类代码示例

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


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

示例1: solve

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的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: set

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的package包/类
public Vec set(final Random random, final double noise, final Constants.TypeAdd type)
{
    try {
        counts.mapToSelf(new UnivariateRealFunction() {
            @Override
            public double value(double d) throws FunctionEvaluationException
            {
                return (type == TypeAdd.RANDOM) ? Math.pow(1 + random.nextDouble(), noise) :
                                         random.nextDouble() * noise;
            }
        });
    }
    catch (FunctionEvaluationException ex) {
        LogInfo.error(ex);
    }
    return computeSum();
}
 
开发者ID:sinantie,项目名称:Generator,代码行数:18,代码来源:SparseVec.java

示例3: wrap

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的package包/类
/**
 * @param f An OG n-D function mapping doubles onto doubles, not null
 * @return A Commons multivariate real function
 */
public static MultivariateRealFunction wrap(final FunctionND<Double, Double> f) {
  Validate.notNull(f);
  return new MultivariateRealFunction() {

    @Override
    public double value(final double[] point) throws FunctionEvaluationException, IllegalArgumentException {
      final int n = point.length;
      final Double[] coordinate = new Double[n];
      for (int i = 0; i < n; i++) {
        coordinate[i] = point[i];
      }
      return f.evaluate(coordinate);
    }
  };
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:CommonsMathWrapper.java

示例4: wrapDifferentiable

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的package包/类
/**
 * @param f An OG 1-D function mapping doubles to doubles, not null
 * @return A Commons differentiable univariate real function
 */
public static DifferentiableUnivariateRealFunction wrapDifferentiable(final DoubleFunction1D f) {
  Validate.notNull(f);
  return new DifferentiableUnivariateRealFunction() {

    @Override
    public double value(final double x) throws FunctionEvaluationException {
      return f.evaluate(x);
    }

    @Override
    public UnivariateRealFunction derivative() {
      return wrapUnivariate(f.derivative());
    }
  };
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:CommonsMathWrapper.java

示例5: stepAccepted

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的package包/类
/** Acknowledge the fact the step has been accepted by the integrator.
 * @param t value of the independent <i>time</i> variable at the
 * end of the step
 * @param y array containing the current value of the state vector
 * at the end of the step
 * @exception FunctionEvaluationException if the value of the switching
 * function cannot be evaluated
 */
public void stepAccepted(double t, double[] y)
  throws FunctionEvaluationException {

  t0 = t;
  g0 = function.g(t, y);

  if (pendingEvent) {
    // force the sign to its value "just after the event"
    previousEventTime = t;
    g0Positive        = increasing;
    nextAction        = function.eventOccurred(t, y);
  } else {
    g0Positive = (g0 >= 0);
    nextAction = SwitchingFunction.CONTINUE;
  }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:25,代码来源:SwitchState.java

示例6: solve

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的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

示例7: stage

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的package包/类
/**
 * Compute the n-th stage integral of trapezoid rule. This function
 * should only be called by API <code>integrate()</code> in the package.
 * To save time it does not verify arguments - caller does.
 * <p>
 * The interval is divided equally into 2^n sections rather than an
 * arbitrary m sections because this configuration can best utilize the
 * alrealy computed values.</p>
 *
 * @param min the lower bound for the interval
 * @param max the upper bound for the interval
 * @param n the stage of 1/2 refinement, n = 0 is no refinement
 * @return the value of n-th stage integral
 * @throws FunctionEvaluationException if an error occurs evaluating the
 * function
 */
double stage(double min, double max, int n) throws
    FunctionEvaluationException {
    
    long i, np;
    double x, spacing, sum = 0;
    
    if (n == 0) {
        s = 0.5 * (max - min) * (f.value(min) + f.value(max));
        return s;
    } else {
        np = 1L << (n-1);           // number of new points in this stage
        spacing = (max - min) / np; // spacing between adjacent new points
        x = min + 0.5 * spacing;    // the first new point
        for (i = 0; i < np; i++) {
            sum += f.value(x);
            x += spacing;
        }
        // add the new sum to previously calculated result
        s = 0.5 * (s + sum * spacing);
        return s;
    }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:39,代码来源:TrapezoidIntegrator.java

示例8: integrate

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的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

示例9: solve

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的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 ConvergenceException 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
    ConvergenceException, FunctionEvaluationException {

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

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

示例10: solve

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的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

示例11: solve

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的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

示例12: set

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的package包/类
public Vec set(final Random random, final double noise, final TypeAdd type)
{
    try {
        counts.mapToSelf(new UnivariateRealFunction() {
            @Override
            public double value(double d) throws FunctionEvaluationException
            {
                return (type == TypeAdd.RANDOM) ? Math.pow(1 + random.nextDouble(), noise) :
                                         random.nextDouble() * noise;
            }
        });
    }
    catch (FunctionEvaluationException ex) {
        LogInfo.error(ex);
    }
    return computeSum();
}
 
开发者ID:sinantie,项目名称:PLTAG,代码行数:18,代码来源:SparseVec.java

示例13: updateSource

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的package包/类
@Override
public void updateSource(float time) {
	BLightMedium lightMedium = (BLightMedium) getMind().getSpace().getMedium(BSpace.AvailableMedium.Light);
	
	float intensity =  lightMedium.getLightIntensity(callback.getPosition(), -1);
	try{
	intensity = settings.clampX(intensity);
	float output = (float) function.value(intensity/settings.getScaleX())*settings.getScaleY();	
	this.state = settings.clampY(output);
	}catch(FunctionEvaluationException e)
	{
		StateManager.logError(e);
		state = settings.clampY(intensity);
	}

}
 
开发者ID:sambayless,项目名称:golems,代码行数:17,代码来源:BLightSensor.java

示例14: generateSignal

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的package包/类
@Override
public float generateSignal(float time) 
{
	 if ((!this.switchActive) && (this.switchType == SwitchType.On))	
		 return 0;
	
	float output = 0;
	try{
		//a null pointer here is tied to physics not deleting...
		output = settings.clampY( (float) function.value(settings.clampX(currentTime/settings.getScaleX()))*settings.getScaleY());

		
	}catch(FunctionEvaluationException e)
	{
		StateManager.getLogger().log(Level.WARNING, e.getStackTrace().toString());
		//send no signal on error
	}
	if(this.switchActive && this.switchType==SwitchType.Invert)
		output = -output;

	
	return output;
}
 
开发者ID:sambayless,项目名称:golems,代码行数:24,代码来源:BFunctionSource.java

示例15: calculateThreshold

import org.apache.commons.math.FunctionEvaluationException; //导入依赖的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


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