Package org.apache.commons.math3.util
Class RandomPivotingStrategy
- java.lang.Object
-
- org.apache.commons.math3.util.RandomPivotingStrategy
-
- All Implemented Interfaces:
java.io.Serializable,PivotingStrategyInterface
public class RandomPivotingStrategy extends java.lang.Object implements PivotingStrategyInterface, java.io.Serializable
A strategy of selecting random index between begin and end indices.- Since:
- 3.4
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private RandomGeneratorrandomRandom generator to use for selecting pivot.private static longserialVersionUIDSerializable UID.
-
Constructor Summary
Constructors Constructor Description RandomPivotingStrategy(RandomGenerator random)Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intpivotIndex(double[] work, int begin, int end)Find pivot index of the array so that partition and Kth element selection can be made
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Serializable UID.- See Also:
- Constant Field Values
-
random
private final RandomGenerator random
Random generator to use for selecting pivot.
-
-
Constructor Detail
-
RandomPivotingStrategy
public RandomPivotingStrategy(RandomGenerator random)
Simple constructor.- Parameters:
random- random generator to use for selecting pivot
-
-
Method Detail
-
pivotIndex
public int pivotIndex(double[] work, int begin, int end) throws MathIllegalArgumentExceptionFind pivot index of the array so that partition and Kth element selection can be made A uniform random pivot selection between begin and end indices- Specified by:
pivotIndexin interfacePivotingStrategyInterface- Parameters:
work- data arraybegin- index of the first element of the sliceend- index after the last element of the slice- Returns:
- The index corresponding to a random uniformly selected value between first and the last indices of the array slice
- Throws:
MathIllegalArgumentException- when indices exceeds range
-
-