如何用CUFFT进行逆fft对称

时间:2017-06-25 08:54:06

标签: cuda fft ifft cufft

我需要将此行(MATLAB)转换为CUDA:

picTimeFiltered = ifft((picFFT_filt), size(I,3), 3 ,'symmetric');

我目前的实现是针对此行(没有'对称'标志):

picTimeFiltered = ifft((picFFT_filt), size(I,3), 3);

这是我的CUDA实施:

void ifftDouble_many(cuDoubleComplex*& input, cuDoubleComplex*& outputMatrixAfterIFFT, const int width, const int height, const int depth)
{
    const int NX = depth;
    const int NY = width * height;

    // Allocate and set the CUDA Input 
    cuDoubleComplex *d_input;
    cudaMalloc(&d_input, NX*NY * sizeof(cuDoubleComplex));
    cudaMemcpy(d_input, input, NX * NY * sizeof(cuDoubleComplex), cudaMemcpyHostToDevice);

    // Allocate the CUDA output
    cufftDoubleComplex* d_output = nullptr;
    cudaMalloc((void**)&d_output, sizeof(cuDoubleComplex)*NX*NY);

    // CUDA FFT
    cufftHandle plan;
    int n[1] = { NX };
    int inembed[] = { NY, NX };
    int onembed[] = { NY, NX };
    cufftPlanMany(&plan, 1, n, inembed, 1, NX, onembed, 1, NX, CUFFT_Z2Z, NY);
    cufftExecZ2Z(plan, d_input, d_output, CUFFT_INVERSE);

    // Devide the results by depth
    devideCufftDoubleComplexArrayByScalar_CUDA(d_output, NX * NY, depth);

    cudaMemcpy(outputMatrixAfterIFFT, d_output, NY*NX * sizeof(cuDoubleComplex), cudaMemcpyDeviceToHost);

    /* Destroy the CUFFT plan. */
    cufftDestroy(plan);
    cudaFree(d_input);
    cudaFree(d_output);
}

请指教 - 如何通过CUDA进行逆fft对称?

1 个答案:

答案 0 :(得分:1)

使用cufftExecC2R()或cufftExecZ2D()计算单次/双精度的反对称fft。

http://docs.nvidia.com/cuda/cufft/index.html#axzz4l0egR62U