45 int main(
int argc,
char **argv)
55 C (*kernel)(R, int,
const R *);
69 printf(
"\nfastsum_test d N M n m p kernel c\n\n");
70 printf(
" d dimension \n");
71 printf(
" N number of source nodes \n");
72 printf(
" M number of target nodes \n");
73 printf(
" n expansion degree \n");
74 printf(
" m cut-off parameter \n");
75 printf(
" p degree of smoothness \n");
76 printf(
" kernel kernel function (e.g., gaussian)\n");
77 printf(
" c kernel parameter \n");
78 printf(
" eps_I inner boundary \n");
79 printf(
" eps_B outer boundary \n\n");
86 c = K(1.0) / POW((R)(N), K(1.0) / ((R)(d)));
92 c = (R)(atof(argv[8]));
93 eps_I = (R)(atof(argv[9]));
94 eps_B = (R)(atof(argv[10]));
95 if (strcmp(s,
"gaussian") == 0)
97 else if (strcmp(s,
"multiquadric") == 0)
98 kernel = multiquadric;
99 else if (strcmp(s,
"inverse_multiquadric") == 0)
100 kernel = inverse_multiquadric;
101 else if (strcmp(s,
"logarithm") == 0)
103 else if (strcmp(s,
"thinplate_spline") == 0)
104 kernel = thinplate_spline;
105 else if (strcmp(s,
"one_over_square") == 0)
106 kernel = one_over_square;
107 else if (strcmp(s,
"one_over_modulus") == 0)
108 kernel = one_over_modulus;
109 else if (strcmp(s,
"one_over_x") == 0)
111 else if (strcmp(s,
"inverse_multiquadric3") == 0)
112 kernel = inverse_multiquadric3;
113 else if (strcmp(s,
"sinc_kernel") == 0)
114 kernel = sinc_kernel;
115 else if (strcmp(s,
"cosc") == 0)
117 else if (strcmp(s,
"cot") == 0)
122 kernel = multiquadric;
126 "d=%d, N=%d, M=%d, n=%d, m=%d, p=%d, kernel=%s, c=%" __FGS__
", eps_I=%" __FGS__
", eps_B=%" __FGS__
" \n",
127 d, N, M, n, m, p, s, c, eps_I, eps_B);
130 fastsum_init_guru(&my_fastsum_plan, d, N, M, kernel, &c, 0, n, m, p, eps_I,
135 fid1 = fopen(
"x.dat",
"r");
136 fid2 = fopen(
"alpha.dat",
"r");
137 for (k = 0; k < N; k++)
139 for (t = 0; t < d; t++)
141 fscanf(fid1, __FR__, &my_fastsum_plan.
x[k * d + t]);
143 fscanf(fid2, __FR__, &temp);
144 my_fastsum_plan.
alpha[k] = temp;
145 fscanf(fid2, __FR__, &temp);
146 my_fastsum_plan.
alpha[k] += temp * II;
152 fid1 = fopen(
"y.dat",
"r");
153 for (j = 0; j < M; j++)
155 for (t = 0; t < d; t++)
157 fscanf(fid1, __FR__, &my_fastsum_plan.
y[j * d + t]);
163 printf(
"direct computation: ");
168 time = NFFT(elapsed_seconds)(t1, t0);
169 printf(__FI__
"sec\n", time);
172 direct = (C *) NFFT(malloc)((size_t)(my_fastsum_plan.
M_total) * (
sizeof(C)));
173 for (j = 0; j < my_fastsum_plan.
M_total; j++)
174 direct[j] = my_fastsum_plan.
f[j];
177 printf(
"pre-computation: ");
182 time = NFFT(elapsed_seconds)(t1, t0);
183 printf(__FI__
"sec\n", time);
186 printf(
"fast computation: ");
191 time = NFFT(elapsed_seconds)(t1, t0);
192 printf(__FI__
"sec\n", time);
196 for (j = 0; j < my_fastsum_plan.
M_total; j++)
198 if (CABS(direct[j] - my_fastsum_plan.
f[j]) / CABS(direct[j]) > error)
199 error = CABS(direct[j] - my_fastsum_plan.
f[j]) / CABS(direct[j]);
201 printf(
"max relative error: " __FE__
"\n", error);
204 fid1 = fopen(
"f.dat",
"w+");
205 fid2 = fopen(
"f_direct.dat",
"w+");
211 for (j = 0; j < M; j++)
213 temp = CREAL(my_fastsum_plan.
f[j]);
214 fprintf(fid1,
" % .16" __FES__
"", temp);
215 temp = CIMAG(my_fastsum_plan.
f[j]);
216 fprintf(fid1,
" % .16" __FES__
"\n", temp);
218 temp = CREAL(direct[j]);
219 fprintf(fid2,
" % .16" __FES__
"", temp);
220 temp = CIMAG(direct[j]);
221 fprintf(fid2,
" % .16" __FES__
"\n", temp);