43 static void voronoi_weights_S2(R *w, R *xi, INT M)
74 x = (R*)
X(malloc)(M *
sizeof(R));
75 y = (R*)
X(malloc)(M *
sizeof(R));
76 z = (R*)
X(malloc)(M *
sizeof(R));
78 list = (
int*)
X(malloc)((6*M-12+1)*
sizeof(
int));
79 lptr = (
int*)
X(malloc)((6*M-12+1)*
sizeof(
int));
80 lend = (
int*)
X(malloc)((M+1)*
sizeof(
int));
81 near = (
int*)
X(malloc)((M+1)*
sizeof(
int));
82 next = (
int*)
X(malloc)((M+1)*
sizeof(
int));
83 dist = (R*)
X(malloc)((M+1)*
sizeof(R));
84 ltri = (
int*)
X(malloc)((6*M+1)*
sizeof(
int));
85 listc = (
int*)
X(malloc)((6*M-12+1)*
sizeof(
int));
86 xc = (R*)
X(malloc)((2*M-4+1)*
sizeof(R));
87 yc = (R*)
X(malloc)((2*M-4+1)*
sizeof(R));
88 zc = (R*)
X(malloc)((2*M-4+1)*
sizeof(R));
89 rc = (R*)
X(malloc)((2*M-4+1)*
sizeof(R));
90 vr = (R*)
X(malloc)(3*(2*M-4+1)*
sizeof(R));
94 for (k = 0; k < M; k++)
96 x[k] = SIN(K2PI*xi[2*k+1])*COS(K2PI*xi[2*k]);
97 y[k] = SIN(K2PI*xi[2*k+1])*SIN(K2PI*xi[2*k]);
98 z[k] = COS(K2PI*xi[2*k+1]);
102 trmesh_(&Mlocal, x, y, z, list, lptr, lend, &lnew, near, next, dist, &ier);
108 crlist_(&Mlocal, &Mlocal, x, y, z, list, lend, lptr, &lnew, ltri, listc, &nb, xc,
114 for (k = 0; k < M; k++)
132 vr[3*j+1] = yc[kv-1];
133 vr[3*j+2] = zc[kv-1];
138 for (el = 0; el < j; el++)
140 a += areas_(vr, &vr[3*(el+1)],&vr[3*(((el+1)%j)+1)]);
169 enum boolean {NO = 0, YES = 1};
181 int main (
int argc,
char **argv)
206 double _Complex *temp2;
213 double *alpha, *beta, *gamma;
216 fscanf(stdin,
"testcases=%d\n",&T);
217 fprintf(stderr,
"%d\n",T);
220 for (t = 0; t < T; t++)
223 fscanf(stdin,
"nfsft=%d\n",&use_nfsft);
224 fprintf(stderr,
"%d\n",use_nfsft);
228 fscanf(stdin,
"nfft=%d\n",&use_nfft);
229 fprintf(stderr,
"%d\n",use_nfsft);
233 fscanf(stdin,
"cutoff=%d\n",&cutoff);
234 fprintf(stderr,
"%d\n",cutoff);
243 fscanf(stdin,
"fpt=%d\n",&use_fpt);
244 fprintf(stderr,
"%d\n",use_fpt);
248 fscanf(stdin,
"threshold=%lf\n",&threshold);
249 fprintf(stderr,
"%lf\n",threshold);
269 fscanf(stdin,
"bandwidth=%d\n",&N);
270 fprintf(stderr,
"%d\n",N);
277 fscanf(stdin,
"nodes=%d\n",&M);
278 fprintf(stderr,
"%d\n",M);
283 X(next_power_of_2_exp_int)(N, &npt, &npt_exp);
284 fprintf(stderr,
"npt = %d, npt_exp = %d\n", npt, npt_exp);
285 fprintf(stderr,
"Optimal interpolation!\n");
287 temp = (
double*)
nfft_malloc((2*N+1)*
sizeof(double));
288 temp2 = (
double _Complex*)
nfft_malloc((N+1)*
sizeof(
double _Complex));
291 for (j = 0; j <= N; j++)
293 xs = 2.0 + (2.0*j)/(N+1);
294 ys[j] = (2.0-((j == 0)?(1.0):(0.0)))*4.0*nfft_bsplines(4,xs);
299 for (j = 0; j <= N; j++)
305 qweights = (
double*)
nfft_malloc(qlength*
sizeof(
double));
307 fplan = fftw_plan_r2r_1d(N+1, qweights, qweights, FFTW_REDFT00, 0U);
308 for (j = 0; j < N+1; j++)
310 qweights[j] = -2.0/(4*j*j-1);
315 for (j = 0; j < N+1; j++)
317 qweights[j] *= 1.0/(2.0*N+1.0);
318 qweights[2*N+1-1-j] = qweights[j];
321 fplan = fftw_plan_r2r_1d(2*N+1, temp, temp, FFTW_REDFT00, 0U);
322 for (j = 0; j <= N; j++)
324 temp[j] = ((j==0 || j == 2*N)?(1.0):(0.5))*ys[j];
326 for (j = N+1; j < 2*N+1; j++)
332 for (j = 0; j < 2*N+1; j++)
334 temp[j] *= qweights[j];
339 for (j = 0; j < 2*N+1; j++)
341 temp[j] *= ((j==0 || j == 2*N)?(1.0):(0.5));
350 alpha = (
double*)
nfft_malloc((N+2)*
sizeof(double));
351 beta = (
double*)
nfft_malloc((N+2)*
sizeof(double));
352 gamma = (
double*)
nfft_malloc((N+2)*
sizeof(double));
354 alpha_al_row(alpha, N, 0);
355 beta_al_row(beta, N, 0);
356 gamma_al_row(gamma, N, 0);
368 fftw_destroy_plan(fplan);
376 nfsft_init_guru(&plan, N, M,
394 for (j = 0; j < M; j++)
396 fscanf(stdin,
"%le %le %le %le\n",&plan.
x[2*j+1],&plan.
x[2*j],&re,&im);
397 plan.
x[2*j+1] = plan.
x[2*j+1]/(2.0*KPI);
398 plan.
x[2*j] = plan.
x[2*j]/(2.0*KPI);
399 if (plan.
x[2*j] >= 0.5)
401 plan.
x[2*j] = plan.
x[2*j] - 1;
403 iplan.
y[j] = re + _Complex_I * im;
404 fprintf(stderr,
"%le %le %le %le\n",plan.
x[2*j+1],plan.
x[2*j],
405 creal(iplan.
y[j]),cimag(iplan.
y[j]));
409 fscanf(stdin,
"nodes_eval=%d\n",&M2);
410 fprintf(stderr,
"%d\n",M2);
413 nfsft_init_guru(&plan2, N, M2,
422 for (j = 0; j < M2; j++)
424 fscanf(stdin,
"%le %le\n",&plan2.
x[2*j+1],&plan2.
x[2*j]);
425 plan2.
x[2*j+1] = plan2.
x[2*j+1]/(2.0*KPI);
426 plan2.
x[2*j] = plan2.
x[2*j]/(2.0*KPI);
427 if (plan2.
x[2*j] >= 0.5)
429 plan2.
x[2*j] = plan2.
x[2*j] - 1;
431 fprintf(stderr,
"%le %le\n",plan2.
x[2*j+1],plan2.
x[2*j]);
434 nfsft_precompute_x(&plan);
436 nfsft_precompute_x(&plan2);
453 for (j = 0; j < plan.
N_total; j++)
455 iplan.
w_hat[j] = 0.0;
458 for (k = 0; k <= N; k++)
460 for (j = -k; j <= k; j++)
468 for (j = 0; j < plan.
N_total; j++)
470 iplan.
w_hat[j] = 0.0;
473 for (k = 0; k <= N; k++)
475 for (j = -k; j <= k; j++)
482 voronoi_weights_S2(iplan.
w, plan.
x, M);
486 for (j = 0; j < plan.
M_total; j++)
488 fprintf(stderr,
"%le\n",iplan.
w[j]);
491 fprintf(stderr,
"sum = %le\n",a);
494 fprintf(stderr,
"N_total = %d\n", plan.
N_total);
495 fprintf(stderr,
"M_total = %d\n", plan.
M_total);
498 for (k = 0; k < plan.
N_total; k++)
504 solver_before_loop_complex(&iplan);
511 for (m = 0; m < 29; m++)
513 fprintf(stderr,
"Residual ||r||=%e,\n",sqrt(iplan.
dot_r_iter));
514 solver_loop_one_step_complex(&iplan);
536 for (k = 0; k < plan2.
M_total; k++)
538 fprintf(stdout,
"%le\n",cabs(plan2.
f[k]));
541 solver_finalize_complex(&iplan);
#define NFSFT_MALLOC_F_HAT
double * x
the nodes for ,
void nfsft_trafo(nfsft_plan *plan)
int main(int argc, char **argv)
The main program.
#define PRECOMPUTE_WEIGHT
fftw_complex * f_hat
Fourier coefficients.
void fpt_transposed(fpt_set set, const int m, double _Complex *x, double _Complex *y, const int k_end, const unsigned int flags)
void nfsft_precompute(int N, double kappa, unsigned int nfsft_flags, unsigned int fpt_flags)
double * w
weighting factors
data structure for an NFSFT (nonequispaced fast spherical Fourier transform) plan with double precisi...
#define NFSFT_NO_FAST_ALGORITHM
double dot_r_iter
weighted dotproduct of r_iter
void fpt_precompute(fpt_set set, const int m, double *alpha, double *beta, double *gam, int k_start, const double threshold)
Holds data for a set of cascade summations.
NFFT_INT M_total
Total number of samples.
#define X(name)
Include header for C99 complex datatype.
void * nfft_malloc(size_t n)
NFFT_INT N_total
Total number of Fourier coefficients.
fpt_set fpt_init(const int M, const int t, const unsigned int flags)
void nfsft_finalize(nfsft_plan *plan)
fftw_complex * y
right hand side, samples
Header file for the nfft3 library.
data structure for an inverse NFFT plan with double precision
#define NFSFT_INDEX(k, n, plan)
#define CSWAP(x, y)
Swap two vectors.
double * w_hat
damping factors
fftw_complex * f_hat_iter
iterative solution