Package org.apache.commons.math3.analysis.differentiation

Examples of org.apache.commons.math3.analysis.differentiation.DerivativeStructure


                new PolynomialFunctionNewtonForm(new double[] { 0, 1, 3, 1 },
                                                 new double[] { 0, 1, 2 });

        double eps = 2.0e-14;
        for (double t = 0.0; t < 10.0; t += 0.1) {
            DerivativeStructure x = new DerivativeStructure(1, 4, 0, t);
            DerivativeStructure y = p.value(x);
            Assert.assertEquals(t * t * t,   y.getValue(),              eps * t * t * t);
            Assert.assertEquals(3.0 * t * t, y.getPartialDerivative(1), eps * 3.0 * t * t);
            Assert.assertEquals(6.0 * t,     y.getPartialDerivative(2), eps * 6.0 * t);
            Assert.assertEquals(6.0,         y.getPartialDerivative(3), eps * 6.0);
            Assert.assertEquals(0.0,         y.getPartialDerivative(4), eps);
        }

    }
View Full Code Here


                                        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();
View Full Code Here

        public double getMax() {
            return max;
        }

        public double value(final double x) {
            return value(new DerivativeStructure(0, 0, x)).getValue();
        }
View Full Code Here

            }

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

        };
View Full Code Here

        return w;
    }

    public double[] value(double[] params) {
        final Model line = new Model(new DerivativeStructure(0, 0, params[0]),
                                     new DerivativeStructure(0, 0, params[1]));

        final double[] model = new double[points.size()];
        for (int i = 0; i < points.size(); i++) {
            final double[] p = points.get(i);
            model[i] = line.value(p[0]);
View Full Code Here

    public DerivativeStructure[] value(DerivativeStructure[] params) {
        final Model line = new Model(params[0], params[1]);

        final DerivativeStructure[] model = new DerivativeStructure[points.size()];
        for (int i = 0; i < points.size(); i++) {
            final DerivativeStructure p0 = params[0].getField().getZero().add(points.get(i)[0]);
            model[i] = line.value(p0);
        }

        return model;
    }
View Full Code Here

        this.problem = new MultivariateDifferentiableVectorFunction() {

            public double[] value(final double[] a) {
                DerivativeStructure[] dsA = new DerivativeStructure[a.length];
                for (int i = 0; i < a.length; ++i) {
                    dsA[i] = new DerivativeStructure(a.length, 0, a[i]);
                }
                final int n = getNumObservations();
                final double[] yhat = new double[n];
                for (int i = 0; i < n; i++) {
                    yhat[i] = getModelValue(getX(i), dsA).getValue();
View Full Code Here

      }

      public double[] value(double[] variables) {
          DerivativeStructure[] dsV = new DerivativeStructure[variables.length];
          for (int i = 0; i < variables.length; ++i) {
              dsV[i] = new DerivativeStructure(0, 0, variables[i]);
          }
          DerivativeStructure[] dsY = value(dsV);
          double[] y = new double[dsY.length];
          for (int i = 0; i < dsY.length; ++i) {
              y[i] = dsY[i].getValue();
View Full Code Here

            buildArray(n, -1.0));
    }

    @Override
    public DerivativeStructure[] value(DerivativeStructure[] variables) {
      DerivativeStructure sum = variables[0].getField().getZero();
      for (int i = 0; i < n; ++i) {
        sum = sum.add(variables[i]);
      }
      DerivativeStructure t  = sum.multiply(2.0 / m).add(1);
      DerivativeStructure[] f = new DerivativeStructure[m];
      for (int i = 0; i < n; ++i) {
        f[i] = variables[i].subtract(t);
      }
      Arrays.fill(f, n, m, t.negate());
      return f;
    }
View Full Code Here

                for (int j = 0; j < factors.getColumnDimension(); ++j) {
                    y[i] = y[i].add(variables[j].multiply(factors.getEntry(i, j)));
                }
            }

            DerivativeStructure sum = variables[0].getField().getZero();
            for (int i = 0; i < y.length; ++i) {
                DerivativeStructure ri = y[i].subtract(target[i]);
                sum = sum.add(ri.multiply(ri));
            }
            return sum;
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.math3.analysis.differentiation.DerivativeStructure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.