/** Test of FloydRivestSelect method, of class FastSelection. */
  @Test
  public void FloydRivestSelect() {
    System.out.println("FloydRivestSelect");

    int iters = 100;
    Random r = new Random();

    for (int j = 1; j < iters; j++) {

      double[] A = VectorFunctions.randomGaussian(iters * 10);
      int L = 0;
      int R = A.length - 1;
      int K = r.nextInt(A.length);
      double result = FastSelection.FloydRivestSelect(L, R, K, A);
      // assertEquals(expResult, result);
      for (int i = 0; i < K; i++) {
        assertTrue(A[i] <= A[K]);
      }
      for (int i = K + 1; i < A.length; i++) {
        assertTrue(A[i] >= A[K]);
      }
    }

    for (int j = 1; j < iters; j++) {

      double[] A = VectorFunctions.randomGaussian(iters * 10);
      Double[] Ac = new Double[A.length];
      for (int i = 0; i < A.length; i++) Ac[i] = new Double(A[i]);

      int L = 0;
      int R = A.length - 1;
      int K = r.nextInt(A.length);
      FastSelection.FloydRivestSelect(L, R, K, Ac);
      // assertEquals(expResult, result);
      for (int i = 0; i < K; i++) {
        assertTrue(Ac[i].compareTo(Ac[K]) <= 0);
      }
      for (int i = K + 1; i < A.length; i++) {
        assertTrue(Ac[i].compareTo(Ac[K]) >= 0);
      }
    }
  }
  @Before
  public void setUp() {
    int length = 1500;

    double[] A = VectorFunctions.randomGaussian(length);
    Vector<Double> Ac = new Vector<Double>();
    for (int i = 0; i < A.length; i++) Ac.add(A[i]);

    Random r = new Random();
    k = r.nextInt(A.length);
    elem = (Double) instance.select(k, Ac);

    System.out.println("k = " + k + ", elem = " + elem);
  }
 /** Test of after method, of class FastSelection. */
 @Test
 public void after() {
   System.out.println("after");
   java.util.Iterator itr = instance.after().iterator();
   while (itr.hasNext()) assertTrue(elem.compareTo((Double) itr.next()) <= 0);
 }