From 4211a5f46640876a3383b1c6c0e3402f199ab24f Mon Sep 17 00:00:00 2001 From: rorysroes Date: Fri, 8 May 2015 20:06:44 +0800 Subject: [PATCH 01/27] fft start --- fft.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 fft.cpp diff --git a/fft.cpp b/fft.cpp new file mode 100644 index 0000000..e69de29 From 54f81f8a1035ba884d9421a8373eaac731f09d5b Mon Sep 17 00:00:00 2001 From: rorysroes Date: Fri, 8 May 2015 21:35:40 +0800 Subject: [PATCH 02/27] fft ver 2 --- fft ver2.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 fft ver2.cpp diff --git a/fft ver2.cpp b/fft ver2.cpp new file mode 100644 index 0000000..01c75b6 --- /dev/null +++ b/fft ver2.cpp @@ -0,0 +1,11 @@ +#include +#include + +int main() +{ + // y_k = sum(x_n * w^{-kn}, n=0..N-1) + // w = cos(2*pi/N)+isin(2*pi/N) + int k ,n ,N; + double *y, *x; + +} From 868a4f4825d7b001063e6d42f59a2f43b5afbc65 Mon Sep 17 00:00:00 2001 From: rorysroes Date: Sun, 10 May 2015 17:43:50 +0800 Subject: [PATCH 03/27] 510 --- fft ver2.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/fft ver2.cpp b/fft ver2.cpp index 01c75b6..2552a2c 100644 --- a/fft ver2.cpp +++ b/fft ver2.cpp @@ -1,11 +1,73 @@ #include #include +#include +#include int main() { // y_k = sum(x_n * w^{-kn}, n=0..N-1) // w = cos(2*pi/N)+isin(2*pi/N) int k ,n ,N; - double *y, *x; + double *y_r, *y_i, *x_r, *x_i, w_r, w_i; + clock_t t1,t2; + //input N + printf("Please input N="); + scanf("%d", &N); //§ä¤@­Ó¾ã¼Æ©ñ¨ìN³o­Ó°O¾ÐÅé¦ì¸m + printf("N=%d\n",N); + //create memory for x and y + x_r = (double * ) malloc(N*sizeof(double)); + x_i = (double * ) malloc(N*sizeof(double)); + y_r = (double * ) malloc(N*sizeof(double)); + y_i = (double * ) malloc(N*sizeof(double)); + for(n=0;n Date: Sun, 10 May 2015 21:12:13 +0800 Subject: [PATCH 04/27] create 8 memorys to do --- fft ver2.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/fft ver2.cpp b/fft ver2.cpp index 2552a2c..6b3d5f2 100644 --- a/fft ver2.cpp +++ b/fft ver2.cpp @@ -2,6 +2,7 @@ #include #include #include +int FFT(double *x_r, double *x_i, double *y_r, double *y_i, int N); int main() { @@ -19,6 +20,7 @@ int main() x_i = (double * ) malloc(N*sizeof(double)); y_r = (double * ) malloc(N*sizeof(double)); y_i = (double * ) malloc(N*sizeof(double)); + for(n=0;n Date: Sun, 10 May 2015 22:41:41 +0800 Subject: [PATCH 05/27] FFT --- fft ver2.cpp | 61 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/fft ver2.cpp b/fft ver2.cpp index 6b3d5f2..8dcafca 100644 --- a/fft ver2.cpp +++ b/fft ver2.cpp @@ -46,38 +46,51 @@ int main() } t2 = clock(); printf("%f secs\n",1.0*(t2 -t1)/CLOCKS_PER_SEC); - system("pause"); + for(n=0;n Date: Sun, 10 May 2015 23:03:51 +0800 Subject: [PATCH 06/27] shift operator --- fft ver2.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fft ver2.cpp b/fft ver2.cpp index 8dcafca..aca66a3 100644 --- a/fft ver2.cpp +++ b/fft ver2.cpp @@ -8,12 +8,13 @@ int main() { // y_k = sum(x_n * w^{-kn}, n=0..N-1) // w = cos(2*pi/N)+isin(2*pi/N) - int k ,n ,N; + int k ,n ,N,p; double *y_r, *y_i, *x_r, *x_i, w_r, w_i; clock_t t1,t2; //input N - printf("Please input N="); - scanf("%d", &N); //§ä¤@­Ó¾ã¼Æ©ñ¨ìN³o­Ó°O¾ÐÅé¦ì¸m + printf("Please input p="); + scanf("%d", &p); + N = 1 << p; //²¾¦ìºâ¤l 2^p ,¥ª²¾ p ­Ó¦ì¸m(ex:p=4 => 1= 0001 => 1000 = 16) printf("N=%d\n",N); //create memory for x and y x_r = (double * ) malloc(N*sizeof(double)); @@ -112,6 +113,11 @@ int FFT(double *x_r, double *x_i, double *y_r, double *y_i, int N) y_i[k+N/2] = even_FT_i[k] - (w_r*odd_FT_i[k] + w_i*odd_FT_r[k]); } + //§â°O¾ÐÅéÁÙ§@·~¨t²Î + free(even_r); + free(even_i); + free(even_FT_r); + free(even_FT_i); /* for(k=N/2;k Date: Mon, 11 May 2015 15:32:23 +0800 Subject: [PATCH 07/27] SFT FFT --- fft ver2.cpp | 95 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 37 deletions(-) diff --git a/fft ver2.cpp b/fft ver2.cpp index aca66a3..eb05d41 100644 --- a/fft ver2.cpp +++ b/fft ver2.cpp @@ -2,34 +2,51 @@ #include #include #include +int SFT(double *x_r, double *x_i, double *y_r, double *y_i, int N); int FFT(double *x_r, double *x_i, double *y_r, double *y_i, int N); +int Generate_N(int p, int q, int r); +int Initial(double *x, double *y, int N); +int Print_Complex_Vector(double *x, double *y, int N); int main() { // y_k = sum(x_n * w^{-kn}, n=0..N-1) // w = cos(2*pi/N)+isin(2*pi/N) - int k ,n ,N,p; + int k ,n ,N, p, q, r; double *y_r, *y_i, *x_r, *x_i, w_r, w_i; clock_t t1,t2; //input N - printf("Please input p="); - scanf("%d", &p); - N = 1 << p; //²¾¦ìºâ¤l 2^p ,¥ª²¾ p ­Ó¦ì¸m(ex:p=4 => 1= 0001 => 1000 = 16) - printf("N=%d\n",N); + printf("Please input p q r="); + scanf("%d %d %d", &p, &q, &r); + N = Generate_N(p, q, r); + printf("N=2^%d 3^%d 5^%d = %d\n", p, q, r, N); + //N = 1 << p; //²¾¦ìºâ¤l 2^p ,¥ª²¾ p ­Ó¦ì¸m(ex:p=4 => 1= 0001 => 1000 = 16) + //printf("N=%d\n",N); //create memory for x and y x_r = (double * ) malloc(N*sizeof(double)); x_i = (double * ) malloc(N*sizeof(double)); y_r = (double * ) malloc(N*sizeof(double)); y_i = (double * ) malloc(N*sizeof(double)); - for(n=0;n=0) printf("%d : %f +%f i\n", n, x[n], y[n]); + else printf("%d : %f %f i\n", n, x[n], y[n]); + } +} From 6897b755a13eea88b2dd100a0490c6dd9fd4c5e3 Mon Sep 17 00:00:00 2001 From: rorysroes Date: Mon, 11 May 2015 17:03:40 +0800 Subject: [PATCH 08/27] Bit_Increase Bit_Reserve --- fft ver2.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/fft ver2.cpp b/fft ver2.cpp index eb05d41..d435677 100644 --- a/fft ver2.cpp +++ b/fft ver2.cpp @@ -7,9 +7,14 @@ int FFT(double *x_r, double *x_i, double *y_r, double *y_i, int N); int Generate_N(int p, int q, int r); int Initial(double *x, double *y, int N); int Print_Complex_Vector(double *x, double *y, int N); +int Bit_Increase(int *D,int b, int N); +int Bit_Reserve(int *D, int b, int N); int main() { + int D[4]; + Bit_Increase(D, 2, 4); + Bit_Reserve(D, 2, 4); // y_k = sum(x_n * w^{-kn}, n=0..N-1) // w = cos(2*pi/N)+isin(2*pi/N) int k ,n ,N, p, q, r; @@ -171,9 +176,55 @@ int Print_Complex_Vector(double *x, double *y, int N) else printf("%d : %f %f i\n", n, x[n], y[n]); } } +int Bit_Increase(int *D, int b, int N) +{ + int i; + // D[3] D[2] D[1] D[0] + //print 0000 0001 0010 0011 0100 0101 ... + for(i=0;i=0;i--) printf("%d", D[i]); + printf("\n"); + D[0] = D[0] + 1; + //check every bit , if D[i] = b => D[i] = 0 , D[i+1]+1 0002 => 0010 + i = 0; + while(D[i]==b & i < N-1) + { + D[i] = 0; + i = i + 1; + D[i] = D[i] + 1; + } + system("pause"); + } + return 0; +} - - +int Bit_Reserve(int *D, int b, int N) +{ + int i; + // D[3] D[2] D[1] D[0] + //print 0000 1000 0100 1100 0010 1010 ... + for(i=0;i=0;i--) printf("%d", D[i]); + printf("\n"); + D[N-1] = D[N-1] + 1; + //check every bit , if D[i] = b => D[i] = 0 , D[i+1]+1 2000 => 0100 + i = N-1; + while(D[i]==b & i > 0) + { + D[i] = 0; + i = i - 1; + D[i] = D[i] + 1; + } + system("pause"); + } + return 0; +} From 460bb2cf5fb5f466a7167a8832e1506aafe87b57 Mon Sep 17 00:00:00 2001 From: rorysroes Date: Mon, 11 May 2015 18:47:40 +0800 Subject: [PATCH 09/27] Bit_Reserve_Integer --- fft ver2.cpp | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/fft ver2.cpp b/fft ver2.cpp index d435677..b45a06c 100644 --- a/fft ver2.cpp +++ b/fft ver2.cpp @@ -9,12 +9,16 @@ int Initial(double *x, double *y, int N); int Print_Complex_Vector(double *x, double *y, int N); int Bit_Increase(int *D,int b, int N); int Bit_Reserve(int *D, int b, int N); +int Bit_Reserve_Integer(int N); int main() { + Bit_Reserve_Integer(8); + /* int D[4]; Bit_Increase(D, 2, 4); Bit_Reserve(D, 2, 4); + */ // y_k = sum(x_n * w^{-kn}, n=0..N-1) // w = cos(2*pi/N)+isin(2*pi/N) int k ,n ,N, p, q, r; @@ -212,20 +216,53 @@ int Bit_Reserve(int *D, int b, int N) { for(i=N-1;i>=0;i--) printf("%d", D[i]); printf("\n"); - D[N-1] = D[N-1] + 1; + //check every bit , if D[i] = b => D[i] = 0 , D[i+1]+1 2000 => 0100 i = N-1; - while(D[i]==b & i > 0) + while(D[i]==b-1 & i > 0) { D[i] = 0; i = i - 1; - D[i] = D[i] + 1; + //D[i] = D[i] + 1; } + D[i] = D[i] + 1; system("pause"); } return 0; } +int Bit_Reserve_Integer(int N) +{ + + // N = 8 + // D[2] D[1] D[0] + //x print 000 100 010 110 001 101 ... + // print 0 4 2 6 1 5 + + int i=0, j=0, M ; + + while(i< N) + { + printf("%d <-> %d", i, j); + //check every bit , if D[i] = b => D[i] = 0 , D[i+1]+1 2000 => 0100 + //i = N-1; + M = N/2 ; + // while(D[i]==b-1 & i>0) + while( j >= M & M > 0) + { + //D[i] = 0; + j = j - M ; + //i = i - 1; + M = M / 2 ; + } + //D[i] = D[i] + 1; + j = j + M ; + i = i + 1 ; + + system("pause"); + } + return 0; +} From 2a8d4543f0c7281cd08f25859ce2eb3b38173a48 Mon Sep 17 00:00:00 2001 From: rorysroes Date: Mon, 11 May 2015 19:56:31 +0800 Subject: [PATCH 10/27] 2 3 5 ver bit reverse --- fft ver2.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/fft ver2.cpp b/fft ver2.cpp index b45a06c..1888390 100644 --- a/fft ver2.cpp +++ b/fft ver2.cpp @@ -13,11 +13,12 @@ int Bit_Reserve_Integer(int N); int main() { - Bit_Reserve_Integer(8); - /* int D[4]; + //Bit_Reserve(D, 5, 4); + Bit_Reserve_Integer(125); + /* Bit_Increase(D, 2, 4); - Bit_Reserve(D, 2, 4); + Bit_Reserve(D, 2, 4); // 2 ¶i¦ì */ // y_k = sum(x_n * w^{-kn}, n=0..N-1) // w = cos(2*pi/N)+isin(2*pi/N) @@ -234,12 +235,51 @@ int Bit_Reserve_Integer(int N) { // N = 8 - // D[2] D[1] D[0] - //x print 000 100 010 110 001 101 ... - // print 0 4 2 6 1 5 - + // D[2] D[1] D[0] + // x print 000 100 010 110 001 101 ... + // print 0 4 2 6 1 5 + // N = 27 + // 0 9 18 3 12 ..... + // N = 125 + // 0 25 .... int i=0, j=0, M ; + while(i < N) + { + printf("%d <-> %d", i, j); + + M = N/5 ; //check 25 + + while( j >= 4 * M & M > 0) + { + j = j - 4 * M ; + M = M / 5 ; + } + j = j + M ; + i = i + 1 ; + + system("pause"); + } + + /*3ªºª©¥» + while(i < N) + { + printf("%d <-> %d", i, j); + + M = N/3 ; //check 9 + + while( j >= 2 * M & M > 0) + { + j = j - 2*M ; + M = M / 3 ; + } + j = j + M ; + i = i + 1 ; + + system("pause"); + } + */ + /*2ªºª©¥» while(i< N) { printf("%d <-> %d", i, j); @@ -261,6 +301,7 @@ int Bit_Reserve_Integer(int N) system("pause"); } + */ return 0; } From edd3336c0638650b86617bde94b5648929f77116 Mon Sep 17 00:00:00 2001 From: rorysroes Date: Mon, 11 May 2015 22:36:12 +0800 Subject: [PATCH 11/27] Group --- fft ver2.cpp | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/fft ver2.cpp b/fft ver2.cpp index 1888390..e00850c 100644 --- a/fft ver2.cpp +++ b/fft ver2.cpp @@ -10,12 +10,15 @@ int Print_Complex_Vector(double *x, double *y, int N); int Bit_Increase(int *D,int b, int N); int Bit_Reserve(int *D, int b, int N); int Bit_Reserve_Integer(int N); +int FFTver3(double *x_r, double *x_i, double *y_r, double *y_i, int N); +int Group(int N); int main() { int D[4]; //Bit_Reserve(D, 5, 4); - Bit_Reserve_Integer(125); + //Bit_Reserve_Integer(125); + Group(8); /* Bit_Increase(D, 2, 4); Bit_Reserve(D, 2, 4); // 2 ¶i¦ì @@ -305,6 +308,87 @@ int Bit_Reserve_Integer(int N) return 0; } +int FFTver3(double *x_r, double *x_i, double *y_r, double *y_i, int N) +{ + + // input : x = x_r + i * x_i + // output : y = y_r + i * y_i + int n; + for(n=0;n= M & M > 0) + { + j = j - M ; + M = M / 2 ; + } + j = j + M ; + i = i + 1 ; + } + + return 0; +} + +int Group(int N) +{ + // N = 8 + // ((0,1) (2,3) (4,5) (6,7)) Big Group number = 1 + // ((0,2) (4,6)) (1,3) (5,7)) Big Group number = 2 + // ((0,4)) ((1,5)) ((2,6)) ((3,7)) Big Group number = 4 + + int n = 1, i, j; + while(n < N) + { + printf("n=%d\n", n); + for(i=0;i Date: Mon, 11 May 2015 23:07:15 +0800 Subject: [PATCH 12/27] FFTver3 --- fft ver2.cpp | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/fft ver2.cpp b/fft ver2.cpp index e00850c..75543da 100644 --- a/fft ver2.cpp +++ b/fft ver2.cpp @@ -18,7 +18,7 @@ int main() int D[4]; //Bit_Reserve(D, 5, 4); //Bit_Reserve_Integer(125); - Group(8); + //Group(8); /* Bit_Increase(D, 2, 4); Bit_Reserve(D, 2, 4); // 2 ¶i¦ì @@ -40,14 +40,14 @@ int main() x_i = (double * ) malloc(N*sizeof(double)); y_r = (double * ) malloc(N*sizeof(double)); y_i = (double * ) malloc(N*sizeof(double)); - + /* Initial(x_r, x_i, N); t1 = clock(); SFT(x_r, x_i, y_r, y_i, N); t2 = clock(); printf("%f secs\n",1.0*(t2 -t1)/CLOCKS_PER_SEC); //Print_Complex_Vector(y_r,y_i, N); - + */ Initial(x_r, x_i, N); t1 = clock(); FFT(x_r, x_i, y_r, y_i, N); @@ -55,6 +55,11 @@ int main() printf("%f secs\n",1.0*(t2 -t1)/CLOCKS_PER_SEC); //Print_Complex_Vector(y_r,y_i, N); + Initial(x_r, x_i, N); + t1 = clock(); + FFTver3(x_r, x_i, y_r, y_i, N); + t2 = clock(); + printf("%f secs\n",1.0*(t2 -t1)/CLOCKS_PER_SEC); } int SFT(double *x_r, double *x_i, double *y_r, double *y_i, int N) { @@ -313,7 +318,7 @@ int FFTver3(double *x_r, double *x_i, double *y_r, double *y_i, int N) // input : x = x_r + i * x_i // output : y = y_r + i * y_i - int n; + int n,k; for(n=0;n Date: Wed, 13 May 2015 03:19:00 +0800 Subject: [PATCH 13/27] midexam --- midexam.cpp | 482 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 482 insertions(+) create mode 100644 midexam.cpp diff --git a/midexam.cpp b/midexam.cpp new file mode 100644 index 0000000..df583f6 --- /dev/null +++ b/midexam.cpp @@ -0,0 +1,482 @@ +#include +#include +#include +#include +int SFT(double *x_r, double *x_i, double *y_r, double *y_i, int N); +int FFT_radix_2(double *x_r, double *x_i, double *y_r, double *y_i, int N); +int FFT_radix_3(double *x_r, double *x_i, double *y_r, double *y_i, int N); +int FFT_radix_5(double *x_r, double *x_i, double *y_r, double *y_i, int N); +int Initial(double *x, double *y, int N); +int Print_Complex_Vector(double *x, double *y, int N); + +int main() +{ + // y_k = sum(x_n * w^{-kn}, n=0..N-1) + // w = cos(2*pi/N)+isin(2*pi/N) + int k ,n ,N; + double *y_r, *y_i, *x_r, *x_i; + clock_t t1,t2; + printf("Please input N="); + scanf("%d", &N); + printf("N = %d\n", N); + + x_r = (double * ) malloc(N*sizeof(double)); + x_i = (double * ) malloc(N*sizeof(double)); + y_r = (double * ) malloc(N*sizeof(double)); + y_i = (double * ) malloc(N*sizeof(double)); + + Initial(x_r, x_i, N); + t1 = clock(); + SFT(x_r, x_i, y_r, y_i, N); + t2 = clock(); + printf("%f secs\n",1.0*(t2 -t1)/CLOCKS_PER_SEC); + //Print_Complex_Vector(y_r,y_i, N); + + Initial(x_r, x_i, N); + if((N%2) == 0) + { + t1 = clock(); + FFT_radix_2(x_r, x_i, y_r, y_i, N); + t2 = clock(); + printf("%f secs\n", 1.0*(t2-t1)/CLOCKS_PER_SEC); + system("pause"); + //Print_Complex_Vector(y_r, y_i, N); + } + else if((N%3) == 0){ + t1 = clock(); + FFT_radix_3(x_r, x_i, y_r, y_i, N); + t2 = clock(); + printf("%f secs\n", 1.0*(t2-t1)/CLOCKS_PER_SEC); + system("pause"); + //Print_Complex_Vector(y_r, y_i, N); + } + else if((N%5) == 0){ + t1 = clock(); + FFT_radix_5(x_r, x_i, y_r, y_i, N); + t2 = clock(); + printf("%f secs\n", 1.0*(t2-t1)/CLOCKS_PER_SEC); + system("pause"); + //Print_Complex_Vector(y_r, y_i, N); + } + else { + printf("Error"); + return 0; + } + return 0; +} +int SFT(double *x_r, double *x_i, double *y_r, double *y_i, int N) +{ + int k, n; + double w_r, w_i; + for(k=0;k=0) printf("%d : %f +%f i\n", n, x[n], y[n]); + else printf("%d : %f %f i\n", n, x[n], y[n]); + } +} + + + + + + + + + + + + + + + + + + + + + + + + From 0d3594ef779f8e3ea9403ac14e1609deea5d3637 Mon Sep 17 00:00:00 2001 From: rorysroes Date: Wed, 13 May 2015 12:26:22 +0800 Subject: [PATCH 14/27] done --- midexam.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/midexam.cpp b/midexam.cpp index df583f6..a8b0a27 100644 --- a/midexam.cpp +++ b/midexam.cpp @@ -24,14 +24,14 @@ int main() x_i = (double * ) malloc(N*sizeof(double)); y_r = (double * ) malloc(N*sizeof(double)); y_i = (double * ) malloc(N*sizeof(double)); - + /* Initial(x_r, x_i, N); t1 = clock(); SFT(x_r, x_i, y_r, y_i, N); t2 = clock(); printf("%f secs\n",1.0*(t2 -t1)/CLOCKS_PER_SEC); //Print_Complex_Vector(y_r,y_i, N); - + */ Initial(x_r, x_i, N); if((N%2) == 0) { @@ -101,7 +101,6 @@ int FFT_radix_2(double *x_r, double *x_i, double *y_r, double *y_i, int N) even_r = (double *) malloc(N*sizeof(double)); even_i = (double *) malloc(N*sizeof(double)); - odd_r = even_r + N/2; //(double *) malloc(N/2*sizeof(double)); odd_i = even_i + N/2; //(double *) malloc(N/2*sizeof(double)); even_FT_r = (double *) malloc(N*sizeof(double)); @@ -115,23 +114,23 @@ int FFT_radix_2(double *x_r, double *x_i, double *y_r, double *y_i, int N) odd_r[n] = x_r[2*n+1]; odd_i[n] = x_i[2*n+1]; } - printf("n = %d",n); - //FFT_radix_2(even_r,even_i,even_FT_r,even_FT_i,N/2); //FFT_radix_2(odd_r,odd_i,odd_FT_r,odd_FT_i,N/2); if((n%2) == 0){ FFT_radix_2(even_r,even_i,even_FT_r,even_FT_i,N/2); - FFT_radix_2(even_r,even_i,even_FT_r,even_FT_i,N/2); + FFT_radix_2(odd_r,odd_i,odd_FT_r,odd_FT_i,N/2); } else if((n%3) == 0){ FFT_radix_3(even_r,even_i,even_FT_r,even_FT_i,N/2); - FFT_radix_3(even_r,even_i,even_FT_r,even_FT_i,N/2); + FFT_radix_3(odd_r,odd_i,odd_FT_r,odd_FT_i,N/2); } else{ FFT_radix_5(even_r,even_i,even_FT_r,even_FT_i,N/2); - FFT_radix_5(even_r,even_i,even_FT_r,even_FT_i,N/2); + FFT_radix_5(odd_r,odd_i,odd_FT_r,odd_FT_i,N/2); } + //w_r = cos(-2.0*M_PI/(2*N)); + //w_i = sin(-2.0*M_PI/(2*N)); for(k=0;k Date: Mon, 1 Jun 2015 18:10:23 +0800 Subject: [PATCH 15/27] bug : r -> i --- midexam.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/midexam.cpp b/midexam.cpp index a8b0a27..9ad62b9 100644 --- a/midexam.cpp +++ b/midexam.cpp @@ -40,7 +40,7 @@ int main() t2 = clock(); printf("%f secs\n", 1.0*(t2-t1)/CLOCKS_PER_SEC); system("pause"); - //Print_Complex_Vector(y_r, y_i, N); + Print_Complex_Vector(y_r, y_i, N); } else if((N%3) == 0){ t1 = clock(); @@ -48,7 +48,7 @@ int main() t2 = clock(); printf("%f secs\n", 1.0*(t2-t1)/CLOCKS_PER_SEC); system("pause"); - //Print_Complex_Vector(y_r, y_i, N); + Print_Complex_Vector(y_r, y_i, N); } else if((N%5) == 0){ t1 = clock(); @@ -56,7 +56,7 @@ int main() t2 = clock(); printf("%f secs\n", 1.0*(t2-t1)/CLOCKS_PER_SEC); system("pause"); - //Print_Complex_Vector(y_r, y_i, N); + Print_Complex_Vector(y_r, y_i, N); } else { printf("Error"); @@ -352,7 +352,7 @@ int FFT_radix_5(double *x_r, double *x_i, double *y_r, double *y_i, int N) y_i[k] += w_r*five_1_FTi[k+2*N/5] + w_i*five_1_FTr[k+2*N/5]; w_r = cos(-k*6*M_PI/N); w_i = sin(-k*6*M_PI/N); - y_r[k] += w_r*five_1_FTr[k+3*N/5] - w_i*five_1_FTr[k+3*N/5]; + y_r[k] += w_r*five_1_FTr[k+3*N/5] - w_i*five_1_FTi[k+3*N/5]; y_i[k] += w_r*five_1_FTi[k+3*N/5] + w_i*five_1_FTr[k+3*N/5]; w_r = cos(-k*8*M_PI/N); w_i = sin(-k*8*M_PI/N); From bb279a861907bf3a24ad944857138b0fb67e05ad Mon Sep 17 00:00:00 2001 From: rorysroes Date: Tue, 9 Jun 2015 21:04:08 +0800 Subject: [PATCH 16/27] FFT done --- "\344\277\256\346\255\243\347\211\210mid.cpp" | 477 ++++++++++++++++++ 1 file changed, 477 insertions(+) create mode 100644 "\344\277\256\346\255\243\347\211\210mid.cpp" diff --git "a/\344\277\256\346\255\243\347\211\210mid.cpp" "b/\344\277\256\346\255\243\347\211\210mid.cpp" new file mode 100644 index 0000000..3c0257e --- /dev/null +++ "b/\344\277\256\346\255\243\347\211\210mid.cpp" @@ -0,0 +1,477 @@ +#include +#include +#include +#include +int SFT(double *x_r, double *x_i, double *y_r, double *y_i, int N); +int FFT_radix_2(double *x_r, double *x_i, double *y_r, double *y_i, int N); +int FFT_radix_3(double *x_r, double *x_i, double *y_r, double *y_i, int N); +int FFT_radix_5(double *x_r, double *x_i, double *y_r, double *y_i, int N); +int Initial(double *x, double *y, int N); +int Print_Complex_Vector(double *x, double *y, int N); + +int main() +{ + // y_k = sum(x_n * w^{-kn}, n=0..N-1) + // w = cos(2*pi/N)+isin(2*pi/N) + int k ,n ,N=1,q,p,r; + double *y_r, *y_i, *x_r, *x_i; + clock_t t1,t2; + printf("Please input p q r="); + scanf("%d %d %d", &p,&q,&r); + for(int i = 0;i

=0) printf("%d : %f +%f i\n", n, x[n], y[n]); + else printf("%d : %f %f i\n", n, x[n], y[n]); + } +} + From 782276e184bc7bffd78d524e982f8e5dcdfec19a Mon Sep 17 00:00:00 2001 From: CHANG SHU ZHONG Date: Wed, 8 Feb 2017 16:12:31 +0800 Subject: [PATCH 17/27] Create README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b180278 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# midexam +快速計算方法 期中考 實作(Cooley–Tukey FFT algorithm) + +## Overview +### In this project I implemented FFT algorithm with radix_2, radix_3 and radix_5 From 39ed389bcfa39d2fcb096f578adf0abb570a5d1e Mon Sep 17 00:00:00 2001 From: CHANG SHU ZHONG Date: Wed, 8 Feb 2017 16:20:41 +0800 Subject: [PATCH 18/27] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b180278..4acb424 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,6 @@ 快速計算方法 期中考 實作(Cooley–Tukey FFT algorithm) ## Overview -### In this project I implemented FFT algorithm with radix_2, radix_3 and radix_5 +This project I implemented FFT algorithm with radix_2, radix_3 and radix_5 + + From cff7ea613610d527ceaaa89e5ced00cb80d9bc55 Mon Sep 17 00:00:00 2001 From: CHANG SHU ZHONG Date: Wed, 8 Feb 2017 16:21:07 +0800 Subject: [PATCH 19/27] Update README.md --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 4acb424..9fd5296 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,4 @@ -# midexam -快速計算方法 期中考 實作(Cooley–Tukey FFT algorithm) - ## Overview -This project I implemented FFT algorithm with radix_2, radix_3 and radix_5 +This project I implemented Cooley–Tukey FFT algorithm with radix_2, radix_3 and radix_5 From b95f5c017757e5a68de9858a13bbacc3dd7d63ad Mon Sep 17 00:00:00 2001 From: CHANG SHU ZHONG Date: Wed, 8 Feb 2017 16:22:57 +0800 Subject: [PATCH 20/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9fd5296..91a3720 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ ## Overview This project I implemented Cooley–Tukey FFT algorithm with radix_2, radix_3 and radix_5 - +[Note] : [FFT Code] (https://github.com/rorysroes/midexam/blob/Fast_Fourier_Transform/修正版mid.cpp) From c54e8c8e5b193afc2bce292a3bcbe01ecfc3ee88 Mon Sep 17 00:00:00 2001 From: CHANG SHU ZHONG Date: Wed, 8 Feb 2017 16:23:08 +0800 Subject: [PATCH 21/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 91a3720..f1e1e6c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ ## Overview This project I implemented Cooley–Tukey FFT algorithm with radix_2, radix_3 and radix_5 -[Note] : [FFT Code] (https://github.com/rorysroes/midexam/blob/Fast_Fourier_Transform/修正版mid.cpp) +\\[Note] : [FFT Code] (https://github.com/rorysroes/midexam/blob/Fast_Fourier_Transform/修正版mid.cpp) From 74a1a397fdd84e1784da9277474eceef245a3c75 Mon Sep 17 00:00:00 2001 From: CHANG SHU ZHONG Date: Wed, 8 Feb 2017 16:23:42 +0800 Subject: [PATCH 22/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f1e1e6c..5b7d503 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ ## Overview This project I implemented Cooley–Tukey FFT algorithm with radix_2, radix_3 and radix_5 -\\[Note] : [FFT Code] (https://github.com/rorysroes/midexam/blob/Fast_Fourier_Transform/修正版mid.cpp) +\[Note] : [FFT Code] (https://github.com/rorysroes/midexam/blob/Fast_Fourier_Transform/修正版mid.cpp) From eda46b642d9becc13de9d1284c83cdff7557c017 Mon Sep 17 00:00:00 2001 From: CHANG SHU ZHONG Date: Wed, 8 Feb 2017 16:25:04 +0800 Subject: [PATCH 23/27] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5b7d503..24629b1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Overview +## Fast Fourier Tranform This project I implemented Cooley–Tukey FFT algorithm with radix_2, radix_3 and radix_5 -\[Note] : [FFT Code] (https://github.com/rorysroes/midexam/blob/Fast_Fourier_Transform/修正版mid.cpp) +[FFT Code] (https://github.com/rorysroes/midexam/blob/Fast_Fourier_Transform/修正版mid.cpp) From 09dbccb7bdc2d2aa5b491d7d204e119a4bce304e Mon Sep 17 00:00:00 2001 From: CHANG SHU ZHONG Date: Wed, 8 Feb 2017 16:25:38 +0800 Subject: [PATCH 24/27] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 24629b1..ea8c4b3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -## Fast Fourier Tranform -This project I implemented Cooley–Tukey FFT algorithm with radix_2, radix_3 and radix_5 +## Fast Fourier Tranform [FFT Code] (https://github.com/rorysroes/midexam/blob/Fast_Fourier_Transform/修正版mid.cpp) - +This project I implemented Cooley–Tukey FFT algorithm with radix_2, radix_3 and radix_5 From f6eeb1bd707e79a0947a15f43a854ea4b392e1ef Mon Sep 17 00:00:00 2001 From: CHANG SHU ZHONG Date: Wed, 8 Feb 2017 16:25:57 +0800 Subject: [PATCH 25/27] Update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ea8c4b3..0d30818 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ ## Fast Fourier Tranform -[FFT Code] (https://github.com/rorysroes/midexam/blob/Fast_Fourier_Transform/修正版mid.cpp) +[FFT Code] (https://github.com/rorysroes/midexam/blob/Fast_Fourier_Transform/修正版mid.cpp): This project I implemented Cooley–Tukey FFT algorithm with radix_2, radix_3 and radix_5 From 1945bf1d46a094796f36ed3f8096dd4e8d581bcb Mon Sep 17 00:00:00 2001 From: CHANG SHU ZHONG Date: Wed, 8 Feb 2017 16:26:08 +0800 Subject: [PATCH 26/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d30818..1e5e2d5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ ## Fast Fourier Tranform -[FFT Code] (https://github.com/rorysroes/midexam/blob/Fast_Fourier_Transform/修正版mid.cpp): +[FFT Code] (https://github.com/rorysroes/midexam/blob/Fast_Fourier_Transform/修正版mid.cpp): This project I implemented Cooley–Tukey FFT algorithm with radix_2, radix_3 and radix_5 From 3e6f3c7cd587819e514a9205941cefe803a4ed05 Mon Sep 17 00:00:00 2001 From: CHANG SHU ZHONG <104352033@nccu.edu.tw> Date: Sat, 18 Feb 2017 17:28:25 +0800 Subject: [PATCH 27/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e5e2d5..ce165b9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ ## Fast Fourier Tranform -[FFT Code] (https://github.com/rorysroes/midexam/blob/Fast_Fourier_Transform/修正版mid.cpp): +[FFT Code] (https://github.com/rorysroes/Fast_Algorithm_FFT/blob/Fast_Fourier_Transform/修正版mid.cpp): This project I implemented Cooley–Tukey FFT algorithm with radix_2, radix_3 and radix_5