/** 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);
      }
    }
  }