Class MedianOf3PivotingStrategy

java.lang.Object
org.apache.commons.math3.util.MedianOf3PivotingStrategy
All Implemented Interfaces:
Serializable, PivotingStrategyInterface

public class MedianOf3PivotingStrategy extends Object implements PivotingStrategyInterface, Serializable
Classic median of 3 strategy given begin and end indices.
Since:
3.4
See Also:
  • Constructor Details

    • MedianOf3PivotingStrategy

      public MedianOf3PivotingStrategy()
  • Method Details

    • pivotIndex

      public int pivotIndex(double[] work, int begin, int end) throws MathIllegalArgumentException
      Find pivot index of the array so that partition and Kth element selection can be made This in specific makes use of median of 3 pivoting.
      Specified by:
      pivotIndex in interface PivotingStrategyInterface
      Parameters:
      work - data array
      begin - index of the first element of the slice
      end - index after the last element of the slice
      Returns:
      The index corresponding to a pivot chosen between the first, middle and the last indices of the array slice
      Throws:
      MathIllegalArgumentException - when indices exceeds range