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

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


                        derivatives[i + 1] += gradient[j] * t[j].getPartialDerivative(orders);
                    }
                    orders[i] = 0;
                }

                return new DerivativeStructure(parameters, order, derivatives);

            }

        };
    }
View Full Code Here


                        final int n = x.length;

                        // delegate computation to underlying function
                        final DerivativeStructure[] dsX = new DerivativeStructure[n];
                        for (int i = 0; i < n; ++i) {
                            dsX[i] = new DerivativeStructure(n, 1, i, x[i]);
                        }
                        final DerivativeStructure[] y = f.value(dsX);

                        // extract Jacobian
                        final double[][] jacobian = new double[y.length][n];
View Full Code Here

                        for (int j = 0; j < n; ++j) {
                            derivatives[i + 1] += jacobian[k][j] * t[j].getPartialDerivative(orders);
                        }
                        orders[i] = 0;
                    }
                    merged[k] = new DerivativeStructure(parameters, order, derivatives);
                }

                return merged;

            }
View Full Code Here

        final double absoluteAccuracy = getAbsoluteAccuracy();

        double x0 = startValue;
        double x1;
        while (true) {
            final DerivativeStructure y0 = computeObjectiveValueAndDerivative(x0);
            x1 = x0 - (y0.getValue() / y0.getPartialDerivative(1));
            if (FastMath.abs(x1 - x0) <= absoluteAccuracy) {
                return x1;
            }

            x0 = x1;
View Full Code Here

        ++jacobianEvaluations;

        final DerivativeStructure[] dsPoint = new DerivativeStructure[params.length];
        final int nC = params.length;
        for (int i = 0; i < nC; ++i) {
            dsPoint[i] = new DerivativeStructure(nC, 1, i, params[i]);
        }
        final DerivativeStructure[] dsValue = jF.value(dsPoint);
        final int nR = getTarget().length;
        if (dsValue.length != nR) {
            throw new DimensionMismatchException(dsValue.length, nR);
View Full Code Here

            int i = 0;
            for (WeightedObservedPoint observed : observations) {

                // build the DerivativeStructure by adding first the value as a constant
                // and then adding derivatives
                DerivativeStructure vi = new DerivativeStructure(point.length, 1, f.value(observed.getX(), parameters));
                for (int k = 0; k < point.length; ++k) {
                    vi = vi.add(new DerivativeStructure(point.length, 1, k, 0.0));
                }

                values[i++] = vi;

            }
View Full Code Here

     * if the maximal number of evaluations is exceeded.
     */
    protected DerivativeStructure computeObjectiveValueAndDerivative(double point)
        throws TooManyEvaluationsException {
        incrementEvaluationCount();
        return function.value(new DerivativeStructure(1, 1, 0, point));
    }
View Full Code Here

    }

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

    }

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

      super(2, startParams, 0.0, buildArray(2, 1.0));
    }

    @Override
    public DerivativeStructure[] value(DerivativeStructure[] variables) {
        DerivativeStructure x1 = variables[0];
        DerivativeStructure x2 = variables[1];
        return new DerivativeStructure[] {
            x2.subtract(x1.multiply(x1)).multiply(10),
            x1.negate().add(1)
        };
    }
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.