Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <complex.h>
- #include <math.h>
- int main(int argc, char * argv[]) {
- char input_path[500];
- sprintf(input_path, "%s", argv[1]);
- char output_path[500];
- sprintf(input_path, "%s", argv[2]);
- int P = atoi(argv[3]);
- FILE* input_file = fopen(input_path, "r");
- FILE* output_file = fopen(output_path, "w");
- int N, n, k, i;
- double pi = acos(-1);
- fread(N, 4, 1, input_path);
- double x[N];
- double complex X[N] = {0};
- fread(x, 8, N, input_path);
- double complex exponent;
- for(k = 0; k < N; k++){
- for(n = 0; n < N; n++){
- exponent = ((-2 * pi * I) / N) * k * n;
- X[k] += x[n] * cexp(exponent);
- }
- }
- char buff[300];
- for(i = 0; i < N; i++){
- sprintf(buff, "%f %f\n", creal(X[i]), cimag(X[i]));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement