diff --git a/5_practice.c b/5_practice.c index 70d6651..8d5262c 100644 --- a/5_practice.c +++ b/5_practice.c @@ -1,40 +1,85 @@ -#include // for printf function -#include // for memory allocation -#include // for time calculation -#include // for sine and cosine functions -int main() { - // Declare all the variables - int k, n, N; - double *x, *yr, *yi; - time_t t; +// +// DFT +// +// Created by Liu Yuting on 2022/3/9. +// - // Input the number N - - - // Locate the memory for x, yr, yi; +#include +#include +#include +#include - // Initial setting for x, for example, x[k] = k - - - - - t = clock(); - // yr[n]+i*yi[n] = sum(exp(-i 2 Pi k n / N)*x[k], k=0..N-1), n=0..N-1 +int main(int argc, const char * argv[]) { + // Declare variables. + int N=7; + int n, k; + int index; + + double *x, *yr, *yi, *cos_array, *sin_array; + x=(double *) malloc(N*sizeof(double)); + yr=(double *) malloc(N*sizeof(double)); + yi=(double *) malloc(N*sizeof(double)); + cos_array=(double *) malloc(N*sizeof(double)); + sin_array=(double *) malloc(N*sizeof(double)); + for(n=0; n