public void testFloatValues(String title, Transformer<Float, float[]> tr) { FastFourierTransformer apache = new FastFourierTransformer(); CLQueue queue = tr.getContext() == null ? null : tr.getContext().createDefaultOutOfOrderQueueIfPossible(); for (double[] data : createTestDoubleInputs()) { float[] dataf = toFloat(data); double[] expected = complexToInterleavedDoubles(apache.transform(interleavedDoublesToComplex(data))); assertArrayEquals(title + " (n = " + (data.length / 2) + ")", toFloat(expected), tr.transform(queue, dataf, false), precisionFloat); } }
@Test public void testFloatDFTInverse() throws IOException, CLException { testFloatTransformer("Float DFT Inverse", new FloatDFT()); } @Ignore
@Test public void testFloatFFTValues() throws IOException { testFloatValues("Float FFT", new FloatFFTPow2()); } @Test
static Collection<float[]> createTestFloatInputs() { Collection<float[]> ret = new ArrayList<float[]>(); for (double[] in : createTestDoubleInputs()) ret.add(toFloat(in)); return ret; }
public void testDoubleValues(String title, Transformer<Double, double[]> tr) { FastFourierTransformer apache = new FastFourierTransformer(); CLQueue queue = tr.getContext() == null ? null : tr.getContext().createDefaultOutOfOrderQueueIfPossible(); for (double[] data : createTestDoubleInputs()) { double[] expected = complexToInterleavedDoubles(apache.transform(interleavedDoublesToComplex(data))); assertArrayEquals(title + " (n = " + (data.length / 2) + ")", expected, tr.transform(queue, data, false), precisionDouble); } } public void testFloatValues(String title, Transformer<Float, float[]> tr) {
@Test public void testDoubleDFTValues() throws IOException { testDoubleValues("Double DFT", new DoubleDFT()); } @Test
@Test public void testDoubleDFTInverse() throws IOException, CLException { testDoubleTransformer("Double FFT Inverse", new DoubleDFT()); } @Test
void testFloatTransformer(String title, Transformer<Float, float[]> t) throws IOException, CLException { CLQueue queue = t.getContext().createDefaultOutOfOrderQueueIfPossible(); //System.out.println("Context: " + t.getContext()); for (float[] in : createTestFloatInputs()) { float[] out = t.transform(queue, in, false); float[] back = t.transform(queue, out, true); assertArrayEquals(title + " (n = " + (in.length / 2) + ")", in, back, precisionInverseFloat); } } }
void testDoubleTransformer(String title, Transformer<Double, double[]> t) throws IOException, CLException { CLQueue queue = t.getContext().createDefaultOutOfOrderQueueIfPossible(); //System.out.println("Context: " + t.getContext()); for (double[] in : createTestDoubleInputs()) { double[] out = t.transform(queue, in, false); double[] back = t.transform(queue, out, true); assertArrayEquals(title + " (n = " + (in.length / 2) + ")", in, back, precisionInverseDouble); } } void testFloatTransformer(String title, Transformer<Float, float[]> t) throws IOException, CLException {
@Ignore @Test public void testDoubleFFTValues() throws IOException { testDoubleValues("Double FFT", new DoubleFFTPow2()); } @Test
@Ignore @Test public void testDoubleFFTInverse() throws IOException, CLException { testDoubleTransformer("Double FFT Inverse", new DoubleFFTPow2()); } @Test
@Test public void testFloatFFTInverse() throws IOException, CLException { testFloatTransformer("Float FFT Inverse", new FloatFFTPow2()); } void testDoubleTransformer(String title, Transformer<Double, double[]> t) throws IOException, CLException {
@Test public void testFloatDFTValues() throws IOException { testFloatValues("Float DFT", new FloatDFT()); } @Test