47 int main(
int argc,
char **argv)
57 C (*kernel)(R, int,
const R *);
71 printf(
"\nfastsum_test d N M n m p kernel c\n\n");
72 printf(
" d dimension \n");
73 printf(
" N number of source nodes \n");
74 printf(
" M number of target nodes \n");
75 printf(
" n expansion degree \n");
76 printf(
" m cut-off parameter \n");
77 printf(
" p degree of smoothness \n");
78 printf(
" kernel kernel function (e.g., gaussian)\n");
79 printf(
" c kernel parameter \n");
80 printf(
" eps_I inner boundary \n");
81 printf(
" eps_B outer boundary \n\n");
88 c = K(1.0) / POW((R)(N), K(1.0) / ((R)(d)));
94 c = (R)(atof(argv[8]));
95 eps_I = (R)(atof(argv[9]));
96 eps_B = (R)(atof(argv[10]));
97 if (strcmp(s,
"gaussian") == 0)
99 else if (strcmp(s,
"multiquadric") == 0)
100 kernel = multiquadric;
101 else if (strcmp(s,
"inverse_multiquadric") == 0)
102 kernel = inverse_multiquadric;
103 else if (strcmp(s,
"logarithm") == 0)
105 else if (strcmp(s,
"thinplate_spline") == 0)
106 kernel = thinplate_spline;
107 else if (strcmp(s,
"one_over_square") == 0)
108 kernel = one_over_square;
109 else if (strcmp(s,
"one_over_modulus") == 0)
110 kernel = one_over_modulus;
111 else if (strcmp(s,
"one_over_x") == 0)
113 else if (strcmp(s,
"inverse_multiquadric3") == 0)
114 kernel = inverse_multiquadric3;
115 else if (strcmp(s,
"sinc_kernel") == 0)
116 kernel = sinc_kernel;
117 else if (strcmp(s,
"cosc") == 0)
119 else if (strcmp(s,
"cot") == 0)
124 kernel = multiquadric;
128 "d=%d, N=%d, M=%d, n=%d, m=%d, p=%d, kernel=%s, c=%" __FGS__
", eps_I=%" __FGS__
", eps_B=%" __FGS__
" \n",
129 d, N, M, n, m, p, s, c, eps_I, eps_B);
132 fastsum_init_guru(&my_fastsum_plan, d, N, M, kernel, &c, 0, n, m, p, eps_I,
137 fid1 = fopen(
"x.dat",
"r");
138 fid2 = fopen(
"alpha.dat",
"r");
139 for (k = 0; k < N; k++)
141 for (t = 0; t < d; t++)
143 fscanf(fid1, __FR__, &my_fastsum_plan.
x[k * d + t]);
145 fscanf(fid2, __FR__, &temp);
146 my_fastsum_plan.
alpha[k] = temp;
147 fscanf(fid2, __FR__, &temp);
148 my_fastsum_plan.
alpha[k] += temp * II;
154 fid1 = fopen(
"y.dat",
"r");
155 for (j = 0; j < M; j++)
157 for (t = 0; t < d; t++)
159 fscanf(fid1, __FR__, &my_fastsum_plan.
y[j * d + t]);
165 printf(
"direct computation: ");
170 time = NFFT(elapsed_seconds)(t1, t0);
171 printf(__FI__
"sec\n", time);
174 direct = (C *) NFFT(malloc)((size_t)(my_fastsum_plan.
M_total) * (
sizeof(C)));
175 for (j = 0; j < my_fastsum_plan.
M_total; j++)
176 direct[j] = my_fastsum_plan.
f[j];
179 printf(
"pre-computation: ");
184 time = NFFT(elapsed_seconds)(t1, t0);
185 printf(__FI__
"sec\n", time);
188 printf(
"fast computation: ");
193 time = NFFT(elapsed_seconds)(t1, t0);
194 printf(__FI__
"sec\n", time);
198 for (j = 0; j < my_fastsum_plan.
M_total; j++)
200 if (CABS(direct[j] - my_fastsum_plan.
f[j]) / CABS(direct[j]) > error)
201 error = CABS(direct[j] - my_fastsum_plan.
f[j]) / CABS(direct[j]);
203 printf(
"max relative error: " __FE__
"\n", error);
206 fid1 = fopen(
"f.dat",
"w+");
207 fid2 = fopen(
"f_direct.dat",
"w+");
213 for (j = 0; j < M; j++)
215 temp = CREAL(my_fastsum_plan.
f[j]);
216 fprintf(fid1,
" % .16" __FES__
"", temp);
217 temp = CIMAG(my_fastsum_plan.
f[j]);
218 fprintf(fid1,
" % .16" __FES__
"\n", temp);
220 temp = CREAL(direct[j]);
221 fprintf(fid2,
" % .16" __FES__
"", temp);
222 temp = CIMAG(direct[j]);
223 fprintf(fid2,
" % .16" __FES__
"\n", temp);
int M_total
number of target knots
Header file with predefined kernels for the fast summation algorithm.
plan for fast summation algorithm
Header file for the fast NFFT-based summation algorithm.
C * alpha
source coefficients
void fastsum_trafo(fastsum_plan *ths)
fast NFFT-based summation
void fastsum_precompute(fastsum_plan *ths)
precomputation for fastsum
void fastsum_init_guru(fastsum_plan *ths, int d, int N_total, int M_total, kernel k, R *param, unsigned flags, int nn, int m, int p, R eps_I, R eps_B)
initialization of fastsum plan
R * y
target knots in d-ball with radius 1/4-eps_b/2
void fastsum_finalize(fastsum_plan *ths)
finalization of fastsum plan
void fastsum_exact(fastsum_plan *ths)
direct computation of sums
R * x
source knots in d-ball with radius 1/4-eps_b/2