![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Application example of FftReal class. FftReal クラスの使用例.
Dependencies: Array_Matrix mbed UIT_FFT_Real
Diff: dftReal.hpp
- Revision:
- 4:8248d5b5cdc9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dftReal.hpp Sat Dec 12 03:21:58 2020 +0000 @@ -0,0 +1,29 @@ +//-------------------------------------------------------------- +// 離散的フーリエ変換 (DFT) +// +// 2020/12/12, Copyright (c) 2020 MIKAMI, Naoki +//-------------------------------------------------------------- + +#include "mbed.h" +#include <complex> // complex で使用 + +#ifndef DFT_REAL_HPP +#define DFT_REAL_HPP + +typedef complex<float> Complex; // "Complex" の定義 + +void DftReal(const float x[], Complex y[], int nFft); + +// DFT の計算 +void DftReal(const float x[], Complex y[], int nFft) +{ + Complex j2PiN = Complex(0, -6.28318531f/nFft); + + for (int k=0; k<nFft; k++) + { + y[k] = 0.0; + for (int n=0; n<nFft; n++) + y[k] = y[k] + x[n]*exp(j2PiN*(float)(n*k)); + } +} +#endif // DFT_REAL_HPP \ No newline at end of file