如何使用 CUFFT 进行反向 fft 对称
How to do inverse fft symmetric with CUFFT
我需要将这一行 (MATLAB) 转换为 CUDA:
picTimeFiltered = ifft((picFFT_filt), size(I,3), 3 ,'symmetric');
我当前的实现是针对这一行(没有 '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 对称?
使用 cufftExecC2R() 或 cufftExecZ2D() 计算 single/double 精度的逆对称 fft。
我需要将这一行 (MATLAB) 转换为 CUDA:
picTimeFiltered = ifft((picFFT_filt), size(I,3), 3 ,'symmetric');
我当前的实现是针对这一行(没有 '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 对称?
使用 cufftExecC2R() 或 cufftExecZ2D() 计算 single/double 精度的逆对称 fft。