Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <complex.h>
  4. #include <math.h>
  5.  
  6.  
  7. int main(int argc, char * argv[]) {
  8. char input_path[500];
  9. sprintf(input_path, "%s", argv[1]);
  10. char output_path[500];
  11. sprintf(input_path, "%s", argv[2]);
  12. int P = atoi(argv[3]);
  13. FILE* input_file = fopen(input_path, "r");
  14. FILE* output_file = fopen(output_path, "w");
  15. int N, n, k, i;
  16. double pi = acos(-1);
  17. fread(N, 4, 1, input_path);
  18. double x[N];
  19. double complex X[N] = {0};
  20. fread(x, 8, N, input_path);
  21. double complex exponent;
  22. for(k = 0; k < N; k++){
  23.  
  24. for(n = 0; n < N; n++){
  25. exponent = ((-2 * pi * I) / N) * k * n;
  26. X[k] += x[n] * cexp(exponent);
  27. }
  28. }
  29. char buff[300];
  30. for(i = 0; i < N; i++){
  31. sprintf(buff, "%f %f\n", creal(X[i]), cimag(X[i]));
  32. }
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement