I’ve been testing cufft on an example given at:
which models the sinusoid x(n)=cos(wnT)
For N=64 data points then there should be 2 peaks in the magnitude spectrum, each at magnitude on a linear scale, located at normalized frequencies f=0.25 and f=0.75. Spectral peak amplitudes of 32=(1/2)64 should be observed, which occur at bin numbers k=(0.25/f)N=16 and k=(0.75/f)N=48. The spectrum should be exactly zero at the other bin numbers. Computed the signal voltage in dB using: 20.0*log10(cuCabsf(value)/32.0) with an approx error of -130dB.
Below is a function that returns the above sinusoid sample for a specified N:
FloatComplexVector TestSamples::generate1DComplexSinusoidSignal(int numberPoints)
float PI = 3.141592654f;
float T = 1.0f;
float fs = 1.0f; // frequency fs/4
float wx = 2.0f * PI * (fs/4.0f);
float tol = 1e-06f;
// fill vector
for (int n=0; n<numberPoints; n++)
cuFloatComplex c = make_cuFloatComplex(rvalue,0.0f);
FloatComplexVector is simply a wrapper around float* to facilitate get() and set() accessors.
Below is pasted o/p for N=64 upto 1,024. The only non-zero values within a tolerance of 1e-03 for N=64 are as discussed above.
The problem is for increasing N, noting that how the accuracy drifts off such that by N=1,024 a large number of non-peak values are outside the tolerance 1e-03.
If I increase N, to say 2^10 (1million points) then the accuracy has got so bad that the fft is meaningless.
Has anyone seen this kind of drift before?
N = 64
index of non-zero value (32.000000,0.000046) is: 16
index of non-zero value (32.000000,-0.000046) is: 48
N = 128
index of non-zero value (64.000000,0.000157) is: 32
index of non-zero value (64.000000,-0.000157) is: 96
N = 256
index of non-zero value (128.000000,0.000694) is: 64
index of non-zero value (128.000000,-0.000694) is: 192
N = 512
index of non-zero value (256.000000,0.002843) is: 128
index of non-zero value (256.000000,-0.002843) is: 384
N = 1024
index of non-zero value (-0.000237,-0.000993) is: 107
index of non-zero value (0.001308,0.000073) is: 108
index of non-zero value (512.000000,0.011255) is: 256