Example usage for org.apache.commons.math3.analysis MultivariateVectorFunction value

List of usage examples for org.apache.commons.math3.analysis MultivariateVectorFunction value

Introduction

In this page you can find the example usage for org.apache.commons.math3.analysis MultivariateVectorFunction value.

Prototype

double[] value(double[] point) throws IllegalArgumentException;

Source Link

Document

Compute the value for the function at the given point.

Usage

From source file:org.orekit.propagation.conversion.AbstractPropagatorConverter.java

/** Find the propagator that minimize the mean square error for a sample of {@link SpacecraftState states}.
 * @param initial initial estimation parameters (position, velocity, free parameters)
 * @return fitted parameters//from  www.java 2s. co m
 * @exception OrekitException if propagator cannot be adapted
 * @exception MaxCountExceededException if maximal number of iterations is exceeded
 */
private double[] fit(final double[] initial) throws OrekitException, MaxCountExceededException {

    final MultivariateVectorFunction f = getObjectiveFunction();
    final MultivariateMatrixFunction jac = getObjectiveFunctionJacobian();
    final MultivariateJacobianFunction fJac = new MultivariateJacobianFunction() {
        /** {@inheritDoc} */
        @Override
        public Pair<RealVector, RealMatrix> value(final RealVector point) {
            final double[] p = point.toArray();
            return new Pair<RealVector, RealMatrix>(MatrixUtils.createRealVector(f.value(p)),
                    MatrixUtils.createRealMatrix(jac.value(p)));
        }
    };
    final LeastSquaresProblem problem = new LeastSquaresBuilder().maxIterations(maxIterations)
            .maxEvaluations(Integer.MAX_VALUE).model(fJac).target(target).weight(new DiagonalMatrix(weight))
            .start(initial).checker(checker).build();
    optimum = optimizer.optimize(problem);
    return optimum.getPoint().toArray();
}