コード例 #1
0
 /**
  * A test of {@link FloatFFT_2D#realInverse(float[][], boolean)}, with the second parameter set to
  * <code>true</code>.
  */
 @Test
 public void testRealInverseScaled2dInput() {
   if (!ConcurrencyUtils.isPowerOf2(numRows)) {
     return;
   }
   if (!ConcurrencyUtils.isPowerOf2(numCols)) {
     return;
   }
   final float[][] actual = new float[numRows][numCols];
   final float[][] expected = new float[numRows][numCols];
   for (int r = 0; r < numRows; r++) {
     for (int c = 0; c < numCols; c++) {
       final float rnd = random.nextFloat();
       actual[r][c] = rnd;
       expected[r][c] = rnd;
     }
   }
   fft.realForward(actual);
   fft.realInverse(actual, true);
   double rmse = IOUtils.computeRMSE(actual, expected);
   Assert.assertEquals(
       String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse,
       0.0,
       rmse,
       EPS);
 }
コード例 #2
0
 /** A test of {@link FloatFFT_2D#realForwardFull(FloatLargeArray)}. */
 @Test
 public void testRealForwardFullLarge() {
   final FloatLargeArray actual = new FloatLargeArray(2 * numRows * numCols, false);
   final float[][] expected0 = new float[numRows][2 * numCols];
   final FloatLargeArray expected = new FloatLargeArray(numRows * 2 * numCols, false);
   for (int r = 0; r < numRows; r++) {
     for (int c = 0; c < numCols; c++) {
       final float rnd = random.nextFloat();
       actual.setDouble(r * numCols + c, rnd);
       expected0[r][2 * c] = rnd;
     }
   }
   fft.realForwardFull(actual);
   complexForward(expected0);
   for (int r = 0; r < numRows; r++) {
     for (int c = 0; c < 2 * numCols; c++) {
       expected.setDouble(2 * r * numCols + c, expected0[r][c]);
     }
   }
   double rmse = IOUtils.computeRMSE(actual, expected);
   Assert.assertEquals(
       String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse,
       0.0,
       rmse,
       EPS);
 }
コード例 #3
0
 /** A test of {@link FloatFFT_2D#realForward(FloatLargeArray)}. */
 @Test
 public void testRealForwardLarge() {
   if (!ConcurrencyUtils.isPowerOf2(numRows)) {
     return;
   }
   if (!ConcurrencyUtils.isPowerOf2(numCols)) {
     return;
   }
   final FloatLargeArray actual = new FloatLargeArray(2 * numRows * numCols, false);
   final FloatLargeArray expected = new FloatLargeArray(numRows * 2 * numCols, false);
   for (int r = 0; r < numRows; r++) {
     for (int c = 0; c < numCols; c++) {
       final float rnd = random.nextFloat();
       actual.setDouble(r * numCols + c, rnd);
       expected.setDouble(r * 2 * numCols + 2 * c, rnd);
     }
   }
   fft.realForward(actual);
   fft.complexForward(expected);
   fillSymmetric(actual, numRows, numCols);
   double rmse = IOUtils.computeRMSE(actual, expected);
   Assert.assertEquals(
       String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse,
       0.0,
       rmse,
       EPS);
 }
コード例 #4
0
 /**
  * A test of {@link FloatFFT_2D#complexInverse(float[][], boolean)}, with the second parameter set
  * to <code>false</code>.
  */
 @Test
 public void testComplexInverseUnScaled2dInput() {
   final float[][] expected = new float[numRows][2 * numCols];
   final float[][] actual = new float[numRows][2 * numCols];
   for (int r = 0; r < numRows; r++) {
     for (int c = 0; c < 2 * numCols; c++) {
       final float rnd = random.nextFloat();
       expected[r][c] = rnd;
       actual[r][c] = rnd;
     }
   }
   fft.complexForward(actual);
   fft.complexInverse(actual, false);
   final float s = numRows * numCols;
   for (int r = 0; r < numRows; r++) {
     for (int c = 0; c < 2 * numCols; c++) {
       actual[r][c] = actual[r][c] / s;
     }
   }
   double rmse = IOUtils.computeRMSE(actual, expected);
   Assert.assertEquals(
       String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse,
       0.0,
       rmse,
       EPS);
 }
コード例 #5
0
 /** A test of {@link FloatFFT_2D#complexForward(float[])}. */
 @Test
 public void testComplexForward1dInput() {
   final float[] actual = new float[2 * numRows * numCols];
   final float[][] expected0 = new float[numRows][2 * numCols];
   final float[] expected = new float[2 * numRows * numCols];
   for (int r = 0; r < numRows; r++) {
     for (int c = 0; c < 2 * numCols; c++) {
       final float rnd = random.nextFloat();
       actual[2 * r * numCols + c] = rnd;
       expected0[r][c] = rnd;
     }
   }
   fft.complexForward(actual);
   complexForward(expected0);
   for (int r = 0; r < numRows; r++) {
     for (int c = 0; c < 2 * numCols; c++) {
       expected[2 * r * numCols + c] = expected0[r][c];
     }
   }
   double rmse = IOUtils.computeRMSE(actual, expected);
   Assert.assertEquals(
       String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse,
       0.0,
       rmse,
       EPS);
 }
コード例 #6
0
 /**
  * A test of {@link FloatFFT_2D#complexInverse(FloatLargeArray, boolean)}, with the second
  * parameter set to <code>true</code>.
  */
 @Test
 public void testComplexInverseScaledLarge() {
   final FloatLargeArray expected = new FloatLargeArray(2 * numRows * numCols, false);
   final FloatLargeArray actual = new FloatLargeArray(2 * numRows * numCols, false);
   for (int i = 0; i < actual.length(); i++) {
     final float rnd = random.nextFloat();
     actual.setDouble(i, rnd);
     expected.setDouble(i, rnd);
   }
   fft.complexForward(actual);
   fft.complexInverse(actual, true);
   double rmse = IOUtils.computeRMSE(actual, expected);
   Assert.assertEquals(
       String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse,
       0.0,
       rmse,
       EPS);
 }
コード例 #7
0
 /**
  * A test of {@link FloatFFT_2D#complexInverse(float[], boolean)}, with the second parameter set
  * to <code>true</code>.
  */
 @Test
 public void testComplexInverseScaled1dInput() {
   final float[] expected = new float[2 * numRows * numCols];
   final float[] actual = new float[2 * numRows * numCols];
   for (int i = 0; i < actual.length; i++) {
     final float rnd = random.nextFloat();
     actual[i] = rnd;
     expected[i] = rnd;
   }
   fft.complexForward(actual);
   fft.complexInverse(actual, true);
   double rmse = IOUtils.computeRMSE(actual, expected);
   Assert.assertEquals(
       String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse,
       0.0,
       rmse,
       EPS);
 }
コード例 #8
0
 /**
  * A test of {@link FloatFFT_2D#realInverseFull(float[][], boolean)}, with the second parameter
  * set to <code>true</code>.
  */
 @Test
 public void testRealInverseFullScaled2dInput() {
   final float[][] actual = new float[numRows][2 * numCols];
   final float[][] expected = new float[numRows][2 * numCols];
   for (int r = 0; r < numRows; r++) {
     for (int c = 0; c < numCols; c++) {
       final float rnd = random.nextFloat();
       actual[r][c] = rnd;
       expected[r][2 * c] = rnd;
     }
   }
   fft.realInverseFull(actual, true);
   fft.complexInverse(expected, true);
   double rmse = IOUtils.computeRMSE(actual, expected);
   Assert.assertEquals(
       String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse,
       0.0,
       rmse,
       EPS);
 }
コード例 #9
0
 /**
  * A test of {@link FloatFFT_2D#realInverseFull(FloatLargeArray, boolean)}, with the second
  * parameter set to <code>false</code>.
  */
 @Test
 public void testRealInverseFullUnscaledLarge() {
   final FloatLargeArray actual = new FloatLargeArray(2 * numRows * numCols, false);
   final FloatLargeArray expected = new FloatLargeArray(2 * numRows * numCols, false);
   for (int r = 0; r < numRows; r++) {
     for (int c = 0; c < numCols; c++) {
       final float rnd = random.nextFloat();
       final int index = r * numCols + c;
       actual.set(index, rnd);
       expected.setDouble(2 * index, rnd);
     }
   }
   // TODO If the two following lines are permuted, this causes an array
   // index out of bounds exception.
   fft.complexInverse(expected, false);
   fft.realInverseFull(actual, false);
   double rmse = IOUtils.computeRMSE(actual, expected);
   Assert.assertEquals(
       String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse,
       0.0,
       rmse,
       EPS);
 }
コード例 #10
0
 /**
  * A test of {@link FloatFFT_2D#realInverseFull(float[], boolean)}, with the second parameter set
  * to <code>true</code>.
  */
 @Test
 public void testRealInverseFullScaled1dInput() {
   final float[] actual = new float[2 * numRows * numCols];
   final float[] expected = new float[2 * numRows * numCols];
   for (int r = 0; r < numRows; r++) {
     for (int c = 0; c < numCols; c++) {
       final float rnd = random.nextFloat();
       final int index = r * numCols + c;
       actual[index] = rnd;
       expected[2 * index] = rnd;
     }
   }
   // TODO If the two following lines are permuted, this causes an array
   // index out of bounds exception.
   fft.complexInverse(expected, true);
   fft.realInverseFull(actual, true);
   double rmse = IOUtils.computeRMSE(actual, expected);
   Assert.assertEquals(
       String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse,
       0.0,
       rmse,
       EPS);
 }