CUFFT 兩次FFT輸入與輸出結果不一樣
以下是我的程式, 使用了兩次的FFT,
照理來說值應該是要一樣的,但是結果是無法對在一起
是怎麼回事呢
#include <stdio.h>
#include <stdlib.h>
#include <cuda_runtime.h>
#include <cutil.h>
#include <cufft.h>
#define H 2
#define W 2
#define T H*W
int main()
{
cufftComplex aaa[H][W]={{1, 2, 3, 4.5},{5, 6 ,7 ,8}};
cufftHandle plan;
cufftComplex *idata, *odata, *odata1;
cudaMalloc((void**)&odata1, sizeof(cufftComplex)*T);
cudaMalloc((void**)&odata, sizeof(cufftComplex)*T);
cudaMalloc((void**)&idata, sizeof(cufftComplex)*T);
cudaMemcpy(idata, aaa, sizeof(cufftComplex) * T,cudaMemcpyHostToDevice);
//image_buf_VS = input random 矩陣
cufftPlan2d(&plan, H, W, CUFFT_C2C);
cufftExecC2C(plan, idata, odata, CUFFT_FORWARD);
cufftPlan2d(&plan, H, W, CUFFT_C2C);
cufftExecC2C(plan, odata, odata, CUFFT_INVERSE);
cufftComplex host_odata[T];
cudaMemcpy(host_odata, odata, sizeof(cufftComplex)*T,
cudaMemcpyDeviceToHost); //host_odata, = output
cufftDestroy(plan);
cudaFree(idata);
cudaFree(odata);
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.122.192.147