Java Code Examples for org.apache.commons.math3.analysis.polynomials.PolynomialFunction#getCoefficients()

The following examples show how to use org.apache.commons.math3.analysis.polynomials.PolynomialFunction#getCoefficients() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LegendreGaussIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private double exactIntegration(PolynomialFunction p, double a, double b) {
    final double[] coeffs = p.getCoefficients();
    double yb = coeffs[coeffs.length - 1] / coeffs.length;
    double ya = yb;
    for (int i = coeffs.length - 2; i >= 0; --i) {
        yb = yb * b + coeffs[i] / (i + 1);
        ya = ya * a + coeffs[i] / (i + 1);
    }
    return yb * b - ya * a;
}
 
Example 2
Source File: HermiteInterpolatorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void checkPolynomial(PolynomialFunction expected, PolynomialFunction result) {
    Assert.assertTrue(result.degree() >= expected.degree());
    double[] cE = expected.getCoefficients();
    double[] cR = result.getCoefficients();
    for (int i = 0; i < cE.length; ++i) {
        Assert.assertEquals(cE[i], cR[i], 1.0e-8 * FastMath.abs(cE[i]));
    }
    for (int i = cE.length; i < cR.length; ++i) {
        Assert.assertEquals(0.0, cR[i], 1.0e-9);
    }
}
 
Example 3
Source File: HermiteInterpolatorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void checkPolynomial(PolynomialFunction expected, PolynomialFunction result) {
    Assert.assertTrue(result.degree() >= expected.degree());
    double[] cE = expected.getCoefficients();
    double[] cR = result.getCoefficients();
    for (int i = 0; i < cE.length; ++i) {
        Assert.assertEquals(cE[i], cR[i], 1.0e-8 * FastMath.abs(cE[i]));
    }
    for (int i = cE.length; i < cR.length; ++i) {
        Assert.assertEquals(0.0, cR[i], 1.0e-9);
    }
}
 
Example 4
Source File: LegendreGaussIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private double exactIntegration(PolynomialFunction p, double a, double b) {
    final double[] coeffs = p.getCoefficients();
    double yb = coeffs[coeffs.length - 1] / coeffs.length;
    double ya = yb;
    for (int i = coeffs.length - 2; i >= 0; --i) {
        yb = yb * b + coeffs[i] / (i + 1);
        ya = ya * a + coeffs[i] / (i + 1);
    }
    return yb * b - ya * a;
}
 
Example 5
Source File: IterativeLegendreGaussIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private double exactIntegration(PolynomialFunction p, double a, double b) {
    final double[] coeffs = p.getCoefficients();
    double yb = coeffs[coeffs.length - 1] / coeffs.length;
    double ya = yb;
    for (int i = coeffs.length - 2; i >= 0; --i) {
        yb = yb * b + coeffs[i] / (i + 1);
        ya = ya * a + coeffs[i] / (i + 1);
    }
    return yb * b - ya * a;
}
 
Example 6
Source File: HermiteInterpolatorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void checkPolynomial(PolynomialFunction expected, PolynomialFunction result) {
    Assert.assertTrue(result.degree() >= expected.degree());
    double[] cE = expected.getCoefficients();
    double[] cR = result.getCoefficients();
    for (int i = 0; i < cE.length; ++i) {
        Assert.assertEquals(cE[i], cR[i], 1.0e-8 * FastMath.abs(cE[i]));
    }
    for (int i = cE.length; i < cR.length; ++i) {
        Assert.assertEquals(0.0, cR[i], 1.0e-9);
    }
}
 
Example 7
Source File: LegendreGaussIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private double exactIntegration(PolynomialFunction p, double a, double b) {
    final double[] coeffs = p.getCoefficients();
    double yb = coeffs[coeffs.length - 1] / coeffs.length;
    double ya = yb;
    for (int i = coeffs.length - 2; i >= 0; --i) {
        yb = yb * b + coeffs[i] / (i + 1);
        ya = ya * a + coeffs[i] / (i + 1);
    }
    return yb * b - ya * a;
}
 
Example 8
Source File: IterativeLegendreGaussIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private double exactIntegration(PolynomialFunction p, double a, double b) {
    final double[] coeffs = p.getCoefficients();
    double yb = coeffs[coeffs.length - 1] / coeffs.length;
    double ya = yb;
    for (int i = coeffs.length - 2; i >= 0; --i) {
        yb = yb * b + coeffs[i] / (i + 1);
        ya = ya * a + coeffs[i] / (i + 1);
    }
    return yb * b - ya * a;
}
 
Example 9
Source File: LegendreGaussIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private double exactIntegration(PolynomialFunction p, double a, double b) {
    final double[] coeffs = p.getCoefficients();
    double yb = coeffs[coeffs.length - 1] / coeffs.length;
    double ya = yb;
    for (int i = coeffs.length - 2; i >= 0; --i) {
        yb = yb * b + coeffs[i] / (i + 1);
        ya = ya * a + coeffs[i] / (i + 1);
    }
    return yb * b - ya * a;
}
 
Example 10
Source File: HermiteInterpolatorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void checkPolynomial(PolynomialFunction expected, PolynomialFunction result) {
    Assert.assertTrue(result.degree() >= expected.degree());
    double[] cE = expected.getCoefficients();
    double[] cR = result.getCoefficients();
    for (int i = 0; i < cE.length; ++i) {
        Assert.assertEquals(cE[i], cR[i], 1.0e-8 * FastMath.abs(cE[i]));
    }
    for (int i = cE.length; i < cR.length; ++i) {
        Assert.assertEquals(0.0, cR[i], 1.0e-9);
    }
}
 
Example 11
Source File: IterativeLegendreGaussIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private double exactIntegration(PolynomialFunction p, double a, double b) {
    final double[] coeffs = p.getCoefficients();
    double yb = coeffs[coeffs.length - 1] / coeffs.length;
    double ya = yb;
    for (int i = coeffs.length - 2; i >= 0; --i) {
        yb = yb * b + coeffs[i] / (i + 1);
        ya = ya * a + coeffs[i] / (i + 1);
    }
    return yb * b - ya * a;
}
 
Example 12
Source File: IterativeLegendreGaussIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private double exactIntegration(PolynomialFunction p, double a, double b) {
    final double[] coeffs = p.getCoefficients();
    double yb = coeffs[coeffs.length - 1] / coeffs.length;
    double ya = yb;
    for (int i = coeffs.length - 2; i >= 0; --i) {
        yb = yb * b + coeffs[i] / (i + 1);
        ya = ya * a + coeffs[i] / (i + 1);
    }
    return yb * b - ya * a;
}
 
Example 13
Source File: HermiteInterpolatorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void checkPolynomial(PolynomialFunction expected, PolynomialFunction result) {
    Assert.assertTrue(result.degree() >= expected.degree());
    double[] cE = expected.getCoefficients();
    double[] cR = result.getCoefficients();
    for (int i = 0; i < cE.length; ++i) {
        Assert.assertEquals(cE[i], cR[i], 1.0e-8 * FastMath.abs(cE[i]));
    }
    for (int i = cE.length; i < cR.length; ++i) {
        Assert.assertEquals(0.0, cR[i], 1.0e-9);
    }
}
 
Example 14
Source File: LegendreGaussIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private double exactIntegration(PolynomialFunction p, double a, double b) {
    final double[] coeffs = p.getCoefficients();
    double yb = coeffs[coeffs.length - 1] / coeffs.length;
    double ya = yb;
    for (int i = coeffs.length - 2; i >= 0; --i) {
        yb = yb * b + coeffs[i] / (i + 1);
        ya = ya * a + coeffs[i] / (i + 1);
    }
    return yb * b - ya * a;
}
 
Example 15
Source File: IterativeLegendreGaussIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private double exactIntegration(PolynomialFunction p, double a, double b) {
    final double[] coeffs = p.getCoefficients();
    double yb = coeffs[coeffs.length - 1] / coeffs.length;
    double ya = yb;
    for (int i = coeffs.length - 2; i >= 0; --i) {
        yb = yb * b + coeffs[i] / (i + 1);
        ya = ya * a + coeffs[i] / (i + 1);
    }
    return yb * b - ya * a;
}
 
Example 16
Source File: HermiteInterpolatorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void checkPolynomial(PolynomialFunction expected, PolynomialFunction result) {
    Assert.assertTrue(result.degree() >= expected.degree());
    double[] cE = expected.getCoefficients();
    double[] cR = result.getCoefficients();
    for (int i = 0; i < cE.length; ++i) {
        Assert.assertEquals(cE[i], cR[i], 1.0e-8 * FastMath.abs(cE[i]));
    }
    for (int i = cE.length; i < cR.length; ++i) {
        Assert.assertEquals(0.0, cR[i], 1.0e-9);
    }
}
 
Example 17
Source File: LegendreGaussIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private double exactIntegration(PolynomialFunction p, double a, double b) {
    final double[] coeffs = p.getCoefficients();
    double yb = coeffs[coeffs.length - 1] / coeffs.length;
    double ya = yb;
    for (int i = coeffs.length - 2; i >= 0; --i) {
        yb = yb * b + coeffs[i] / (i + 1);
        ya = ya * a + coeffs[i] / (i + 1);
    }
    return yb * b - ya * a;
}
 
Example 18
Source File: IterativeLegendreGaussIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private double exactIntegration(PolynomialFunction p, double a, double b) {
    final double[] coeffs = p.getCoefficients();
    double yb = coeffs[coeffs.length - 1] / coeffs.length;
    double ya = yb;
    for (int i = coeffs.length - 2; i >= 0; --i) {
        yb = yb * b + coeffs[i] / (i + 1);
        ya = ya * a + coeffs[i] / (i + 1);
    }
    return yb * b - ya * a;
}
 
Example 19
Source File: HermiteInterpolatorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void checkPolynomial(PolynomialFunction expected, PolynomialFunction result) {
    Assert.assertTrue(result.degree() >= expected.degree());
    double[] cE = expected.getCoefficients();
    double[] cR = result.getCoefficients();
    for (int i = 0; i < cE.length; ++i) {
        Assert.assertEquals(cE[i], cR[i], 1.0e-8 * FastMath.abs(cE[i]));
    }
    for (int i = cE.length; i < cR.length; ++i) {
        Assert.assertEquals(0.0, cR[i], 1.0e-9);
    }
}
 
Example 20
Source File: LegendreGaussIntegratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private double exactIntegration(PolynomialFunction p, double a, double b) {
    final double[] coeffs = p.getCoefficients();
    double yb = coeffs[coeffs.length - 1] / coeffs.length;
    double ya = yb;
    for (int i = coeffs.length - 2; i >= 0; --i) {
        yb = yb * b + coeffs[i] / (i + 1);
        ya = ya * a + coeffs[i] / (i + 1);
    }
    return yb * b - ya * a;
}