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

Add a method in Interval that verifies if a double is inside the Interval

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0
    • Fix Version/s: 3.1
    • Labels:
      None

      Description

      It would be convenient if class org.apache.commons.math3.geometry.euclidean.oned.Interval had a method such as the one below.

      Here is the method code that may be added to the class.
          /** Verifies if x is inside this Interval.
           * @return true if x is a value between this Interval lower and upper
           * bounds, false otherwise
           */
          public boolean contains(double x) {
              return upper >= x && lower <= x;
          }
      

      Notice that I'm assuming that an Interval includes its endpoints which may not be true in certain applications. This may imply the need to improve the Interval class (by adding methods or internal state) that describe the inclusion or exclusion of endpoints.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ramiromagalhaes Ramiro Pereira de Magalhães
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: