当前位置: 首页>>代码示例>>Java>>正文


Java PolynomialFunction.degree方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:16,代码来源:SparseGradientTest.java

示例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]);
            }
        }
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:30,代码来源:DerivativeStructureTest.java


注:本文中的org.apache.commons.math3.analysis.polynomials.PolynomialFunction.degree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。