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


Java Inverse类代码示例

本文整理汇总了Java中org.apache.commons.math3.analysis.function.Inverse的典型用法代码示例。如果您正苦于以下问题:Java Inverse类的具体用法?Java Inverse怎么用?Java Inverse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Inverse类属于org.apache.commons.math3.analysis.function包,在下文中一共展示了Inverse类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMath832

import org.apache.commons.math3.analysis.function.Inverse; //导入依赖的package包/类
@Test
public void testMath832() {
    final UnivariateFunction f = new UnivariateFunction() {
            private final UnivariateDifferentiableFunction sqrt = new Sqrt();
            private final UnivariateDifferentiableFunction inv = new Inverse();
            private final UnivariateDifferentiableFunction func
                = FunctionUtils.add(FunctionUtils.multiply(new Constant(1e2), sqrt),
                                    FunctionUtils.multiply(new Constant(1e6), inv),
                                    FunctionUtils.multiply(new Constant(1e4),
                                                           FunctionUtils.compose(inv, sqrt)));

            public double value(double x) {
                return func.value(new DerivativeStructure(1, 1, 0, x)).getPartialDerivative(1);
            }

        };

    BrentSolver solver = new BrentSolver();
    final double result = solver.solve(99, f, 1, 1e30, 1 + 1e-10);
    Assert.assertEquals(804.93558250, result, 1e-8);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:22,代码来源:BrentSolverTest.java

示例2: testMultiplyDifferentiable

import org.apache.commons.math3.analysis.function.Inverse; //导入依赖的package包/类
@Test
public void testMultiplyDifferentiable() {
    UnivariateDifferentiableFunction c = new Constant(4);
    UnivariateDifferentiableFunction id = new Identity();
    final double a = 1.2345678;
    Assert.assertEquals(8 * a, FunctionUtils.multiply(c, id, id).value(new DerivativeStructure(1, 1, 0, a)).getPartialDerivative(1), EPS);

    UnivariateDifferentiableFunction inv = new Inverse();
    UnivariateDifferentiableFunction pow = new Power(2.5);
    UnivariateDifferentiableFunction cos = new Cos();
    Assert.assertEquals(1.5 * FastMath.sqrt(a) * FastMath.cos(a) - FastMath.pow(a, 1.5) * FastMath.sin(a),
                        FunctionUtils.multiply(inv, pow, cos).value(new DerivativeStructure(1, 1, 0, a)).getPartialDerivative(1), EPS);

    UnivariateDifferentiableFunction cosh = new Cosh();
    Assert.assertEquals(1.5 * FastMath.sqrt(a) * FastMath.cosh(a) + FastMath.pow(a, 1.5) * FastMath.sinh(a),
                        FunctionUtils.multiply(inv, pow, cosh).value(new DerivativeStructure(1, 1, 0, a)).getPartialDerivative(1), 8 * EPS);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:18,代码来源:FunctionUtilsTest.java

示例3: testCompose

import org.apache.commons.math3.analysis.function.Inverse; //导入依赖的package包/类
@Test
public void testCompose() {
    UnivariateFunction id = new Identity();
    Assert.assertEquals(3, FunctionUtils.compose(id, id, id).value(3), EPS);

    UnivariateFunction c = new Constant(4);
    Assert.assertEquals(4, FunctionUtils.compose(id, c).value(3), EPS);
    Assert.assertEquals(4, FunctionUtils.compose(c, id).value(3), EPS);

    UnivariateFunction m = new Minus();
    Assert.assertEquals(-3, FunctionUtils.compose(m).value(3), EPS);
    Assert.assertEquals(3, FunctionUtils.compose(m, m).value(3), EPS);

    UnivariateFunction inv = new Inverse();
    Assert.assertEquals(-0.25, FunctionUtils.compose(inv, m, c, id).value(3), EPS);

    UnivariateFunction pow = new Power(2);
    Assert.assertEquals(81, FunctionUtils.compose(pow, pow).value(3), EPS);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:FunctionUtilsTest.java

示例4: testComposeDifferentiable

import org.apache.commons.math3.analysis.function.Inverse; //导入依赖的package包/类
@Test
public void testComposeDifferentiable() {
    UnivariateDifferentiableFunction id = new Identity();
    Assert.assertEquals(1, FunctionUtils.compose(id, id, id).value(new DerivativeStructure(1, 1, 0, 3)).getPartialDerivative(1), EPS);

    UnivariateDifferentiableFunction c = new Constant(4);
    Assert.assertEquals(0, FunctionUtils.compose(id, c).value(new DerivativeStructure(1, 1, 0, 3)).getPartialDerivative(1), EPS);
    Assert.assertEquals(0, FunctionUtils.compose(c, id).value(new DerivativeStructure(1, 1, 0, 3)).getPartialDerivative(1), EPS);

    UnivariateDifferentiableFunction m = new Minus();
    Assert.assertEquals(-1, FunctionUtils.compose(m).value(new DerivativeStructure(1, 1, 0, 3)).getPartialDerivative(1), EPS);
    Assert.assertEquals(1, FunctionUtils.compose(m, m).value(new DerivativeStructure(1, 1, 0, 3)).getPartialDerivative(1), EPS);

    UnivariateDifferentiableFunction inv = new Inverse();
    Assert.assertEquals(0.25, FunctionUtils.compose(inv, m, id).value(new DerivativeStructure(1, 1, 0, 2)).getPartialDerivative(1), EPS);

    UnivariateDifferentiableFunction pow = new Power(2);
    Assert.assertEquals(108, FunctionUtils.compose(pow, pow).value(new DerivativeStructure(1, 1, 0, 3)).getPartialDerivative(1), EPS);

    UnivariateDifferentiableFunction log = new Log();
    double a = 9876.54321;
    Assert.assertEquals(pow.value(new DerivativeStructure(1, 1, 0, a)).getPartialDerivative(1) / pow.value(a),
                        FunctionUtils.compose(log, pow).value(new DerivativeStructure(1, 1, 0, a)).getPartialDerivative(1), EPS);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:25,代码来源:FunctionUtilsTest.java

示例5: testMultiplyDifferentiable

import org.apache.commons.math3.analysis.function.Inverse; //导入依赖的package包/类
@Test
public void testMultiplyDifferentiable() {
    UnivariateDifferentiableFunction c = new Constant(4);
    UnivariateDifferentiableFunction id = new Identity();
    final double a = 1.2345678;
    Assert.assertEquals(8 * a, FunctionUtils.multiply(c, id, id).value(new DerivativeStructure(1, 1, 0, a)).getPartialDerivative(1), EPS);

    UnivariateDifferentiableFunction inv = new Inverse();
    UnivariateDifferentiableFunction pow = new Power(2.5);
    UnivariateDifferentiableFunction cos = new Cos();
    Assert.assertEquals(1.5 * Math.sqrt(a) * Math.cos(a) - Math.pow(a, 1.5) * Math.sin(a),
                        FunctionUtils.multiply(inv, pow, cos).value(new DerivativeStructure(1, 1, 0, a)).getPartialDerivative(1), EPS);

    UnivariateDifferentiableFunction cosh = new Cosh();
    Assert.assertEquals(1.5 * Math.sqrt(a) * Math.cosh(a) + Math.pow(a, 1.5) * Math.sinh(a),
                        FunctionUtils.multiply(inv, pow, cosh).value(new DerivativeStructure(1, 1, 0, a)).getPartialDerivative(1), 8 * EPS);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:FunctionUtilsTest.java

示例6: inverse

import org.apache.commons.math3.analysis.function.Inverse; //导入依赖的package包/类
public Variable inverse(Transform transform, Variable numericVariable, Map<String, TransformOption> options) throws Exception {

        if (numericVariable.calculateUnivariateStats().get("min").get(0)[0] <= 0) {
            Transform scaleTransform = new Transform("scale", null, numericVariable, getStatLib());
            numericVariable = scaleTransform.transform();
            VariableDAO.getInstance().createVariableRow(numericVariable);
        }
        UnivariateDifferentiableFunction function = new Inverse();
        double[] origData = numericVariable.getData();
        double[] newData = new double[origData.length];
        for (int i = 0; i < origData.length; i++) {
            newData[i] = function.value(origData[i]);
        }

        Instances weka = new Util().createWekaData(newData, transform.toString());
        return new Variable(numericVariable, transform, transform.toString(), numericVariable.getLab(), newData, weka, numericVariable.getDateFormat(), VariableType.NUMERIC);
    }
 
开发者ID:williamClanton,项目名称:jbossBA,代码行数:18,代码来源:WekaApacheEngine.java

示例7: testInverse

import org.apache.commons.math3.analysis.function.Inverse; //导入依赖的package包/类
@Test
public void testInverse() {
    final UnivariateFunction inv = new Inverse();
    final UnivariateFunction log = new Log();

    final double lo = 12.34;
    final double hi = 456.78;

    final GaussIntegrator integrator = factory.legendre(60, lo, hi);
    final double s = integrator.integrate(inv);
    final double expected = log.value(hi) - log.value(lo);
    // System.out.println("s=" + s + " e=" + expected);
    Assert.assertEquals(expected, s, 1e-14);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:15,代码来源:LegendreTest.java

示例8: testInverse

import org.apache.commons.math3.analysis.function.Inverse; //导入依赖的package包/类
@Test
public void testInverse() {
    final UnivariateFunction inv = new Inverse();
    final UnivariateFunction log = new Log();

    final double lo = 12.34;
    final double hi = 456.78;

    final GaussIntegrator integrator = factory.legendreHighPrecision(60, lo, hi);
    final double s = integrator.integrate(inv);
    final double expected = log.value(hi) - log.value(lo);
    // System.out.println("s=" + s + " e=" + expected);
    Assert.assertEquals(expected, s, 1e-15);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:15,代码来源:LegendreHighPrecisionTest.java

示例9: testAdd

import org.apache.commons.math3.analysis.function.Inverse; //导入依赖的package包/类
@Test
public void testAdd() {
    UnivariateFunction id = new Identity();
    UnivariateFunction c = new Constant(4);
    UnivariateFunction m = new Minus();
    UnivariateFunction inv = new Inverse();

    Assert.assertEquals(4.5, FunctionUtils.add(inv, m, c, id).value(2), EPS);
    Assert.assertEquals(4 + 2, FunctionUtils.add(c, id).value(2), EPS);
    Assert.assertEquals(4 - 2, FunctionUtils.add(c, FunctionUtils.compose(m, id)).value(2), EPS);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:12,代码来源:FunctionUtilsTest.java

示例10: testAddDifferentiable

import org.apache.commons.math3.analysis.function.Inverse; //导入依赖的package包/类
@Test
public void testAddDifferentiable() {
    UnivariateDifferentiableFunction sin = new Sin();
    UnivariateDifferentiableFunction c = new Constant(4);
    UnivariateDifferentiableFunction m = new Minus();
    UnivariateDifferentiableFunction inv = new Inverse();

    final double a = 123.456;
    Assert.assertEquals(- 1 / (a * a) -1 + FastMath.cos(a),
                        FunctionUtils.add(inv, m, c, sin).value(new DerivativeStructure(1, 1, 0, a)).getPartialDerivative(1),
                        EPS);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:13,代码来源:FunctionUtilsTest.java

示例11: testMultiply

import org.apache.commons.math3.analysis.function.Inverse; //导入依赖的package包/类
@Test
public void testMultiply() {
    UnivariateFunction c = new Constant(4);
    Assert.assertEquals(16, FunctionUtils.multiply(c, c).value(12345), EPS);

    UnivariateFunction inv = new Inverse();
    UnivariateFunction pow = new Power(2);
    Assert.assertEquals(1, FunctionUtils.multiply(FunctionUtils.compose(inv, pow), pow).value(3.5), EPS);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:10,代码来源:FunctionUtilsTest.java

示例12: createFunctions

import org.apache.commons.math3.analysis.function.Inverse; //导入依赖的package包/类
protected UnivariateFunction[] createFunctions() {
    return new UnivariateFunction[] {
        new Power(2.0), new Exp(), new Expm1(), new Log(), new Log10(),
        new Log1p(), new Cosh(), new Sinh(), new Tanh(), new Cos(),
        new Sin(), new Tan(), new Acos(), new Asin(), new Atan(),
        new Inverse(), new Abs(), new Sqrt(), new Cbrt(), new Ceil(),
        new Floor(), new Rint(), new Signum(), new Ulp()
    };
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:10,代码来源:RealVectorAbstractTest.java


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