Application example of FftReal class. FftReal クラスの使用例.

Dependencies:   Array_Matrix mbed UIT_FFT_Real

Revision:
4:8248d5b5cdc9
Parent:
3:4ef52c7f5281
--- a/main.cpp	Mon Jan 13 08:57:54 2020 +0000
+++ b/main.cpp	Sat Dec 12 03:21:58 2020 +0000
@@ -1,42 +1,38 @@
 //--------------------------------------------------------------
-// Demo program of FftReal class
+//  FftReal クラスのデモ用プログラム
 //
-// Copyright (c) 2020 MIKAMI, Naoki,  2020/01/13
+//  2020/12/12, Copyright (c) 2020 MIKAMI, Naoki
 //--------------------------------------------------------------
 
-#include "dftComplex.hpp"
+#include "dftReal.hpp"
 #include "fftReal.hpp"
-
 using namespace Mikami;
+#pragma diag_suppress 870   // マルチバイト文字使用の警告抑制のため
 
 int main()
 {
-//    const int N = 16;       // number of date for FFT
-    const int N = 256;       // number of date for FFT
+    const int N = 16;       // FFT のデータ数
+//    const int N = 256;       // FFT のデータ数
 
     float x1[N], x2[N];
     Complex y1[N], y2[N/2+1];
 
-    // Generate random data
+    // 乱数生成
     srand(1234);
     for (int n=0; n<N; n++)
         x1[n] = 2.0f*rand()/(float)RAND_MAX - 1.0f;
-    printf("\r\n#### Original data for DFT ####\r\n");
+    printf("\r\n#### 元のデータ ####\r\n");
     for (int n=0; n<N; n++)
         printf("f[%2d]: %8.4f\r\n", n, x1[n]);
 
-    Timer tm;   // for measurement of execution time
+    Timer tm;   // 実行時間測定のため
 
-    // DFT, for comarison
+    // DFT, 比較のため
     tm.reset();
     tm.start();
-    DftComplex(x1, y1, N);
+    DftReal(x1, y1, N);
     tm.stop();
-    printf("\r\nExecution time (DFT): %d [us]\r\n", tm.read_us());
-    printf("\r\n#### Result of direct DFT ####\r\n");
-    printf("          real    imaginary\r\n");
-    for (int n=0; n<N; n++)
-        printf("F[%2d]: %8.4f, %8.4f\r\n", n, y1[n].real(), y1[n].imag());
+    printf("\r\n実行時間 (DFT): %d [μs]\r\n", tm.read_us());
 
     // FFT
     FftReal fft(N);
@@ -44,19 +40,22 @@
     tm.start();
     fft.Execute(x1, y2);
     tm.stop();
-    printf("\r\nExecution time (FFT): %d [us]\r\n", tm.read_us());
-    printf("\r\n#### Result of DFT using FFT ####\r\n");
+    printf("実行時間 (FFT): %d [μs]\r\n", tm.read_us());
+
+    printf("\r\n#### DFT と FFT による結果 ####\r\n");
+    printf("          実部      虚部      実部      虚部\r\n");
     for (int n=0; n<=N/2; n++)
-        printf("F[%2d]: %8.4f, %8.4f\r\n", n, y2[n].real(), y2[n].imag());
+        printf("F[%2d]: %8.4f, %8.4f; %8.4f, %8.4f\r\n",
+               n, y1[n].real(), y1[n].imag(), y2[n].real(), y2[n].imag());
     
     // IFFT
     tm.reset();
     tm.start();
     fft.ExecuteIfft(y2, x2);
     tm.stop();
-    printf("\r\nExecution time (IFFT): %d [us]\r\n", tm.read_us());
-    printf("\r\n#### Result of IFFT ####\r\n");
-    printf("        original  IFFT of FFT\r\n");
+    printf("\r\n実行時間 (IFFT): %d [μs]\r\n", tm.read_us());
+    printf("\r\n#### IFFT の結果 ####\r\n");
+    printf("        元の値    FFT の IFFT\r\n");
     for (int n=0; n<N; n++)
         printf("f[%2d]: %8.4f, %8.4f\r\n", n, x1[n], x2[n]);
 }
\ No newline at end of file