-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest.c
70 lines (57 loc) · 1.39 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <complex.h>
#include <string.h>
#include <time.h>
#include <fftw3.h>
#include "cfftlog.h"
#include "utils.h"
#include "utils_complex.h"
int main(int argc, char const *argv[])
{
config my_config;
double ell = 1.;
my_config.nu = 1.01;
my_config.c_window_width = 0.25;
my_config.derivative = 0;
my_config.N_pad = 0;
char filename[] = "f1_chi.txt";
FILE *IN = fopen(filename, "r");
// double *ell, *fl;
long Nk = 1000;
double k[Nk], fk[Nk];
long linenum = 0;
while(!feof(IN) && (linenum<Nk)) {
fscanf(IN, "%lg %lg", &k[linenum], &fk[linenum]);
linenum++;
}
printf("linenum, %ld\n", linenum);
double dlnk = log(k[1]/k[0]);
int i,j;
double *r, *result;
r = malloc(Nk * sizeof(double));
result = malloc(Nk * sizeof(double));
for(i=0; i<Nk; i++) {
result[i] = 0.;
}
printf("k:%lg, %lg, %lg\n", k[0], k[1],k[Nk-2]);
clock_t start = clock();
cfftlog(k, fk, Nk, &my_config, ell, r, result);
printf("r:%lg, %lg\n", r[0], r[1]);
printf("result:%lg, %lg\n", result[0], result[1]);
clock_t end = clock();
float seconds = (float)(end - start) / CLOCKS_PER_SEC;
printf("time:%f\n", seconds);
char outfilename[] = "test_1.txt";
FILE *OUT = fopen(outfilename, "w");
for(i=0; i<Nk; i++) {
fprintf(OUT, "%lg %lg", r[i], result[i]);
fprintf(OUT, "\n");
}
fclose(OUT);
fclose(IN);
free(r);
free(result);
return 0;
}