commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/MultivariateOptimizer.java [265:292]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        /* package-private */ UnivariatePointValuePair search(final double[] startPoint,
                                                              final double[] direction) {
            final int n = startPoint.length;
            final MultivariateFunction func = mainOptimizer.getObjectiveFunction();
            final UnivariateFunction f = new UnivariateFunction() {
                    /** {@inheritDoc} */
                    @Override
                    public double value(double alpha) {
                        final double[] x = new double[n];
                        for (int i = 0; i < n; i++) {
                            x[i] = startPoint[i] + alpha * direction[i];
                        }
                        return func.value(x);
                    }
                };

            final GoalType goal = mainOptimizer.getGoalType();
            bracket.search(f, goal, 0, initialBracketingRange);
            // Passing "MAX_VALUE" as a dummy value because it is the enclosing
            // class that counts the number of evaluations (and will eventually
            // generate the exception).
            return lineOptimizer.optimize(new MaxEval(Integer.MAX_VALUE),
                                          new UnivariateObjectiveFunction(f),
                                          goal,
                                          new SearchInterval(bracket.getLo(),
                                                             bracket.getHi(),
                                                             bracket.getMid()));
        }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/LineSearch.java [117:144]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public UnivariatePointValuePair search(final double[] startPoint,
                                           final double[] direction) {
        final int n = startPoint.length;
        final MultivariateFunction func = mainOptimizer.getObjectiveFunction();
        final UnivariateFunction f = new UnivariateFunction() {
            /** {@inheritDoc} */
            @Override
            public double value(double alpha) {
                final double[] x = new double[n];
                for (int i = 0; i < n; i++) {
                    x[i] = startPoint[i] + alpha * direction[i];
                }
                return func.value(x);
            }
        };

        final GoalType goal = mainOptimizer.getGoalType();
        bracket.search(f, goal, 0, initialBracketingRange);
        // Passing "MAX_VALUE" as a dummy value because it is the enclosing
        // class that counts the number of evaluations (and will eventually
        // generate the exception).
        return lineOptimizer.optimize(new MaxEval(Integer.MAX_VALUE),
                                      new UnivariateObjectiveFunction(f),
                                      goal,
                                      new SearchInterval(bracket.getLo(),
                                                         bracket.getHi(),
                                                         bracket.getMid()));
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



