你们可以这样想: 指针绕着纵坐标旋转,所以在样本 k 上,指针指向 k.theta 方向,长度是信号[ k ]。如果信号的频率与坐标系的频率完全匹配,那么就会在某个方向上形成凸起的形状。所以如果你把所有的贡献加起来,你会得到一个强合成矢量。
如果频率几乎匹配,则凸起将更小,并且在圆周上缓慢移动。
对于一个与频率不匹配的信号,贡献会相互抵消
// let's say log2n = 8, so n=2^8=256 samples, or 'harmonics' or 'terms'
// if we pre-calculate the 256th roots of unity (of which there are 256)
// that will save us time later.
//
// Note that this call creates an array which will need to be released
// later to avoid leaking
setupReal = vDSP_create_fftsetup(log2n, FFT_RADIX2);
然后再回来... 我们仍然需要从 A 中解压缩原始数组,然后进行比较,以检查我们是否得到了开始时的确切结果,释放预先计算好的线轴并完成!
但是等等! 在你打开行李之前,还有最后一件事需要做:
// Need to see the documentation for this one...
// in order to optimise, different routines return values
// that need to be scaled by different amounts in order to
// be correct as per the math
// In this case...
scale = (float) 1.0 / (2 * n);
vDSP_vsmul(A.realp, 1, &scale, A.realp, 1, nOver2);
vDSP_vsmul(A.imagp, 1, &scale, A.imagp, 1, nOver2);