cuFFT scaling forward FFT

Hello all,

I am aware that cuFFT doesn’t scale output for inverse/backward FFT. Does one need to scale the forward FFT in cuFFT? I am doing complex-to-complex transforms using cuComplex datatype for single precision.

I would like my cuFFT FFT calls to match what is defined by Python if possible.

Thank you.

no scaling on the forward FFT should be necessary:

$ cat t1614.cu
#include <cufft.h>
#include <iostream>

int main(){

  cufftComplex data[] = {{1.0f, 0}, {2.0f, 0}, {3.0f, 0}, {4.0f, 0}};
  cufftComplex *d_data;
  int ds = sizeof(data)/sizeof(data[0]);
  cudaMalloc(&d_data, ds*sizeof(data[0]));
  cudaMemcpy(d_data, data, ds*sizeof(data[0]), cudaMemcpyHostToDevice);
  cufftHandle plan;
  cufftPlan1d(&plan, ds, CUFFT_C2C, 1);
  cufftExecC2C(plan, d_data, d_data, CUFFT_FORWARD);
  cudaMemcpy(data, d_data, ds*sizeof(data[0]), cudaMemcpyDeviceToHost);
  for (int i = 0; i < ds; i++) std::cout << data[i].x << "," << data[i].y << std::endl;
  return 0;
}
$ nvcc -o t1614 t1614.cu -lcufft
$ ./t1614
10,0
-2,2
-2,0
-2,-2
$ cat t1.py
import numpy as np
from numpy import fft

d = np.asarray([1.0+0j, 2.0+0j, 3.0+0j, 4.0+0j], dtype = np.complex64)
dfft = np.fft.fft(d)
print(dfft)
$ python t1.py
[ 10.+0.j  -2.+2.j  -2.+0.j  -2.-2.j]
$