本文整理汇总了Java中org.apache.commons.math3.analysis.polynomials.PolynomialFunction.degree方法的典型用法代码示例。如果您正苦于以下问题:Java PolynomialFunction.degree方法的具体用法?Java PolynomialFunction.degree怎么用?Java PolynomialFunction.degree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.analysis.polynomials.PolynomialFunction
的用法示例。
在下文中一共展示了PolynomialFunction.degree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCompose
import org.apache.commons.math3.analysis.polynomials.PolynomialFunction; //导入方法依赖的package包/类
@Test
public void testCompose() {
PolynomialFunction poly =
new PolynomialFunction(new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 });
for (double x = 0.1; x < 1.2; x += 0.001) {
SparseGradient sgX = SparseGradient.createVariable(0, x);
SparseGradient sgY1 = sgX.getField().getZero();
for (int i = poly.degree(); i >= 0; --i) {
sgY1 = sgY1.multiply(sgX).add(poly.getCoefficients()[i]);
}
SparseGradient sgY2 = sgX.compose(poly.value(x), poly.derivative().value(x));
SparseGradient zero = sgY1.subtract(sgY2);
checkF0F1(zero, 0.0, 0.0);
}
}
示例2: testCompose
import org.apache.commons.math3.analysis.polynomials.PolynomialFunction; //导入方法依赖的package包/类
@Test
public void testCompose() {
double[] epsilon = new double[] { 1.0e-20, 5.0e-14, 2.0e-13, 3.0e-13, 2.0e-13, 1.0e-20 };
PolynomialFunction poly =
new PolynomialFunction(new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 });
for (int maxOrder = 0; maxOrder < 6; ++maxOrder) {
PolynomialFunction[] p = new PolynomialFunction[maxOrder + 1];
p[0] = poly;
for (int i = 1; i <= maxOrder; ++i) {
p[i] = p[i - 1].polynomialDerivative();
}
for (double x = 0.1; x < 1.2; x += 0.001) {
DerivativeStructure dsX = new DerivativeStructure(1, maxOrder, 0, x);
DerivativeStructure dsY1 = dsX.getField().getZero();
for (int i = poly.degree(); i >= 0; --i) {
dsY1 = dsY1.multiply(dsX).add(poly.getCoefficients()[i]);
}
double[] f = new double[maxOrder + 1];
for (int i = 0; i < f.length; ++i) {
f[i] = p[i].value(x);
}
DerivativeStructure dsY2 = dsX.compose(f);
DerivativeStructure zero = dsY1.subtract(dsY2);
for (int n = 0; n <= maxOrder; ++n) {
Assert.assertEquals(0.0, zero.getPartialDerivative(n), epsilon[n]);
}
}
}
}