对于这个问题,我使用的是Apache的数学库
我的目标是在对输入值的前向傅里叶变换的绝对值结果执行傅里叶逆变换后,取回我的输入。
当我对输入的前向傅里叶变换的复数值结果执行傅里叶逆变换时,我得到了正确的输出。
我可能做错了什么?
public void fourierTestTemp(){
double[] input = new double[]{1,0,0,0,0,0,0,66,888,0,0,0,0,0,0,0};//Length = 16
double[] result = new double[input.length];//This double array will hold the results of the fourier transform
FastFourierTransformer transformer = new FastFourierTransformer(DftNormalization.UNITARY);//The FastFourierTransformer class by Apache
Complex[] complx = transformer.transform(result, TransformType.FORWARD);//Apply fourier transform to double[]
//Go through Complex value results and obtain absolute value
for (int i = 0; i < complx.length; i++) {
result[i] = complx[i].abs();
}
//Perform inverse transform on the obtained absolute values from the forward transform.
complx = transformer.transform(result, TransformType.INVERSE);
//Go through Complex value results and obtain absolute value
for (int i = 0; i < complx.length; i++) {
result[i] = complx[i].abs();
}
//Print results
for (int i = 0; i < result.length; i++) {
System.out.print(result[i]+",");
}
}
ifft(abs(fft(x))) 只是当 x 是严格对称的恒等式(只能由 DFT 的余弦基向量构造)时。 您的测试向量不是。
余弦是对称函数。 正弦是反对称的。
如果 x 不对称,fft(x) 将不是实数,因此 abs() 函数将旋转一些相位结果,从而扭曲 ifft 输出波形。