Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-218

UnivariateRealSolver: Allow function to be passed as argument to the "solve" method

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • 2.0
    • None
    • None

    Description

      Hello.

      I was wondering why all the root finders (e.g. NewtonSolver, BrentSolver, etc.) require the function to be passed as an argument to the contructor.
      It should be possible to pass it when calling the method "solve" i.e.
      double solve(UnivariateRealFunction f, double min, double max)
      This would be much more flexible, e.g. allowing one to use the same solver instance for several functions.

      For example, my need would be something like the following (currently impossible) code:

      public class Zero implements UnivariateRealFunction {
      public value(double x) throws FunctionEvaluationException

      { return ...; }

      public double get(UnivariateRealSolver s, double min, double max)

      { return s.solve(this, min, max); }

      }

      Best regards,
      Gilles

      Attachments

        Activity

          People

            Unassigned Unassigned
            erans Gilles Sadowski
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: