001package com.nativelibs4java.opencl.util.fft;
002
003import com.nativelibs4java.opencl.*;
004import java.io.IOException;
005import java.nio.FloatBuffer;
006
007/**
008 * OpenCL Fast Fourier Transform for array sizes that are powers of two (simple precision floating point numbers)
009 */
010public class FloatFFTPow2 extends AbstractFFTPow2<Float, float[]> {
011
012    final FloatFFTProgram program;
013
014    public FloatFFTPow2(CLContext context) throws IOException {
015        super(context, Float.class);
016        this.program = new FloatFFTProgram(context);
017        program.getProgram().setFastRelaxedMath();
018    }
019    public FloatFFTPow2() throws IOException {
020        this(JavaCL.createBestContext());
021    }
022
023    protected CLEvent cooleyTukeyFFTTwiddleFactors(CLQueue queue, int N, CLBuffer<Float> buf, CLEvent... evts) throws CLException {
024        return program.cooleyTukeyFFTTwiddleFactors(queue, N, buf, new int[] { N / 2 }, null, evts);
025    }
026    protected CLEvent cooleyTukeyFFTCopy(CLQueue queue, CLBuffer<Float> inBuf, CLBuffer<Float> outBuf, int length, CLBuffer<Integer> offsetsBuf, boolean inverse, CLEvent... evts) throws CLException {
027        return program.cooleyTukeyFFTCopy(queue, inBuf, outBuf, length, offsetsBuf, inverse ? 1.0f / length : 1, new int[] { length }, null, evts);
028    }
029    protected CLEvent cooleyTukeyFFT(CLQueue queue, CLBuffer<Float> Y, int N, CLBuffer<Float> twiddleFactors, int inverse, int[] dims, CLEvent... evts) throws CLException {
030        return program.cooleyTukeyFFT(queue, Y, N, twiddleFactors, inverse, dims, null, evts);
031    }
032 }
033