Package org.apache.commons.math.analysis.polynomials

Examples of org.apache.commons.math.analysis.polynomials.PolynomialFunction


    public void testQuinticFunction() throws MathException {
        double min, max, expected, result, tolerance;

        // p(x) = x^5 - x^4 - 12x^3 + x^2 - x - 12 = (x+1)(x+3)(x-4)(x^2-x+1)
        double coefficients[] = { -12.0, -1.0, 1.0, -12.0, -1.0, 1.0 };
        PolynomialFunction f = new PolynomialFunction(coefficients);
        UnivariateRealSolver solver = new LaguerreSolver();

        min = -2.0; max = 2.0; expected = -1.0;
        tolerance = Math.max(solver.getAbsoluteAccuracy(),
                    Math.abs(expected * solver.getRelativeAccuracy()));
 
View Full Code Here


    /**
     * Test of parameters for the solver.
     */
    public void testParameters() throws Exception {
        double coefficients[] = { -3.0, 5.0, 2.0 };
        PolynomialFunction f = new PolynomialFunction(coefficients);
        UnivariateRealSolver solver = new LaguerreSolver();

        try {
            // bad interval
            solver.solve(f, 1, -1);
View Full Code Here

                for (int i = 0; i < 10; ++i) {
                    double[] coeff = new double[degree + 1];
                    for (int k = 0; k < coeff.length; ++k) {
                        coeff[k] = 2 * random.nextDouble() - 1;
                    }
                    PolynomialFunction p = new PolynomialFunction(coeff);
                    double result    = integrator.integrate(p, -5.0, 15.0);
                    double reference = exactIntegration(p, -5.0, 15.0);
                    assertEquals(n + " " + degree + " " + i, reference, result, 1.0e-12 * (1.0 + Math.abs(reference)));
                }
            }
View Full Code Here

     * @return a fresh copy of the polynomial function
     * @deprecated as of 2.0 the function is not stored anymore within the instance.
     */
    @Deprecated
    public PolynomialFunction getPolynomialFunction() {
        return new PolynomialFunction(p.getCoefficients());
    }
View Full Code Here

            c[j] = z[j] - mu[j] * c[j + 1];
            b[j] = (y[j + 1] - y[j]) / h[j] - h[j] * (c[j + 1] + 2d * c[j]) / 3d;
            d[j] = (c[j + 1] - c[j]) / (3d * h[j]);
        }
       
        PolynomialFunction polynomials[] = new PolynomialFunction[n];
        double coefficients[] = new double[4];
        for (int i = 0; i < n; i++) {
            coefficients[0] = y[i];
            coefficients[1] = b[i];
            coefficients[2] = c[i];
            coefficients[3] = d[i];
            polynomials[i] = new PolynomialFunction(coefficients);
        }
       
        return new PolynomialSplineFunction(x, polynomials);
    }
View Full Code Here

     * @exception OptimizationException if the algorithm failed to converge
     */
    public PolynomialFunction fit()
        throws OptimizationException {
        try {
            return new PolynomialFunction(fitter.fit(new ParametricPolynomial(), new double[degree + 1]));
        } catch (FunctionEvaluationException fee) {
            // this should never happen
            throw MathRuntimeException.createInternalError(fee);
        }
    }
View Full Code Here

     * @return a fresh copy of the polynomial function
     * @deprecated as of 2.0 the function is not stored anymore within the instance.
     */
    @Deprecated
    public PolynomialFunction getPolynomialFunction() {
        return new PolynomialFunction(p.getCoefficients());
    }
View Full Code Here

            c[j] = z[j] - mu[j] * c[j + 1];
            b[j] = (y[j + 1] - y[j]) / h[j] - h[j] * (c[j + 1] + 2d * c[j]) / 3d;
            d[j] = (c[j + 1] - c[j]) / (3d * h[j]);
        }

        PolynomialFunction polynomials[] = new PolynomialFunction[n];
        double coefficients[] = new double[4];
        for (int i = 0; i < n; i++) {
            coefficients[0] = y[i];
            coefficients[1] = b[i];
            coefficients[2] = c[i];
            coefficients[3] = d[i];
            polynomials[i] = new PolynomialFunction(coefficients);
        }

        return new PolynomialSplineFunction(x, polynomials);
    }
View Full Code Here

     * @exception OptimizationException if the algorithm failed to converge
     */
    public PolynomialFunction fit()
        throws OptimizationException {
        try {
            return new PolynomialFunction(fitter.fit(new ParametricPolynomial(), new double[degree + 1]));
        } catch (FunctionEvaluationException fee) {
            // this should never happen
            throw MathRuntimeException.createInternalError(fee);
        }
    }
View Full Code Here

        points.add(point);
        fitter.addObservedPoint(1, point.RT, point.RT2);
      }
    }
    try {
      PolynomialFunction function = fitter.fit();
      for (AlignStructMol point : data) {
        double y = point.RT2;
        double bestY = function.value(point.RT);
        if (Math.abs(y - bestY) < t) {
          point.ransacAlsoInLiers = true;
          AlsoNumber++;
        } else {
          point.ransacAlsoInLiers = false;
View Full Code Here

TOP

Related Classes of org.apache.commons.math.analysis.polynomials.PolynomialFunction

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.