本文整理汇总了Java中org.apache.commons.math3.analysis.polynomials.PolynomialFunction.getCoefficients方法的典型用法代码示例。如果您正苦于以下问题:Java PolynomialFunction.getCoefficients方法的具体用法?Java PolynomialFunction.getCoefficients怎么用?Java PolynomialFunction.getCoefficients使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.analysis.polynomials.PolynomialFunction
的用法示例。
在下文中一共展示了PolynomialFunction.getCoefficients方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPolynomialFunctionAST
import org.apache.commons.math3.analysis.polynomials.PolynomialFunction; //导入方法依赖的package包/类
/**
* Creates the polynomial function AST that encodes the give polynomial function.
*
* @param pf polynomial function. The starting knot corresponds to zero for this function.
* @param knot starting knot for this function
*
* @return AST node representing the function
*/
private static ASTNode createPolynomialFunctionAST(PolynomialFunction pf, double knot) {
double[] coefficients = pf.getCoefficients();
ASTNode sum = new ASTNode(ASTNode.Type.PLUS);
// Coefficients start with the constant then x^1, x^2 and so on
sum.addChild(new ASTNode(coefficients[0]));
for (int i=1; i<coefficients.length; ++i) {
sum.addChild(
ASTNode.times(
new ASTNode(coefficients[i]),
ASTNode.pow(createTimeMinusOffsetAST(knot), i)));
}
return sum;
}
示例2: exactIntegration
import org.apache.commons.math3.analysis.polynomials.PolynomialFunction; //导入方法依赖的package包/类
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;
}
示例3: checkPolynomial
import org.apache.commons.math3.analysis.polynomials.PolynomialFunction; //导入方法依赖的package包/类
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);
}
}