51 int main(
int argc, 
char **argv)
 
   61   double _Complex (*kernel)(double , int , 
const double *);  
 
   64   double _Complex *direct;                                   
 
   73     printf(
"\nfastsum_test d N M n m p kernel c eps_I eps_B\n\n");
 
   74     printf(
"  d       dimension                 \n");
 
   75     printf(
"  N       number of source nodes    \n");
 
   76     printf(
"  M       number of target nodes    \n");
 
   77     printf(
"  n       expansion degree          \n");
 
   78     printf(
"  m       cut-off parameter         \n");
 
   79     printf(
"  p       degree of smoothness      \n");
 
   80     printf(
"  kernel  kernel function  (e.g., gaussian)\n");
 
   81     printf(
"  c       kernel parameter          \n");
 
   82     printf(
"  eps_I   inner boundary            \n");
 
   83     printf(
"  eps_B   outer boundary            \n\n");
 
   89     N=atoi(argv[2]); c=1.0/pow((
double)N,1.0/(
double)d);
 
   98     if (strcmp(s,
"gaussian")==0)
 
  100     else if (strcmp(s,
"multiquadric")==0)
 
  101       kernel = multiquadric;
 
  102     else if (strcmp(s,
"inverse_multiquadric")==0)
 
  103       kernel = inverse_multiquadric;
 
  104     else if (strcmp(s,
"logarithm")==0)
 
  106     else if (strcmp(s,
"thinplate_spline")==0)
 
  107       kernel = thinplate_spline;
 
  108     else if (strcmp(s,
"one_over_square")==0)
 
  109       kernel = one_over_square;
 
  110     else if (strcmp(s,
"one_over_modulus")==0)
 
  111       kernel = one_over_modulus;
 
  112     else if (strcmp(s,
"one_over_x")==0)
 
  114     else if (strcmp(s,
"inverse_multiquadric3")==0)
 
  115       kernel = inverse_multiquadric3;
 
  116     else if (strcmp(s,
"sinc_kernel")==0)
 
  117       kernel = sinc_kernel;
 
  118     else if (strcmp(s,
"cosc")==0)
 
  120     else if (strcmp(s,
"cot")==0)
 
  125       kernel = multiquadric;
 
  128   printf(
"d=%d, N=%d, M=%d, n=%d, m=%d, p=%d, kernel=%s, c=%g, eps_I=%g, eps_B=%g \n",d,N,M,n,m,p,s,c,eps_I,eps_B);
 
  130   printf(
"nearfield correction using piecewise cubic Lagrange interpolation\n");
 
  131 #elif defined(NF_QUADR) 
  132   printf(
"nearfield correction using piecewise quadratic Lagrange interpolation\n");
 
  133 #elif defined(NF_LIN) 
  134   printf(
"nearfield correction using piecewise linear Lagrange interpolation\n");
 
  142       printf(
"nthreads=%d\n", omp_get_max_threads());
 
  150   fastsum_init_guru(&my_fastsum_plan, d, N, M, kernel, &c, 0, n, m, p, eps_I, eps_B);
 
  153   if (my_fastsum_plan.
flags & NEARFIELD_BOXES)
 
  154     printf(
"determination of nearfield candidates based on partitioning into boxes\n");
 
  156     printf(
"determination of nearfield candidates based on search tree\n");
 
  162     double r_max = 0.25 - my_fastsum_plan.
eps_B/2.0;
 
  166       my_fastsum_plan.
x[k*d+j] = 2.0 * r_max * (
double)rand()/(double)RAND_MAX - r_max;
 
  169       r2 += my_fastsum_plan.
x[k*d+j] * my_fastsum_plan.
x[k*d+j];
 
  171     if (r2 >= r_max * r_max)
 
  192     my_fastsum_plan.
alpha[k] = (double)rand()/(double)RAND_MAX + _Complex_I*(
double)rand()/(double)RAND_MAX;
 
  199     double r_max = 0.25 - my_fastsum_plan.
eps_B/2.0;
 
  203       my_fastsum_plan.
y[k*d+j] = 2.0 * r_max * (
double)rand()/(double)RAND_MAX - r_max;
 
  206       r2 += my_fastsum_plan.
y[k*d+j] * my_fastsum_plan.
y[k*d+j];
 
  208     if (r2 >= r_max * r_max)
 
  230   printf(
"direct computation: "); fflush(NULL);
 
  234   time=nfft_elapsed_seconds(t1,t0);
 
  235   printf(
"%fsec\n",time);
 
  238   direct = (
double _Complex *)
nfft_malloc(my_fastsum_plan.
M_total*(
sizeof(
double _Complex)));
 
  239   for (j=0; j<my_fastsum_plan.
M_total; j++)
 
  240     direct[j]=my_fastsum_plan.
f[j];
 
  243   printf(
"pre-computation:    "); fflush(NULL);
 
  247   time=nfft_elapsed_seconds(t1,t0);
 
  248   printf(
"%fsec\n",time);
 
  251   printf(
"fast computation:   "); fflush(NULL);
 
  255   time=nfft_elapsed_seconds(t1,t0);
 
  256   printf(
"%fsec\n",time);
 
  260   for (j=0; j<my_fastsum_plan.
M_total; j++)
 
  262     if (cabs(direct[j]-my_fastsum_plan.
f[j])/cabs(direct[j])>error)
 
  263       error=cabs(direct[j]-my_fastsum_plan.
f[j])/cabs(direct[j]);
 
  265   printf(
"max relative error: %e\n",error);