資源簡介
java實現(xiàn)FFT算法,關(guān)于快速傅里葉變換(FFT)和傅里葉變換的理論知識這里我就不提了,本文主要講解FFT實現(xiàn):
之前想找一個FFT代碼,在網(wǎng)上找了很多都是有問題的,下面我完善了一個供大家學(xué)習(xí)交流;

代碼片段和文件信息
import?java.util.objects;
public?class?Complex?{
?private?final?double?re;???//?the?real?part
????private?final?double?im;???//?the?imaginary?part
????//?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“;
????}
????//?return?abs/modulus/magnitude
????public?double?abs()?{
????????return?Math.hypot(re?im);
????}
????//?return?angle/phase/argument?normalized?to?be?between?-pi?and?pi
????public?double?phase()?{
????????return?Math.atan2(im?re);
????}
????//?return?a?new?Complex?object?whose?value?is?(this?+?b)
????public?Complex?plus(Complex?b)?{
????????Complex?a?=?this;?????????????//?invoking?object
????????double?real?=?a.re?+?b.re;
????????double?imag?=?a.im?+?b.im;
????????return?new?Complex(real?imag);
????}
????//?return?a?new?Complex?object?whose?value?is?(this?-?b)
????public?Complex?minus(Complex?b)?{
????????Complex?a?=?this;
????????double?real?=?a.re?-?b.re;
????????double?imag?=?a.im?-?b.im;
????????return?new?Complex(real?imag);
????}
????//?return?a?new?Complex?object?whose?value?is?(this?*?b)
????public?Complex?times(Complex?b)?{
????????Complex?a?=?this;
????????double?real?=?a.re?*?b.re?-?a.im?*?b.im;
????????double?imag?=?a.re?*?b.im?+?a.im?*?b.re;
????????return?new?Complex(real?imag);
????}
????//?return?a?new?object?whose?value?is?(this?*?alpha)
????public?Complex?scale(double?alpha)?{
????????return?new?Complex(alpha?*?re?alpha?*?im);
????}
????//?return?a?new?Complex?object?whose?value?is?the?conjugate?of?this
????public?Complex?conjugate()?{
????????return?new?Complex(re?-im);
????}
????//?return?a?new?Complex?object?whose?value?is?the?reciprocal?of?this
????public?Complex?reciprocal()?{
????????double?scale?=?re*re?+?im*im;
????????return?new?Complex(re?/?scale?-im?/?scale);
????}
????//?return?the?real?or?imaginary?part
????public?double?re()?{?return?re;?}
????public?double?im()?{?return?im;?}
????//?return?a?/?b
????public?Complex?divides(Complex?b)?{
????????Complex?a?=?this;
????????return?a.times(b.reciprocal());
????}
????//?return?a?new?Complex?object?whose?value?is?the?complex?exponential?of?this
????public?Complex?exp()?{
????????return?new?Complex(Math.exp(re)?*?Math.cos(im)?Math.exp(re)?*?Math.sin(im));
????}
????//?return?a?new?Complex?object?whose?value?is?the?complex?sine?of?this
????public?Complex?sin()?{
????????return?new?Complex(Math.sin(re)?*?Math.cosh(im)?Math.cos(re)?*?Math.sinh(im));
????}
????//?return?a?new?Complex?object?whose?value?is?the?complex?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-12-14?15:17??Test\
?????文件?????????377??2019-01-02?17:39??Test\.classpath
?????文件?????????380??2018-12-14?15:17??Test\.project
?????目錄???????????0??2018-12-14?15:17??Test\.settings\
?????文件?????????598??2018-12-14?15:17??Test\.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2019-01-03?17:24??Test\bin\
?????文件????????4456??2019-01-03?17:24??Test\bin\Complex.class
?????文件????????3114??2019-01-03?17:24??Test\bin\FFT.class
?????目錄???????????0??2019-01-02?17:39??Test\src\
?????文件????????4920??2019-01-02?17:31??Test\src\Complex.java
?????文件????????6807??2019-01-02?18:50??Test\src\FFT.java
- 上一篇:利用Java程序把多張圖片合成一張圖片
- 下一篇:java與藍(lán)牙通信
評論
共有 條評論