Package org.apache.commons.math

Examples of org.apache.commons.math.FunctionEvaluationException


      MultivariateRealFunction wrong =
          new MultivariateRealFunction() {
            private static final long serialVersionUID = 4751314470965489371L;
            public double value(double[] x) throws FunctionEvaluationException {
                if (x[0] < 0) {
                    throw new FunctionEvaluationException(x, "{0}", "oops");
                } else if (x[0] > 1) {
                    throw new FunctionEvaluationException(new RuntimeException("oops"), x);
                } else {
                    return x[0] * (1 - x[0]);
                }
            }
      };
View Full Code Here


      MultivariateRealFunction wrong =
          new MultivariateRealFunction() {
            private static final long serialVersionUID = 4751314470965489371L;
            public double value(double[] x) throws FunctionEvaluationException {
                if (x[0] < 0) {
                    throw new FunctionEvaluationException(x, "{0}", "oops");
                } else if (x[0] > 1) {
                    throw new FunctionEvaluationException(new RuntimeException("oops"), x);
                } else {
                    return x[0] * (1 - x[0]);
                }
            }
      };
View Full Code Here

        optimizer.optimize(new DifferentiableMultivariateVectorialFunction() {
                public MultivariateMatrixFunction jacobian() {
                    return null;
                }
                public double[] value(double[] point) throws FunctionEvaluationException {
                    throw new FunctionEvaluationException(point[0]);
                }
            }, new double[] { 2 }, new double[] { 1 }, new double[] { 0 });
    }
View Full Code Here

        }
       
        @Override
        public double value(double xx) throws FunctionEvaluationException{
            if (xx < x[0] || xx > x[n]){
                throw new FunctionEvaluationException(xx, "Argument " + xx + " is not in the domain of this function.");
            }
            // This speeds things up if the function is sampled at several
            // closely spaced x-values
            int i = lastindex;
            if (x[i] < xx && x[i+1] > xx){
View Full Code Here

    @Override
    public double value(double x) throws FunctionEvaluationException {
        UnivariateRealFunction seg = getSegmentFor(x);
        if(seg == null){
            throw new FunctionEvaluationException(x, "Argument outside domain: " + x);
        }
           
        return seg.value(x);
    }
View Full Code Here

              public double value(double t) throws FunctionEvaluationException {
                  try {
                      interpolator.setInterpolatedTime(t);
                      return function.g(t, interpolator.getInterpolatedState());
                  } catch (DerivativeException e) {
                      throw new FunctionEvaluationException(t, e);
                  }
              }
          });
          solver.setAbsoluteAccuracy(convergence);
          solver.setMaximalIterationCount(maxIterationCount);
View Full Code Here

            public double value(double x) throws FunctionEvaluationException {
                double ret = Double.NaN;
                try {
                    ret = cumulativeProbability(x) - p;
                } catch (MathException ex) {
                    throw new FunctionEvaluationException(x, ex.getSpecificPattern(), ex.getGeneralPattern(), ex.getArguments());
                }
                if (Double.isNaN(ret)) {
                    throw new FunctionEvaluationException(x, LocalizedFormats.CUMULATIVE_PROBABILITY_RETURNED_NAN, x, p);
                }
                return ret;
            }
        };
View Full Code Here

    /** {@inheritDoc} */
    public double value(double z) throws FunctionEvaluationException {
        try {
            return evaluate(x, y, z);
        } catch (DuplicateSampleAbscissaException e) {
            throw new FunctionEvaluationException(z, e.getSpecificPattern(), e.getGeneralPattern(), e.getArguments());
        }
    }
View Full Code Here

     */
    protected void updateJacobian() throws FunctionEvaluationException {
        ++jacobianEvaluations;
        jacobian = jF.value(point);
        if (jacobian.length != rows) {
            throw new FunctionEvaluationException(point, "dimension mismatch {0} != {1}",
                                                  jacobian.length, rows);
        }
        for (int i = 0; i < rows; i++) {
            final double[] ji = jacobian[i];
            final double factor = -Math.sqrt(weights[i]);
View Full Code Here

     */
    protected void updateResidualsAndCost()
        throws FunctionEvaluationException {

        if (++objectiveEvaluations > maxEvaluations) {
            throw new FunctionEvaluationException(new MaxEvaluationsExceededException(maxEvaluations),
                                                  point);
        }
        objective = f.value(point);
        if (objective.length != rows) {
            throw new FunctionEvaluationException(point, "dimension mismatch {0} != {1}",
                                                  objective.length, rows);
        }
        cost = 0;
        for (int i = 0, index = 0; i < rows; i++, index += cols) {
            final double residual = target[i] - objective[i];
View Full Code Here

TOP

Related Classes of org.apache.commons.math.FunctionEvaluationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.