前言:
FFT 相关知识,强烈推荐看这篇博文:深入浅出的讲解傅里叶变换(真正的通俗易懂)
程序参考文章:
话不多说,直接上代码,😎😎😎。
代码:
class Complex {
private double re = 0; // the real part
private double im = 0; // the imaginary part
private int index = 0; // the index ! to find 5 max
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public double getRe() {
return re;
}
public void setRe(double re) {
this.re = re;
}
public double getIm() {
return im;
}
public void setIm(double im) {
this.im = im;
}
// create a new object with the given real and imaginary parts 构造函数。
public Complex(double real, double imag) {
re = real;
im = imag;
}
// return a string representation of the invoking Complex object
public String toString() {
if (im == 0)
return re + "";
if (re == 0)
return im + "i";
if (im < 0)
return re + " - " + (-im) + "i";
return re + " + " + im + "i"